# cran1ax/virtual-3d-office architecture

> Architecture diagram of the GitHub repository cran1ax/virtual-3d-office, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cran1ax/virtual-3d-office
- Repository: https://github.com/cran1ax/virtual-3d-office

## Overview

##### Project Type and Purpose
- This is a full-stack, real-time, web-based 3D “metaverse” or collaborative environment.
- The client (under `/client`) is a Vite-powered React app that loads 3D models/animations (GLB files) and renders them with Three.js.
- The server (under `/server`) is a Node.js application (likely using Express + Socket.io) that handles WebSocket signaling for state sync (avatars, lobby, shop, tasks) and voice-call signaling (WebRTC).

##### File Structure
A. Top-Level
– `/client` → Frontend source, assets, configs (Vite, Tailwind, PostCSS).
– `/server` → Backend code, config files (`default.json`, `.env`), restart script.
– `README.md` at root only points to a video tutorial.
B. Frontend Details
– `client/src` houses React components (Avatar, Room, Lobby, VoiceCall, TaskManager, etc.).
– `client/public/models`, `/textures`, `/animations` store static GLB and HDR assets.
– `SocketManager.jsx` and hooks handle real-time events.
C. Backend Details
– `server/index.js` presumably spins up HTTP + WebSocket servers.
– `server/default.json` and `.env` define ports, credentials.
– `restart.js` may auto-restart the server on config or file changes.

##### README for Insights
- The README contains only a link to a tutorial video—no explicit architecture docs.

