# vrchat-community/vrc-oscquery-lib architecture

> Architecture diagram of the GitHub repository vrchat-community/vrc-oscquery-lib, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vrchat-community/vrc-oscquery-lib
- Repository: https://github.com/vrchat-community/vrc-oscquery-lib

## Overview

##### Project Type and Purpose
- This is a cross-platform C# .NET library (“vrc-oscquery-lib”) implementing the OSCQuery protocol. It provides:
- Service discovery via mDNS/Zeroconf
- An embedded HTTP/1.1 server exposing a JSON tree of OSC endpoints
- A fluent builder API for library consumers to advertise and manage OSC methods
- It’s accompanied by console-app examples (DataSender, DataReceiver, LogAdvertisers), a Unity example project (OSCQueryExplorer-Unity), and unit tests.

##### Key Architectural Components
a. Core Library (vrc-oscquery-lib)
- OSCQueryServiceBuilder → configures and constructs an OSCQueryService
- OSCQueryService → hosts:
– Zeroconf advertiser (in Zeroconf/MeaModDiscovery.cs)
– HTTP server (listening on a TCP port, parses URLs into OSCQueryNode lookups)
– In-memory node tree (OSCQueryNode, OSCQueryServiceProfile)
- Public API: AddEndpoint/RemoveEndpoint to manage OSC address entries
- Resource: embedded OSCQueryExplorer.html returned by HTTP when “?explorer” is appended
b. Discovery Layer
- Zeroconf library for mDNS advertising of “_oscjson._tcp” service type
- Example “LogAdvertisers” console app listens for these advertisements
c. HTTP Layer
- HTTP 1.1 listener (depending on .NET HTTPListener or Kestrel)
- JSON serialization of node tree and attributes
- Query-string parsing for explorer UI or host info
d. Consumers / Examples
- DataSender: advertises its own OSCQuery/OSC service and exposes random int endpoints
- DataReceiver: DNS-discovers services, polls HTTP for JSON updates
- OSCQueryExplorer-Unity: Unity runtime client showing scenes for sending/receiving OSC via library
- TerminalGuiAddons: shared UI helpers for console apps
e. Testing
- Unit tests in Tests/vrc-oscquery-tests cover core model and spec compliance

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Library Layer
    subgraph "Core Library"
        direction TB
        Builder["OSCQueryServiceBuilder"]:::core
        Service["OSCQueryService"]:::core
        HttpServer["OSCQueryHttpServer"]:::core
        NodeTree["OSCQueryNode<br/>(Node Tree)"]:::core
        Profile["OSCQueryServiceProfile"]:::core
        HostInfo["HostInfo"]:::core
        Extensions["Extensions (Public API)"]:::core
        Attributes["Attributes (Metadata)"]:::core
        ExplorerUI["OSCQueryExplorer.html<br/>(Embedded UI)"]:::core
    end

    %% Discovery Layer
    subgraph "Discovery Layer"
        direction TB
        ZeroconfTypes["ZeroconfTypes"]:::external
        MeaModDiscovery["MeaModDiscovery"]:::core
        mDNSCloud(("mDNS / Zeroconf")):::network
    end

    %% HTTP Layer
    subgraph "HTTP Layer"
        direction TB
        HTTPLib["HTTPListener / Kestrel"]:::external
        JSONSerializer["JSON Serializer"]:::external
        HTTPCloud(("HTTP/1.1 Network")):::network
    end

    %% Consumer Applications
    subgraph "Consumer Apps"
        direction TB
        DataSender["DataSender"]:::consumer
        DataReceiver["DataReceiver"]:::consumer
        LogAdvertisers["LogAdvertisers"]:::consumer
        UnityExplorer["OSCQueryExplorer-Unity"]:::consumer
        StatusLogger["StatusLogger"]:::consumer
        VRChatIntegration["VRChat Integration"]:::consumer
    end

    %% Core Library Relationships
    Builder -->|"builds"| Service
    Service -->|"advertises via"| MeaModDiscovery
    Service -->|"hosts"| HttpServer
    Service -->|"manages"| NodeTree
    NodeTree -->|"uses profile"| Profile
    Service -->|"maintains"| HostInfo
    Service -->|"provides extensions"| Extensions
    Service -->|"uses attributes"| Attributes
    HttpServer -->|"serves"| ExplorerUI

    %% Discovery Flow
    MeaModDiscovery -->|"mDNS Advertise"| mDNSCloud
    mDNSCloud -->|"discover"| DataReceiver
    mDNSCloud -->|"discover"| LogAdvertisers

    %% HTTP Flow
    HttpServer -->|"binds via"| HTTPLib
    HTTPLib -->|"over"| HTTPCloud
    DataReceiver -->|"HTTP GET /.. → JSON"| HTTPCloud
    UnityExplorer -->|"HTTP GET /.. → JSON"| HTTPCloud
    VRChatIntegration -->|"HTTP GET /.. → JSON"| HTTPCloud
    HTTPCloud -->|"JSON Response"| DataReceiver
    HTTPCloud -->|"JSON Response"| UnityExplorer
    HTTPCloud -->|"JSON Response"| VRChatIntegration

    %% Consumer Interactions
    DataSender -->|"calls"| Builder
    DataSender -->|"uses"| Extensions
    DataReceiver -->|"uses"| Extensions
    LogAdvertisers -->|"uses"| ZeroconfTypes
    DataSender -->|"logs via"| StatusLogger
    DataReceiver -->|"logs via"| StatusLogger
    LogAdvertisers -->|"logs via"| StatusLogger
    UnityExplorer -->|"integrates runtime"| Service

    %% Click Events
    click Builder "https://github.com/vrchat-community/vrc-oscquery-lib/blob/main/vrc-oscquery-lib/OSCQueryServiceBuilder.cs"
    click Service "https://github.com/vrchat-community/vrc-oscquery-lib/blob/main/vrc-oscquery-lib/OSCQueryService.cs"
    click HttpServer "https://github.com/vrchat-community/vrc-oscquery-lib/blob/main/vrc-oscquery-lib/OSCQueryHttpServer.cs"
    click NodeTree "https://github.com/vrchat-community/vrc-oscquery-lib/blob/main/vrc-oscquery-lib/OSCQueryNode.cs"
    click Profile "https://github.com/vrchat-community/vrc-oscquery-lib/blob/main/vrc-oscquery-lib/OSCQueryServiceProfile.cs"
    click HostInfo "https://github.com/vrchat-community/vrc-oscquery-lib/blob/main/vrc-oscquery-lib/HostInfo.cs"
    click Extensions "https://github.com/vrchat-community/vrc-oscquery-lib/blob/main/vrc-oscquery-lib/Extensions.cs"
    click Attributes "https://github.com/vrchat-community/vrc-oscquery-lib/blob/main/vrc-oscquery-lib/Attributes.cs"
    click ExplorerUI "https://github.com/vrchat-community/vrc-oscquery-lib/blob/main/vrc-oscquery-lib/Resources/OSCQueryExplorer.html"
    click ZeroconfTypes "https://github.com/vrchat-community/vrc-oscquery-lib/blob/main/vrc-oscquery-lib/Zeroconf/ZeroconfTypes.cs"
    click MeaModDiscovery "https://github.com/vrchat-community/vrc-oscquery-lib/blob/main/vrc-oscquery-lib/Zeroconf/MeaModDiscovery.cs"
    click DataSender "https://github.com/vrchat-community/vrc-oscquery-lib/blob/main/Examples/DataSender/Program.cs"
    click DataSender "https://github.com/vrchat-community/vrc-oscquery-lib/blob/main/Examples/DataSender/OSCQueryServiceWindow.cs"
    click DataReceiver "https://github.com/vrchat-community/vrc-oscquery-lib/blob/main/Examples/DataReceiver/Program.cs"
    click DataReceiver "https://github.com/vrchat-community/vrc-oscquery-lib/blob/main/Examples/DataReceiver/FindServiceDialog.cs"
    click LogAdvertisers "https://github.com/vrchat-community/vrc-oscquery-lib/blob/main/LogAdvertisers/Program.cs"
    click UnityExplorer "https://github.com/vrchat-community/vrc-oscquery-lib/tree/main/Examples/OSCQueryExplorer-Unity/Assets/OSCQuery/Runtime"
    click UnityExplorer "https://github.com/vrchat-community/vrc-oscquery-lib/blob/main/Examples/OSCQueryExplorer-Unity/Assets/OSCQuery/Runtime/Plugins/Resources/OSCQueryExplorer.html"
    click StatusLogger "https://github.com/vrchat-community/vrc-oscquery-lib/blob/main/Examples/TerminalGuiAddons/StatusLogger.cs"

    %% Styles
    classDef core fill:#b7e3a8,stroke:#333,stroke-width:1px
    classDef consumer fill:#a8c4e3,stroke:#333,stroke-width:1px
    classDef external fill:#f3c28b,stroke:#333,stroke-width:1px
    classDef network fill:#d3d3d3,stroke:#333,stroke-width:1px
```
