# xiangechen/chili3d architecture

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

- Interactive diagram: https://gitdiagram.com/xiangechen/chili3d
- Repository: https://github.com/xiangechen/chili3d

## Overview

##### Main System Components

A. Frontend Layer (UI/Presentation)
- `chili-ui` package with components like:
- Ribbon interface
- Property panels
- Viewport
- Project tree
- Status bar
- Dialog system

B. Core Application Layer
- Center around `chili-core` package showing:
- Application management
- Document handling
- Command system
- Selection management
- Property system
- Event handling

C. Geometry Processing Layer
- Feature the `chili-wasm` package interfacing with OpenCascade:
- Geometric operations
- Meshing capabilities

D. Rendering Layer
- `chili-three` package showing:
- Three.js integration
- Visual representation
- Camera control
- Scene management

##### Key Relationships to Highlight

**UI Layer → Core Layer: User commands, events**
**Geometry Layer → Rendering Layer: Mesh data**
**Rendering Layer → UI Layer: Visual feedback**

##### Important Subsystems to Detail

A. Command System (`chili/src/commands`)
- Command hierarchy
- Command execution flow
- Undo/Redo system

B. Snap System (`chili/src/snap`)
- Snap handlers
- Tracking system
- Point/angle/length snapping

C. Data Management
- Document structure
- Node hierarchy

##### External Dependencies

- OpenCascade (via WebAssembly)
- Three.js
- Browser storage (IndexedDB)
- File system (import/export)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef geometry fill:#e67e22,stroke:#d35400,color:white
    classDef rendering fill:#9b59b6,stroke:#8e44ad,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white
    
    %% Frontend Layer
    subgraph Frontend
        UI_Ribbon["Ribbon Interface"]:::ui
        UI_Property["Property Panels"]:::ui
        UI_Viewport["Viewport"]:::ui
        UI_Project["Project Tree"]:::ui
        UI_Status["Status Bar"]:::ui
        UI_Dialog["Dialog System"]:::ui
    end
    
    %% Core Layer
    subgraph Core
        App["Application Manager"]:::core
        Doc["Document Handler"]:::core
        Cmd["Command System"]:::core
        Select["Selection Manager"]:::core
        Prop["Property System"]:::core
        Event["Event Handler"]:::core
        I18N["i18n System"]:::core
    end
    
    %% Geometry Layer
    subgraph Geometry
        Shape["Shape Operations"]:::geometry
        Geom["Geometric Processing"]:::geometry
        Mesh["Meshing System"]:::geometry
        Factory["Shape Factory"]:::geometry
    end
    
    %% Rendering Layer
    subgraph Rendering
        ThreeView["Three.js View"]:::rendering
        Visual["Visual System"]:::rendering
        Camera["Camera Controller"]:::rendering
        Scene["Scene Manager"]:::rendering
    end
    
    %% External Dependencies
    OpenCascade["OpenCascade WASM"]:::external
    ThreeJS["Three.js"]:::external
    IndexedDB["Browser Storage"]:::external
    FileSystem["File System"]:::external
    
    %% Relationships
    Frontend --> Core
    Core --> Geometry
    Geometry --> Rendering
    Rendering --> Frontend
    
    Geometry --> OpenCascade
    Rendering --> ThreeJS
    Core --> IndexedDB
    Core --> FileSystem
    
    %% Click Events
    click UI_Ribbon "https://github.com/xiangechen/chili3d/tree/main/packages/chili-ui/src/ribbon"
    click UI_Property "https://github.com/xiangechen/chili3d/tree/main/packages/chili-ui/src/property"
    click UI_Viewport "https://github.com/xiangechen/chili3d/tree/main/packages/chili-ui/src/viewport"
    click UI_Project "https://github.com/xiangechen/chili3d/tree/main/packages/chili-ui/src/project"
    click UI_Status "https://github.com/xiangechen/chili3d/tree/main/packages/chili-ui/src/statusbar"
    
    click App "https://github.com/xiangechen/chili3d/blob/main/packages/chili-core/src/application.ts"
    click Doc "https://github.com/xiangechen/chili3d/blob/main/packages/chili-core/src/document.ts"
    click Cmd "https://github.com/xiangechen/chili3d/tree/main/packages/chili-core/src/command"
    click Select "https://github.com/xiangechen/chili3d/blob/main/packages/chili-core/src/selection.ts"
    click Prop "https://github.com/xiangechen/chili3d/blob/main/packages/chili-core/src/property.ts"
    click Event "https://github.com/xiangechen/chili3d/blob/main/packages/chili-core/src/visual/eventHandler.ts"
    click I18N "https://github.com/xiangechen/chili3d/tree/main/packages/chili-core/src/i18n"
    
    click Shape "https://github.com/xiangechen/chili3d/blob/main/packages/chili-wasm/src/shape.ts"
    click Geom "https://github.com/xiangechen/chili3d/blob/main/packages/chili-wasm/src/geometry.ts"
    click Mesh "https://github.com/xiangechen/chili3d/blob/main/packages/chili-wasm/src/mesher.ts"
    click Factory "https://github.com/xiangechen/chili3d/blob/main/packages/chili-wasm/src/factory.ts"
    
    click ThreeView "https://github.com/xiangechen/chili3d/blob/main/packages/chili-three/src/threeView.ts"
    click Visual "https://github.com/xiangechen/chili3d/blob/main/packages/chili-three/src/threeVisual.ts"
    click Camera "https://github.com/xiangechen/chili3d/blob/main/packages/chili-three/src/cameraController.ts"
    click Scene "https://github.com/xiangechen/chili3d/blob/main/packages/chili-three/src/threeRenderBuilder.ts"
    
    click IndexedDB "https://github.com/xiangechen/chili3d/blob/main/packages/chili-storage/src/indexedDBStorage.ts"
```