##### Elements
- HTTP GET (asset bundles, models)
- WebSocket connect/send/receive
- WebRTC signaling & media streams
- Frontend components (e.g., green)
- Backend components (e.g., blue)
- External services (e.g., orange)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client (Browser)"
        direction TB
        CE["Entry Point<br/>(main.jsx)"]:::frontend
        AS["App Shell<br/>(App.jsx)"]:::frontend
        EXP["3D Renderer & Scene Setup<br/>(Experience.jsx)"]:::frontend
        subgraph "UI Layer"
            direction TB
            AV["Avatar Component<br/>(Avatar.jsx)"]:::frontend
            LB["Lobby Component<br/>(Lobby.jsx)"]:::frontend
            SH["Shop Component<br/>(Shop.jsx)"]:::frontend
            TM["Task Manager<br/>(TaskManager.jsx)"]:::frontend
            TA["TodoApp Component<br/>(TodoApp.jsx)"]:::frontend
            VC["VoiceCall Interface<br/>(VoiceCall.jsx)"]:::frontend
            RM["Room Visualization<br/>(Room.jsx)"]:::frontend
            MO["Monitor Component<br/>(Monitor.jsx)"]:::frontend
            TB["Tablet Component<br/>(Tablet.jsx)"]:::frontend
            SK["Skyscraper Component<br/>(Skyscraper.jsx)"]:::frontend
        end
        NM["SocketManager<br/>(SocketManager.jsx)"]:::frontend
        subgraph "Hooks & Utils"
            direction TB
            HG["useGrid Hook<br/>(useGrid.jsx)"]:::frontend
            PD["Proximity Detection<br/>(proximityDetection.js)"]:::frontend
        end
        subgraph "Static Assets"
            direction TB
            MD["3D Models<br/>(public/models/)"]:::frontend
            AN["Animations<br/>(public/animations/)"]:::frontend
            TX["HDR Textures<br/>(public/textures/)"]:::frontend
        end
        subgraph "Frontend Config"
            direction TB
            VC1["Vite Config<br/>(vite.config.js)"]:::frontend
            TC["Tailwind Config<br/>(tailwind.config.js)"]:::frontend
            PC["PostCSS Config<br/>(postcss.config.js)"]:::frontend
        end

        CE -->|Loads| AS
        AS -->|Initializes| EXP
        AS -->|Renders UI| AV & LB & SH & TM & TA & VC & RM & MO & TB & SK
        EXP -->|Loads Assets via HTTP GET| MD & AN & TX
        EXP -->|Uses| HG & PD
        AV & LB & SH & TM & TA & VC & RM & MO & TB & SK -->|Network Events| NM
        NM -->|WS Signaling| SERVER_WS
    end

    %% Server Side
    subgraph "Server (Node.js)"
        direction TB
        IDX["Server Entry<br/>(index.js)"]:::backend
        CFG["Config Files<br/>(default.json & .env)"]:::backend
        PKG["Dependencies & Scripts<br/>(package.json & restart.js)"]:::backend
        SERVER_WS["WebSocket Server<br/>(Socket.io)"]:::backend
        HTTP["HTTP Server"]:::backend
    end

    %% External Services
    subgraph "External Services"
        direction TB
        ST["STUN/TURN Servers"]:::external
        CDN["CDN / Static Host"]:::external
    end

    %% Connections
    CE -->|HTTP GET Bundles| HTTP
    HTTP -->|Serves Assets| CE
    SERVER_WS -->|Broadcasts State| NM
    SERVER_WS -->|Signaling| ST
    EXP -->|Fetch from CDN| CDN

    %% Click Events
    click CE "https://github.com/cran1ax/virtual-3d-office/blob/main/client/src/main.jsx"
    click AS "https://github.com/cran1ax/virtual-3d-office/blob/main/client/src/App.jsx"
    click EXP "https://github.com/cran1ax/virtual-3d-office/blob/main/client/src/components/Experience.jsx"
    click AV "https://github.com/cran1ax/virtual-3d-office/blob/main/client/src/components/Avatar.jsx"
    click LB "https://github.com/cran1ax/virtual-3d-office/blob/main/client/src/components/Lobby.jsx"
    click SH "https://github.com/cran1ax/virtual-3d-office/blob/main/client/src/components/Shop.jsx"
    click TM "https://github.com/cran1ax/virtual-3d-office/blob/main/client/src/components/TaskManager.jsx"
    click TA "https://github.com/cran1ax/virtual-3d-office/blob/main/client/src/components/TodoApp.jsx"
    click VC "https://github.com/cran1ax/virtual-3d-office/blob/main/client/src/components/VoiceCall.jsx"
    click RM "https://github.com/cran1ax/virtual-3d-office/blob/main/client/src/components/Room.jsx"
    click MO "https://github.com/cran1ax/virtual-3d-office/blob/main/client/src/components/Monitor.jsx"
    click TB "https://github.com/cran1ax/virtual-3d-office/blob/main/client/src/components/Tablet.jsx"
    click SK "https://github.com/cran1ax/virtual-3d-office/blob/main/client/src/components/Skyscraper.jsx"
    click NM "https://github.com/cran1ax/virtual-3d-office/blob/main/client/src/components/SocketManager.jsx"
    click HG "https://github.com/cran1ax/virtual-3d-office/blob/main/client/src/hooks/useGrid.jsx"
    click PD "https://github.com/cran1ax/virtual-3d-office/blob/main/client/src/utils/proximityDetection.js"
    click MD "https://github.com/cran1ax/virtual-3d-office/tree/main/client/public/models/"
    click AN "https://github.com/cran1ax/virtual-3d-office/tree/main/client/public/animations/"
    click TX "https://github.com/cran1ax/virtual-3d-office/tree/main/client/public/textures/"
    click VC1 "https://github.com/cran1ax/virtual-3d-office/blob/main/client/vite.config.js"
    click TC "https://github.com/cran1ax/virtual-3d-office/blob/main/client/tailwind.config.js"
    click PC "https://github.com/cran1ax/virtual-3d-office/blob/main/client/postcss.config.js"
    click IDX "https://github.com/cran1ax/virtual-3d-office/blob/main/server/index.js"
    click CFG "https://github.com/cran1ax/virtual-3d-office/blob/main/server/default.json"
    click CFG "https://github.com/cran1ax/virtual-3d-office/blob/main/server/.env"
    click PKG "https://github.com/cran1ax/virtual-3d-office/blob/main/server/package.json"
    click PKG "https://github.com/cran1ax/virtual-3d-office/blob/main/server/restart.js"

    %% Styles
    classDef frontend fill:#e0ffe0,stroke:#00a000,stroke-width:1px
    classDef backend fill:#e0f0ff,stroke:#0060a0,stroke-width:1px
    classDef external fill:#fff4e6,stroke:#d97706,stroke-width:1px
```
