# aalavandhaann/blueprint-js architecture

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

- Interactive diagram: https://gitdiagram.com/aalavandhaann/blueprint-js
- Repository: https://github.com/aalavandhaann/blueprint-js

## Overview

##### Main Components Overview

a) Core Application Layer
- Main Blueprint.js controller
- To Model, 2D Viewer, and 3D Viewer components

b) Model Layer (Left Side)
- Core data models: Floorplan, Room, Wall, Corner
- Relationship to Items management
- To data persistence/serialization

c) View Layers (Right Side)
Split into two main sections:
- 2D Viewer (Pixi.js based)
- 3D Viewer (Three.js based)

##### Component Relationships

a) Data Flow
- Model → 2D Viewer (Floor plan rendering)
- Model → 3D Viewer (3D scene rendering)
- User Input → Controllers → Model (bidirectional)

b) Asset Management
- Texture management system
- Model loading pipeline (GLTF/OBJ)
- Material system

##### Specific Implementation Details

- 🟦 Blue: Core components
- 🟩 Green: View components
- 🟨 Yellow: Model components
- 🟥 Red: External dependencies

##### Technical Stack Indicators

Technology badges:
- Three.js for 3D rendering
- Pixi.js for 2D rendering
- GSAP for animations
- Parcel for bundling

##### Architectural Patterns

MVC pattern implementation:
- Models: /src/scripts/model/
- Views: /src/scripts/viewer2d/ and /src/scripts/viewer3d/
- Controllers: Various helper classes

##### Key Features to Highlight

Create subsystems for:
- Parametric object generation
- Material management
- Room planning
- Item placement
- VR export capability

##### External Integrations

Connections to:
- Texture loading system
- 3D model import/export
- VR visualization
- Environment mapping

##### The event-driven architecture using Three.js event dispatcher

This will provide a clear understanding of how the application's components interact while maintaining the appropriate level of abstraction for a principal software engineer to understand the system's architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core
        Blueprint["Blueprint Controller"]:::core
        Config["Configuration"]:::core
        Utils["Core Utils"]:::core
    end

    subgraph ModelLayer["Model Layer"]
        Floorplan["Floorplan"]:::model
        Room["Room"]:::model
        Wall["Wall"]:::model
        Corner["Corner"]:::model
        
        subgraph Items["Item Management"]
            ItemFactory["Item Factory"]:::model
            BaseItem["Base Item"]:::model
            WallItems["Wall Items"]:::model
            FloorItems["Floor Items"]:::model
        end
    end

    subgraph ViewLayer["View Layer"]
        subgraph 2DViewer["2D Viewer (Pixi.js)"]
            RoomView2D["Room View 2D"]:::view
        end

        subgraph 3DViewer["3D Viewer (Three.js)"]
            Floor3D["3D Floor"]:::view
        end
    end

    subgraph AssetManagement["Asset Management"]
        subgraph Materials["Materials System"]
            FloorMaterial["Floor Material"]:::asset
            WallMaterial["Wall Material"]:::asset
        end
        
        subgraph Parametric["Parametric Generation"]
            DoorFactory["Door Factory"]:::asset
            DoorTypes["Door Types"]:::asset
            HandleGen["Handle Generator"]:::asset
        end
    end

    Blueprint --> ModelLayer
    Blueprint --> ViewLayer
    ModelLayer --> 2DViewer
    ModelLayer --> 3DViewer
    AssetManagement --> 3DViewer
    Items --> ModelLayer

    %% Click events for component mapping
    click Blueprint "https://github.com/aalavandhaann/blueprint-js/blob/master/src/scripts/blueprint.js"
    click Config "https://github.com/aalavandhaann/blueprint-js/blob/master/src/scripts/core/configuration.js"
    click Utils "https://github.com/aalavandhaann/blueprint-js/blob/master/src/scripts/core/utils.js"
    click Floorplan "https://github.com/aalavandhaann/blueprint-js/blob/master/src/scripts/model/floorplan.js"
    click Room "https://github.com/aalavandhaann/blueprint-js/blob/master/src/scripts/model/room.js"
    click Wall "https://github.com/aalavandhaann/blueprint-js/blob/master/src/scripts/model/wall.js"
    click Corner "https://github.com/aalavandhaann/blueprint-js/blob/master/src/scripts/model/corner.js"
    click RoomView2D "https://github.com/aalavandhaann/blueprint-js/blob/master/src/scripts/viewer2d/RoomView2D.js"
    click Floor3D "https://github.com/aalavandhaann/blueprint-js/blob/master/src/scripts/viewer3d/floor3d.js"
    click FloorMaterial "https://github.com/aalavandhaann/blueprint-js/blob/master/src/scripts/materials/FloorMaterial3D.js"
    click WallMaterial "https://github.com/aalavandhaann/blueprint-js/blob/master/src/scripts/materials/WallMaterial3D.js"
    click DoorFactory "https://github.com/aalavandhaann/blueprint-js/blob/master/src/scripts/parametrics/doors/DoorFactory.js"
    click DoorTypes "https://github.com/aalavandhaann/blueprint-js/tree/master/src/scripts/parametrics/doors"
    click HandleGen "https://github.com/aalavandhaann/blueprint-js/blob/master/src/scripts/parametrics/doors/doorhandles/DoorHandleGenerator.js"
    click ItemFactory "https://github.com/aalavandhaann/blueprint-js/blob/master/src/scripts/items/factory.js"
    click BaseItem "https://github.com/aalavandhaann/blueprint-js/blob/master/src/scripts/items/item.js"
    click WallItems "https://github.com/aalavandhaann/blueprint-js/blob/master/src/scripts/items/wall_item.js"
    click FloorItems "https://github.com/aalavandhaann/blueprint-js/blob/master/src/scripts/items/floor_item.js"

    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef model fill:#FFC107,stroke:#FFA000,color:black
    classDef view fill:#4CAF50,stroke:#388E3C,color:white
    classDef asset fill:#F44336,stroke:#D32F2F,color:white

    %% Legend
    subgraph Legend
        CoreLegend["Core Components"]:::core
        ModelLegend["Model Components"]:::model
        ViewLegend["View Components"]:::view
        AssetLegend["Asset Components"]:::asset
    end
```
