# ntueelightdance/lightdance-editor architecture

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

- Interactive diagram: https://gitdiagram.com/ntueelightdance/lightdance-editor
- Repository: https://github.com/ntueelightdance/lightdance-editor

## Overview

##### Main Components
- Clients
– Web Frontend (served by editor-server)
– Blender Add-on (editor-blender)
– Command-Center App (Python CLI/GUI)
- Services
– editor-server (GraphQL + REST API, port 4000)
– file-server (static assets, port 8081)
– controller-server (RPC/WebSocket to RPis & control panels, port 8082)
- Data Stores
– MySQL (Prisma ORM)
– Redis (pub/sub for subscriptions & caching)
- External/Utility
– Docker Compose for dev/prod
– initDB & post-processing scripts (utils/)
– NTP sync, backup scripts

##### Relationships & Flows
- Web Frontend ⇄ editor-server via GraphQL HTTP
- Blender Add-on ⇄ editor-server via GraphQL/subscriptions
- editor-server ⇄ file-server for 3D/model assets
- editor-server ⇄ MySQL (Prisma) & Redis
- Controller-server ⇄ RPis & Control Panels via WebSocket
- Command-Center ⇄ controller-server via HTTP API or WebSocket
- initDB scripts write initial data into MySQL

##### Architectural Patterns
- Micro-services: three independent HTTP/WebSocket services
- CQRS & Subscriptions: editor-server uses GraphQL queries, mutations, subscriptions
- Asset Server: file-server serves heavy binary/model files separately
- Client-side extension: Blender plug-in communicates same APIs as web

##### Technologies & Frameworks
- Node.js/TypeScript (controller-server, file-server via static serve)
- Rust + Prisma (editor-server)
- Python (command-center, editor-blender)
- GraphQL (editor-server) + WebSocket
- Docker Compose for orchestration

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients
    subgraph "Clients"
        direction TB
        WF["Web Frontend"]:::client
        BA["Blender Add-on"]:::client
        CC["Command-Center App"]:::client
    end

    %% Services
    subgraph "Services"
        direction TB
        ES["editor-server\n(GraphQL & REST)\nport 4000"]:::service
        FS["file-server\n(static assets)\nport 8081"]:::service
        CS["controller-server\n(RPC & WebSocket)\nport 8082"]:::service
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        DB1[(MySQL)]:::db
        Redis[(Redis)]:::db
    end

    %% Utilities
    subgraph "Utilities & Scripts"
        direction TB
        DockerDev["Docker Compose (dev)"]:::util
        DockerProd["Docker Compose (prod)"]:::util
        initDB["initDB scripts"]:::util
        PostProc["Post-processing scripts"]:::util
        NTP["NTP sync scripts"]:::util
        Backup["Backup scripts"]:::util
    end

    %% External Hardware
    Hardware["RPis & Control Panels"]:::external

    %% Connections
    WF -->|"HTTP GraphQL"| ES
    BA <-->|"GraphQL Subscriptions\n(WebSocket)"| ES
    ES -->|"HTTP asset fetch"| FS
    ES -->|"Prisma ORM"| DB1
    ES -.->|"Redis pub/sub"| Redis
    CC -->|"HTTP API / WebSocket"| CS
    CS -->|"WebSocket"| Hardware
    initDB -->|"writes initial data"| DB1
    DockerDev --> ES
    DockerDev --> FS
    DockerDev --> CS
    DockerProd --> ES
    DockerProd --> FS
    DockerProd --> CS

    %% Click Events
    click WF "https://github.com/ntueelightdance/lightdance-editor/tree/main/editor-server/src/routes/"
    click BA "https://github.com/ntueelightdance/lightdance-editor/tree/main/editor-blender/"
    click CC "https://github.com/ntueelightdance/lightdance-editor/tree/main/command-center/"
    click ES "https://github.com/ntueelightdance/lightdance-editor/tree/main/editor-server/"
    click FS "https://github.com/ntueelightdance/lightdance-editor/tree/main/file-server/"
    click CS "https://github.com/ntueelightdance/lightdance-editor/tree/main/controller-server/"
    click DB1 "https://github.com/ntueelightdance/lightdance-editor/blob/main/editor-server/prisma/schema.prisma"
    click Redis "https://github.com/ntueelightdance/lightdance-editor/blob/main/editor-server/src/global/clients.rs"
    click DockerDev "https://github.com/ntueelightdance/lightdance-editor/blob/main/dev.docker-compose.yml"
    click DockerProd "https://github.com/ntueelightdance/lightdance-editor/blob/main/prod-support/prod.docker-compose.yml"
    click initDB "https://github.com/ntueelightdance/lightdance-editor/blob/main/utils/initDB.js"
    click PostProc "https://github.com/ntueelightdance/lightdance-editor/tree/main/utils/post_processing/"
    click NTP "https://github.com/ntueelightdance/lightdance-editor/tree/main/controller-server/ntp/"
    click Backup "https://github.com/ntueelightdance/lightdance-editor/tree/main/scripts/backup/"

    %% Styles
    classDef client fill:#D0E6FF,stroke:#666,stroke-width:1px
    classDef service fill:#D4FCDC,stroke:#666,stroke-width:1px
    classDef db fill:#FFE6A7,stroke:#666,stroke-width:1px
    classDef util fill:#E2E2E2,stroke:#666,stroke-width:1px
    classDef external fill:#F0D0FF,stroke:#666,stroke-width:1px
```
