# odedindi/angrymobremote-webrtc-example architecture

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

- Interactive diagram: https://gitdiagram.com/odedindi/angrymobremote-webrtc-example
- Repository: https://github.com/odedindi/angrymobremote-webrtc-example

## Overview

##### Main Components

A. Client-Side Application Structure:
- React Application Layer
- WebGL Rendering Engine
- WebRTC Communication Layer
- Device Metrics Handler
- Asset Management System

B. External Services/Dependencies:
- WebRTC Signaling Server (for initial peer matching)
- Asset Delivery (static files)

**┌─ Client Application ─────────────────────────────────────┐**

- ┌─ UI Layer ─────────┐    ┌─ Core Services ────────┐  │
- React Components │    │ - Context Providers    │  │
- LCARS UI        │    │ - Device Metrics       │  │
- Cyber UI        │    │ - WebRTC Handler       │  │
- ┬┘    └─────────┬─────────────┘  │

- ┌─ 3D Engine ──────┴──────────────┴───────────┐     │
- Scene Management                          │     │
- Asset Loading                             │     │
- WebGL Rendering                           │     │
- Camera Control                            │     │
- ┬┘     │

- ┌─ Asset System ────────────────────────────┬┘       │
- 3D Models (.gltf, .obj, .fbx)          │        │
- Textures                               │        │
- Materials                              │        │
- ┘       │
- ┘

##### Key Relationships to Highlight

a. Data Flow:
- Device metrics → WebRTC → Peer devices
- 3D engine ← Asset system
- UI layer ↔ Core services

b. Component Dependencies:
- Scene management depending on asset loading
- Camera control depending on device metrics
- UI updates based on connection status

##### Implementation Details

- File structure organization (/src, /public, /mesh)
- Key technology implementations (Three.js/WebGL, WebRTC)
- Asset pipeline for 3D models and textures
- Real-time communication paths

##### The device orientation to camera control mechanism

Keep the abstraction level focused on the major systems while providing enough detail to understand the unique aspects of this WebGL/WebRTC implementation.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Application"]
        subgraph UILayer["UI Layer"]
            ReactComponents["React Components"]:::ui
            LCARSUI["LCARS UI"]:::ui
            CyberUI["Cyber UI"]:::ui
        end

        subgraph CoreServices["Core Services"]
            ContextProviders["Context Providers"]:::service
            DeviceMetrics["Device Metrics"]:::service
            WebRTCHandler["WebRTC Handler"]:::service
        end

        subgraph Engine["3D Engine"]
            SceneManagement["Scene Management"]:::engine
            AssetLoading["Asset Loading"]:::engine
            WebGLRendering["WebGL Rendering"]:::engine
            CameraControl["Camera Control"]:::engine
        end

        subgraph AssetSystem["Asset System"]
            Models["3D Models"]:::asset
            Textures["Textures"]:::asset
            Materials["Materials"]:::asset
        end
    end

    ExternalSignaling["WebRTC Signaling Server"]:::external
    StaticAssets["Static Asset Delivery"]:::external

    %% Relationships
    ReactComponents --> ContextProviders
    LCARSUI --> ReactComponents
    CyberUI --> ReactComponents
    
    DeviceMetrics --> CameraControl
    WebRTCHandler --> ExternalSignaling
    
    SceneManagement --> AssetLoading
    AssetLoading --> Models
    AssetLoading --> Textures
    AssetLoading --> Materials
    
    WebGLRendering --> SceneManagement
    CameraControl --> WebGLRendering
    
    StaticAssets --> AssetSystem

    %% Click Events
    click ReactComponents "https://github.com/odedindi/AngryMobRemote-Webrtc-example/blob/master/src/App.js"
    click ContextProviders "https://github.com/odedindi/AngryMobRemote-Webrtc-example/tree/master/src/contexts"
    click LCARSUI "https://github.com/odedindi/AngryMobRemote-Webrtc-example/blob/master/src/dumb/LcarsHeader.jsx"
    click CyberUI "https://github.com/odedindi/AngryMobRemote-Webrtc-example/blob/master/src/dumb/CyberPunkModal.jsx"
    click DeviceMetrics "https://github.com/odedindi/AngryMobRemote-Webrtc-example/blob/master/src/contexts/DeviceMetricsContext.jsx"
    click WebRTCHandler "https://github.com/odedindi/AngryMobRemote-Webrtc-example/blob/master/src/contexts/RTCContext.jsx"
    click SceneManagement "https://github.com/odedindi/AngryMobRemote-Webrtc-example/blob/master/src/modules/3d/SceneBase.js"
    click WebGLRendering "https://github.com/odedindi/AngryMobRemote-Webrtc-example/blob/master/src/modules/3d/TextureRenderer.js"
    click CameraControl "https://github.com/odedindi/AngryMobRemote-Webrtc-example/blob/master/src/modules/DeviceCameraTools.js"
    click AssetLoading "https://github.com/odedindi/AngryMobRemote-Webrtc-example/blob/master/src/modules/3d/AssetLoaders.js"
    click Models "https://github.com/odedindi/AngryMobRemote-Webrtc-example/tree/master/public/mesh"
    click Textures "https://github.com/odedindi/AngryMobRemote-Webrtc-example/tree/master/public/textures"

    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef service fill:#9b59b6,stroke:#8e44ad,color:white
    classDef engine fill:#2ecc71,stroke:#27ae60,color:white
    classDef asset fill:#e67e22,stroke:#d35400,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        UI["UI Component"]:::ui
        Service["Core Service"]:::service
        EngineComponent["Engine Component"]:::engine
        AssetComponent["Asset Component"]:::asset
        ExternalService["External Service"]:::external
    end
```
