# vrcx-team/vrcx architecture

> Architecture diagram of the GitHub repository vrcx-team/vrcx, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vrcx-team/vrcx
- Repository: https://github.com/vrcx-team/vrcx

## Overview

##### Main System Components
- Backend (.NET Application):
- App API: Organized under Dotnet/AppApi with subdirectories “Cef”, “Electron”, and “Common”. These modules include code for VRChat integration (e.g., game handling, screenshot capture, registry access) and share common functionality.
- Native Windows/Overlay Components: Within directories like Dotnet/Cef, Dotnet/Overlay, Dotnet/OpenVR, and others, you have modules for rendering and handling user interactions with Windows forms as well as overlays (VR forms, offscreen browsers, etc.).
- IPC Mechanism: Found under Dotnet/IPC. This is likely used for inter-process communication between various parts (for example, between the .NET backend and the Electron process).
- Service Utilities: Various utility classes (e.g., LogWatcher, ProcessMonitor, Update, JsonFileSerializer, etc.) that support application life-cycle and maintenance.
- Data Management: Modules like Dotnet/PWI (for world persistence) and SQLiteLegacy, as well as repository and shared data components (found under src/repository) that hint at local caching or database operations.

- Frontend (Electron & Web UI):
- Electron Integration: Code under src-electron (including main.js, preload.js, and related interop scripts) manages launching the Electron shell and interfacing with the .NET backend.
- Web UI/Client Side: The “src” directory contains reactive components (with Vue components, Pug templates, SCSS styling, etc.), localization resources, and service logic (API calls, websockets, etc.) to build a slick user interface. This layer renders views (login, feed, dialogs, tabs) and organizes components (favorites, sidebar, charts) for user interaction.
- Localization and Theming: Multiple directories and files in “src/localization” and various SCSS theme files indicate robust support for multiple languages and visual designs.

- Installer and Build Tools:
- Supporting files (e.g., .nsi installer file, build-installer.bat, and scripts for generating bundles) should be listed as part of the deployment pipeline.

- External Services and Data Sources:
- VRChat API: While not directly within the repository, the application interacts with external VRChat API endpoints and uses Discord Rich Presence integration. Represent these as external systems.
- Possibly a local database (SQLite or similar) and an image cache/component for persisting image data and screenshots.

##### Relationships and Data Flows
- The VRChat API (an external component) communicates with the .NET App API modules to retrieve friend and world data.
- The .NET backend, via its different implementations (CEF vs. Electron), passes data to the Electron main process.
- The Electron process initiates and then communicates with the web UI layer (built in “src”) to render data and receive user actions.
- The IPC layer facilitates communications between backend and frontend components.
- The database and file caching modules exchange data with the backend services for persisting state and configuration.

##### Important Architectural Patterns and Design Principles
- Modular Layering: Different directories indicate clear separation of concerns (API, IPC, UI, services).
- Multi-Platform/Frontend Support: The existence of both CEF and Electron components suggests that the system is designed to support multiple rendering technologies.
- Integration and Extensibility: The use of external build scripts, installer setups, and localization resources suggests that the application is built with extensibility, maintainability, and cross-platform support in mind.
- Clear Separation Between System Layers: Emphasize that the architecture splits between data gathering (backend), business logic (services, IPC), and user interface (Electron and web UI).

## Diagram (Mermaid)

