# videosdk-live/videosdk-rtc-unity-sdk-example architecture

> Architecture diagram of the GitHub repository videosdk-live/videosdk-rtc-unity-sdk-example, 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/videosdk-live/videosdk-rtc-unity-sdk-example
- Repository: https://github.com/videosdk-live/videosdk-rtc-unity-sdk-example

## Overview

##### Main Components
- Unity Engine as the core runtime environment.
- Assets Folder: Contains several critical sub-components:
- Scenes (e.g., SampleScene.unity) – where the video conferencing UI and simulation take place.
- Scripts (e.g., GameManager.cs, meeting and callback implementation scripts) – handle meeting management, UI interactions, and integration logic.
- Plugins: Contains platform-specific configurations (Android Gradle templates, iOS integration hooks) as well as potential third-party code.
- Prefabs (e.g., Participant.prefab) – pre-built game objects for participants or UI elements.
- Utility scripts (including those in CrystalFramework/Utility) – containing helper methods or demos (like the SafeAreaDemo) which might be used to manage UI layout.
- Additional modules like Unity-Logs-Viewer (logging/reporting utility) to capture runtime messages.

##### External Dependencies & Integration Layers
- VideoSDK Package: Installed via a Git URL; it provides core functionality (Meeting object creation, join, participant callbacks, video streaming) for video conferencing.
- Android and iOS build configurations: Gradle templates for Android and instructions for linking iOS frameworks. These elements indicate separate build pipeline layers.
- Newtonsoft-json: Managed via Unity's Package Manager for JSON serialization support.

##### Relationships and Interactions
- The Meeting Manager/Sdk Initialization layer (via a singleton or static GetMeetingObject() call) initializes the VideoSDK and exposes methods for creating and joining meetings.
- UI Components (such as GameObjects with VideoSurface script, RawImage for video rendering, or custom prefabs) interact with the Meeting Manager. They receive callbacks on participant events and utilize VideoSurface to render video frames.
- Participant Management: Scripts capture callbacks when participants join or leave and then update the UI accordingly. The meeting object’s event handlers funnel these events.
- Build and Platform Integration: The Plugins and ProjectSettings directories provide hooks for integrating external SDK dependencies (Android/iOS SDKs). They ensure that the VideoSDK is properly linked during the build phase.

##### Architectural Patterns/Design Principles
- Separation of Concerns: UI (scenes and prefabs) is clearly separated from business logic (meeting management, callback handling).
- Modular Integration: The VideoSDK is integrated as a package and uses clear API methods (CreateMeetingId, Join, SetParticipant, etc.) – this modularity allows for replacing or updating the SDK with minimal changes to the UI.
- Event-Driven Communication: The design uses callbacks (for meeting creation, participant join/leave, stream enabling/disabling) to update the visual components in real time, emphasizing an event-driven architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Unity Engine Core (Runtime)
    subgraph "Unity Engine Core (Runtime)"
        %% UI Layer
        subgraph "UI Layer"
            A["Sample Scene"]:::ui
            B["Participant UI"]:::ui
        end
        %% SDK Integration Layer
        subgraph "SDK Integration"
            C["Meeting Manager (GameManager.cs)"]:::integration
            D["VideoSurface Component"]:::integration
            E["VideoSDK Package"]:::external
        end
        %% Utility & Logging
        subgraph "Utility & Logging"
            F["Utility Scripts"]:::utility
            F2["Utility Demos"]:::utility
            G["Unity Logs Viewer"]:::utility
        end
    end

    %% Platform-specific Build Configurations
    subgraph "Platform-specific Build Config"
        H["Android Build Config"]:::platform
        I["iOS Build Config"]:::platform
    end

    %% Relationships
    A -->|"UIinteractions"| C
    C -->|"Callbacks:Join_Leave"| B
    C -->|"Controls"| D
    C -->|"UsesSDK"| E
    F -->|"Helpers"| A
    F -->|"SupportsUI"| B
    G -->|"LogsEvents"| C
    H -->|"Configures"| C
    H -->|"Configures"| A
    I -->|"Configures"| C

    %% Styles
    classDef ui fill:#ffcccb,stroke:#333,stroke-width:2px;
    classDef integration fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef external fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef platform fill:#ffe4b5,stroke:#333,stroke-width:2px;
    classDef utility fill:#d3d3d3,stroke:#333,stroke-width:2px;

    %% Click Events
    click A "https://github.com/videosdk-live/videosdk-rtc-unity-sdk-example/blob/main/Unity-VideoSdk-Example/Assets/Scenes/SampleScene.unity"
    click C "https://github.com/videosdk-live/videosdk-rtc-unity-sdk-example/blob/main/Unity-VideoSdk-Example/Assets/Scripts/GameManager.cs"
    click H "https://github.com/videosdk-live/videosdk-rtc-unity-sdk-example/tree/main/Unity-VideoSdk-Example/Assets/Plugins/Android"
    click B "https://github.com/videosdk-live/videosdk-rtc-unity-sdk-example/blob/main/Unity-VideoSdk-Example/Assets/Prefabs/Participant.prefab"
    click F "https://github.com/videosdk-live/videosdk-rtc-unity-sdk-example/tree/main/Unity-VideoSdk-Example/Assets/CrystalFramework/Utility"
    click F2 "https://github.com/videosdk-live/videosdk-rtc-unity-sdk-example/tree/main/Unity-VideoSdk-Example/Assets/CrystalFramework/Utility/Demos"
    click G "https://github.com/videosdk-live/videosdk-rtc-unity-sdk-example/tree/main/Unity-VideoSdk-Example/Assets/Unity-Logs-Viewer"
```
