# yuming0929/desk architecture

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

- Interactive diagram: https://gitdiagram.com/yuming0929/desk
- Repository: https://github.com/yuming0929/desk

## Overview

##### Project type and purpose
- This is a single-page, full-stack-style (client-only) React application delivered as static assets.
- Purpose: let end users customize a 3D desk model in real time via a web UI, powered by Three.js (inside React).

##### File structure
- Top-level files:
– index.html + public/ → static HTML/CSS + 3D assets (desk.glb, textures)
– vite.config.js → build & dev server config
– package.json → dependencies (React, Three.js, state library, etc.)
- src/: contains React entry point (main.jsx), styles (App.css, index.css), components, asset folder, and state stores.
- src/components/:
– Experience.jsx → Three.js canvas setup, scene & renderer
– Desk.jsx → loads the GLTF model + applies textures/materials
- src/stores/: configStore.js, detail.js → centralized state (likely Zustand or similar).

##### README
- Confirms it’s a “3d桌子选配器” with a deployed demo (Netlify).
- No server-side/microservices—purely static front-end.

##### Main components
a. Client Browser (User’s device)
b. Web Server/CDN (Netlify or any static host)
c. React Application:
1) UI Layer (Configurator component + standard React tree)
2) State Management Layer (configStore, detailStore)
3) 3D Rendering Layer (Experience, Desk components using Three.js)
d. Static Asset Store (public/models/desk.glb, public/textures)
f. External Services – analytics or hosting, if any

##### Relationships & interactions
- Client requests index.html + JS/CSS from CDN.
- React App boots (main.jsx → App.jsx).
- Configurator (UI) dispatches actions → State Store.
- Experience subscribes to State Store updates → re-renders Desk.
- Desk component uses GLTFLoader to fetch .glb + textures from the public folder.
- Three.js WebGL context renders the scene back to the browser canvas.

##### Architectural patterns & design principles
- Component-based UI (React JSX components)
- Unidirectional data flow (Configurator → Store → Experience → UI update)
- Separation of concerns: UI / State / Rendering
- Static asset hosting for 3D models and textures

##### Essential details to capture
- Labels: name each component (e.g., “Configurator (React)”, “configStore (Zustand)”)

##### Putting it all together
- Related components with lightly shaded containers.

## Diagram (Mermaid)

```mermaid
flowchart TB
    classDef infra fill:#ADD8E6,stroke:#000;
    classDef app fill:#90EE90,stroke:#000;
    classDef external fill:#FFA500,stroke:#000;

    subgraph "Infrastructure"
        Infra_CDN["Web CDN / Netlify"]:::infra
        Infra_Model["public/models/desk.glb"]:::infra
        Infra_Textures["public/textures/"]:::infra
        IndexHTML["index.html"]:::infra
    end

    Browser["Client Browser"]:::app

    Infra_CDN -->|"serve index.html, bundle.js"| Browser
    Infra_CDN -->|"serve static assets"| IndexHTML
    Infra_Model -->|"HTTP GET loadModel()"| Desk
    Infra_Textures -->|"HTTP GET loadTextures()"| Desk

    Browser -->|"load bundle.js"| Main

    subgraph "React Application"
        subgraph "App Root"
            Main["main.jsx"]:::app
            App["App.jsx"]:::app
        end
        subgraph "UI Layer"
            Configurator["Configurator.jsx"]:::app
        end
        subgraph "State Layer"
            ConfigStore["configStore.js"]:::app
            DetailStore["detail.js"]:::app
        end
        subgraph "Rendering Layer"
            Experience["Experience.jsx"]:::app
            Desk["Desk.jsx"]:::app
        end
    end

    Browser -->|"mount React App"| Main
    Main -->|"render App"| App
    App -->|"mount UI components"| Configurator
    Configurator -->|"dispatch updateConfig()"| ConfigStore
    Configurator -->|"dispatch updateDetail()"| DetailStore
    ConfigStore -->|"state update"| Experience
    DetailStore -->|"state update"| Experience
    Experience -->|"add Desk to scene"| Desk
    Experience -->|"render()"| Canvas

    Canvas["WebGL Canvas"]:::app

    subgraph "Build & Config"
        Vite["vite.config.js"]:::external
        Package["package.json"]:::external
        Styles1["src/index.css"]:::app
        Styles2["src/App.css"]:::app
    end

    %% Click Events
    click Configurator "https://github.com/yuming0929/desk/blob/main/src/components/Configurator.jsx"
    click Experience "https://github.com/yuming0929/desk/blob/main/src/components/Experience.jsx"
    click Desk "https://github.com/yuming0929/desk/blob/main/src/components/Desk.jsx"
    click Main "https://github.com/yuming0929/desk/blob/main/src/main.jsx"
    click App "https://github.com/yuming0929/desk/blob/main/src/App.jsx"
    click ConfigStore "https://github.com/yuming0929/desk/blob/main/src/stores/configStore.js"
    click DetailStore "https://github.com/yuming0929/desk/blob/main/src/stores/detail.js"
    click IndexHTML "https://github.com/yuming0929/desk/blob/main/index.html"
    click Infra_Model "https://github.com/yuming0929/desk/blob/main/public/models/desk.glb"
    click Infra_Textures "https://github.com/yuming0929/desk/tree/main/public/textures/"
    click Vite "https://github.com/yuming0929/desk/blob/main/vite.config.js"
    click Styles1 "https://github.com/yuming0929/desk/blob/main/src/index.css"
    click Styles2 "https://github.com/yuming0929/desk/blob/main/src/App.css"
    click Package "https://github.com/yuming0929/desk/blob/main/package.json"
```