```mermaid
graph TD
    %% External Systems
    subgraph "External Systems"
        VRChatAPI["VRChat API"]:::external
        DiscordIntegration["Discord Rich Presence"]:::external
        DiscordRPC["Discord RPC"]:::external
    end

    %% Backend (.NET) Layer
    subgraph "Backend (.NET)"
        API_Cef[".NET App API (Cef)"]:::backend
        API_Electron[".NET App API (Electron)"]:::backend
        CommonAPI["Common API & Shared Functionality"]:::backend

        NativeCef["Native Cef Components"]:::backend
        OverlayComponents["Overlay Components"]:::backend

        IPC["IPC Mechanism"]:::backend

        subgraph "Data Management"
            PWI["World Persistence (PWI)"]:::backend
            SQLite["SQLite Legacy"]:::backend
            Repository["Repository"]:::backend
        end

        subgraph "Service Utilities"
            LogWatcher["Log Watcher"]:::backend
            ProcessMonitor["Process Monitor"]:::backend
            UpdateService["Update Service"]:::backend
            JsonSerializer["JSON File Serializer"]:::backend
        end
    end

    %% Frontend Layer
    subgraph "Frontend"
        ElectronIntegration["Electron Integration"]:::frontend
        WebUI["Web UI / Vue Components"]:::frontend
        Localization["Localization & Theming"]:::frontend
    end

    %% Deployment/Installer
    subgraph "Deployment"
        Installer["Installer & Build Tools"]:::installer
    end

    %% Data Flow Connections
    VRChatAPI -->|"fetchData"| API_Cef
    VRChatAPI -->|"fetchData"| API_Electron
    DiscordIntegration -->|"notify"| API_Cef
    DiscordIntegration -->|"notify"| API_Electron
    DiscordIntegration --> DiscordRPC

    API_Cef -->|"render"| NativeCef
    API_Cef -->|"present"| OverlayComponents
    API_Electron --> IPC
    IPC -->|"communicate"| ElectronIntegration

    API_Cef --> CommonAPI
    API_Electron --> CommonAPI

    API_Cef -->|"persist"| PWI
    API_Electron -->|"persist"| PWI
    PWI --> SQLite
    PWI --> Repository

    API_Cef -->|"utilize"| LogWatcher
    API_Cef --> ProcessMonitor
    API_Cef --> UpdateService
    API_Cef --> JsonSerializer
    API_Electron --> LogWatcher
    API_Electron --> ProcessMonitor
    API_Electron --> UpdateService
    API_Electron --> JsonSerializer

    ElectronIntegration -->|"updateUI"| WebUI
    WebUI ---|"apply"| Localization

    Installer -->|"packages"| API_Electron
    Installer --> WebUI

    %% Styling Classes
    classDef external fill:#f9c,stroke:#333,stroke-width:2px;
    classDef backend fill:#ccf,stroke:#333,stroke-width:2px;
    classDef frontend fill:#cfc,stroke:#333,stroke-width:2px;
    classDef installer fill:#ffc,stroke:#333,stroke-width:2px;

    %% Click Events
    click API_Cef "https://github.com/vrcx-team/vrcx/tree/master/Dotnet/AppApi/Cef"
    click API_Electron "https://github.com/vrcx-team/vrcx/tree/master/Dotnet/AppApi/Electron"
    click CommonAPI "https://github.com/vrcx-team/vrcx/tree/master/Dotnet/AppApi/Common"
    click NativeCef "https://github.com/vrcx-team/vrcx/tree/master/Dotnet/Cef"
    click OverlayComponents "https://github.com/vrcx-team/vrcx/tree/master/Dotnet/Overlay"
    click IPC "https://github.com/vrcx-team/vrcx/tree/master/Dotnet/IPC"
    click PWI "https://github.com/vrcx-team/vrcx/tree/master/Dotnet/PWI"
    click SQLite "https://github.com/vrcx-team/vrcx/tree/master/Dotnet/SQLiteLegacy"
    click Repository "https://github.com/vrcx-team/vrcx/tree/master/src/repository"
    click LogWatcher "https://github.com/vrcx-team/vrcx/tree/master/Dotnet/LogWatcher"
    click ProcessMonitor "https://github.com/vrcx-team/vrcx/tree/master/Dotnet/ProcessMonitor"
    click UpdateService "https://github.com/vrcx-team/vrcx/tree/master/Dotnet/Update"
    click JsonSerializer "https://github.com/vrcx-team/vrcx/tree/master/Dotnet/JsonFileSerializer"
    click ElectronIntegration "https://github.com/vrcx-team/vrcx/tree/master/src-electron"
    click WebUI "https://github.com/vrcx-team/vrcx/tree/master/src"
    click Localization "https://github.com/vrcx-team/vrcx/tree/master/src/localization"
    click Installer "https://github.com/vrcx-team/vrcx/tree/master/Installer"
    click DiscordIntegration "https://github.com/vrcx-team/vrcx/tree/master/Dotnet/Discord"
    click DiscordRPC "https://github.com/vrcx-team/vrcx/blob/master/src/classes/discordRpc.js"
```
