# grebtsew/floorplantoblender3d architecture

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

- Interactive diagram: https://gitdiagram.com/grebtsew/floorplantoblender3d
- Repository: https://github.com/grebtsew/floorplantoblender3d

## Overview

##### Project type and purpose
- This is a specialized full-stack Python application and library whose core purpose is to take 2D floorplan images and automatically generate corresponding 3D models in Blender.
- It ships with:
- FTBL (FloorplanToBlenderLib) – the core image-processing, detection, geometry-generation and Blender-export library.
- Example scripts and notebooks (Docs, Blender/) that invoke FTBL directly.
- A Flask-based server (Server/) exposing a Swagger documented REST API that accepts images and returns Blender files.
- Docker and Docker-Compose configurations for script, server and Jupyter modes.

##### File structure
- Top-level: Docker files, README, main.py, requirements, license.
- Server/ – Flask application with subfolders for API handlers (api/), file handling, processing pipeline (process/), configuration (config/), Swagger UI assets, test clients.
- Docs/ – tutorials and Jupyter notebooks.
- Blender/ and Development Center/ – example scripts for exporting to Blender.
- Stacking/ – batch/world-building language and examples.
- Testing/ – pytest suites for both library and server.

##### README for additional insights
- FTBL library and standalone scripts share the same processing pipeline.
- The server organizes its functionality into REST controllers → business logic in process/ → core FTBL library.
- Docker-Compose brings up three modes: script, server with Swagger, and Jupyter tutorials.

##### Main components and their interactions
a. Client Layers
- Example CLI scripts or Jupyter notebook (Docs/)
- HTTP clients (curl, browser via Swagger UI)
b. Server Layer
- Flask web server (Server/flask + Server/api)
- REST controllers (GET/POST/PUT) → delegate to Server/process modules
- FileHandler (Server/file) for temporary storage of inputs/outputs
- ConfigHandler (Server/config) for runtime settings
- Swagger UI (Server/swagger) for interactive docs
c. Processing Layer
- Server/process/*.py: orchestrate “load image → detect walls/rooms/doors → generate geometry → export .blend”
d. Core Library (FloorplanToBlenderLib/)
- Detection submodules (edge/feature matching)
- Geometric calculations (calculate.py, transform.py, stacking.py)
e. External Services & Tools
- Blender3D (called via scripts or headless mode)
- Docker container for packaging and deployment
- Weave Scope (optional monitoring)
f. Data & Config
- Input images (Images/Examples)
- Config files (Configs folder created at runtime)
- Stacking scripts (Stacking/) for batch builds

##### Architectural patterns and design principles
- Layered architecture: Presentation (CLI/HTTP) → Controller (Flask API) → Service/Process layer → Core library → External tool (Blender).
- Separation of concerns: FTBL library is reusable outside the server.
- Plug-in style modules: detection, transform, generate are decoupled.
- RESTful API with auto-generated Swagger documentation.
- Containerized deployment via Docker + Compose for reproducibility.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client / Presentation Layer
    subgraph "Client / Presentation"
        NB["Jupyter Notebook"]:::client
        PPT["Presentation PPTX"]:::client
        BE["Blender Example Scripts"]:::client
        DEV["DevCenter Blender Demos"]:::client
        HTTP["Swagger UI Browser"]:::client
        CLI["CLI Scripts"]:::client
    end

    %% Server Layer
    subgraph "API Server"
        MAIN["main.py"]:::server
        FLASK["Flask Handler"]:::server
        CONTROLLERS["REST API Controllers"]:::server
        FILEH["FileHandler"]:::server
        CONFH["ConfigHandler"]:::server
        SHARED["Shared Variables"]:::server
        SWAGGER_UI["Swagger UI Assets"]:::server
    end

    %% Processing Pipeline
    subgraph "Processing Pipeline"
        ORCH["Process Orchestrator"]:::process
        COMP["compare.py"]:::process
        CREATE["create.py"]:::process
        EVAL["evaluate.py"]:::process
        FILTER["filter.py"]:::process
        REFORMAT["reformat.py"]:::process
        RESIZE["resize.py"]:::process
    end

    %% Core Library
    subgraph "Core Library (FTBL)"
        IO["IO.py"]:::corelib
        DET["detect.py"]:::corelib
        DRW["draw.py"]:::corelib
        GEN["generate.py"]:::corelib
        TRF["transform.py"]:::corelib
        CALC["calculate.py"]:::corelib
        STACK["stacking.py"]:::corelib
        EXEC["execution.py"]:::corelib
        DLG["dialog.py"]:::corelib
        IMG["image.py"]:::corelib
        CFG["config.py"]:::corelib
        CST["const.py"]:::corelib
        FPLAN["floorplan.py"]:::corelib
        GENR["generator.py"]:::corelib
    end

    %% External Tools & Deployment
    subgraph "External Tools & Deployment"
        BLENDER["Blender3D"]:::external
        DOCKER["Docker Compose"]:::external
        WEAVE["Weave Scope"]:::external
        STACKDSL["Stacking DSL Files"]:::external
        CONFIG_STORE["Runtime Config Store"]:::external
    end

    %% Data Flow Arrows
    CLI -->|Python calls| IO
    NB -->|Python calls| IO
    BE -->|Python scripts| IO
    DEV -->|Python scripts| IO

    HTTP -->|HTTP POST /floorplan| FLASK
    FLASK -->|delegate| CONTROLLERS
    CONTROLLERS -->|invoke| ORCH
    FILEH -->|store/load files| ORCH
    CONFH -->|provide settings| ORCH
    SHARED -->|shared state| ORCH

    ORCH -->|calls| COMP
    ORCH -->|calls| CREATE
    ORCH -->|calls| EVAL
    ORCH -->|calls| FILTER
    ORCH -->|calls| REFORMAT
    ORCH -->|calls| RESIZE

    COMP -->|uses| DET
    CREATE -->|uses| GEN
    EVAL -->|uses| CALC
    FILTER -->|uses| TRF
    REFORMAT -->|uses| DRW
    RESIZE -->|uses| IMG

    ORCH -->|export| DLG
    DLG -->|run| EXEC
    EXEC -->|launch| BLENDER
    BLENDER -->|produce .blend| FILEH
    FILEH -->|return .blend| FLASK
    FLASK -->|HTTP response| HTTP

    STACKDSL -->|feed| ORCH
    CONFIG_STORE -->|loaded by| CONFH

    DOCKER -->|runs| FLASK
    DOCKER -->|runs| NB
    DOCKER -->|runs| CLI
    WEAVE -->|monitors| DOCKER

    %% Click Events - Client Layer
    click NB "https://github.com/grebtsew/floorplantoblender3d/blob/master/Docs/FloorplanToBlenderLibrary.ipynb"
    click PPT "https://github.com/grebtsew/floorplantoblender3d/blob/master/Docs/Floorplan To Blender.pptx"
    click BE "https://github.com/grebtsew/floorplantoblender3d/blob/master/Blender/blender_export_any.py"
    click BE "https://github.com/grebtsew/floorplantoblender3d/blob/master/Blender/blender_export_obj_script.py"
    click BE "https://github.com/grebtsew/floorplantoblender3d/blob/master/Blender/floorplan_to_3dObject_in_blender.py"
    click BE "https://github.com/grebtsew/floorplantoblender3d/blob/master/Blender/reformat_object.py"
    click BE "https://github.com/grebtsew/floorplantoblender3d/blob/master/Blender/show_model.py"
    click DEV "https://github.com/grebtsew/floorplantoblender3d/blob/master/Development Center/Blender_scripts/simple_house_example.py"
    click DEV "https://github.com/grebtsew/floorplantoblender3d/blob/master/Development Center/Blender_scripts/simple_plane_example.py"
    click DEV "https://github.com/grebtsew/floorplantoblender3d/blob/master/Development Center/Blender_scripts/Reformat_blender_to_obj.py"

    %% Click Events - Server Layer
    click MAIN "https://github.com/grebtsew/floorplantoblender3d/blob/master/Server/main.py"
    click FLASK "https://github.com/grebtsew/floorplantoblender3d/blob/master/Server/flask/flask_handler.py"
    click CONTROLLERS "https://github.com/grebtsew/floorplantoblender3d/blob/master/Server/api/api.py"
    click CONTROLLERS "https://github.com/grebtsew/floorplantoblender3d/blob/master/Server/api/get.py"
    click CONTROLLERS "https://github.com/grebtsew/floorplantoblender3d/blob/master/Server/api/post.py"
    click CONTROLLERS "https://github.com/grebtsew/floorplantoblender3d/blob/master/Server/api/put.py"
    click CONTROLLERS "https://github.com/grebtsew/floorplantoblender3d/blob/master/Server/api/server.py"
    click FILEH "https://github.com/grebtsew/floorplantoblender3d/blob/master/Server/file/file_handler.py"
    click CONFH "https://github.com/grebtsew/floorplantoblender3d/blob/master/Server/config/config_handler.py"
    click CONFH "https://github.com/grebtsew/floorplantoblender3d/blob/master/Server/config/server_config.ini"
    click SHARED "https://github.com/grebtsew/floorplantoblender3d/blob/master/Server/shared_variables.py"
    click SWAGGER_UI "https://github.com/grebtsew/floorplantoblender3d/blob/master/Server/swagger/swagger-ui/index.html"

    %% Click Events - Processing Pipeline
    click ORCH "https://github.com/grebtsew/floorplantoblender3d/blob/master/Server/process/process.py"
    click COMP "https://github.com/grebtsew/floorplantoblender3d/blob/master/Server/process/compare.py"
    click CREATE "https://github.com/grebtsew/floorplantoblender3d/blob/master/Server/process/create.py"
    click EVAL "https://github.com/grebtsew/floorplantoblender3d/blob/master/Server/process/evaluate.py"
    click FILTER "https://github.com/grebtsew/floorplantoblender3d/blob/master/Server/process/filter.py"
    click REFORMAT "https://github.com/grebtsew/floorplantoblender3d/blob/master/Server/process/reformat.py"
    click RESIZE "https://github.com/grebtsew/floorplantoblender3d/blob/master/Server/process/resize.py"

    %% Click Events - Core Library
    click IO "https://github.com/grebtsew/floorplantoblender3d/blob/master/FloorplanToBlenderLib/IO.py"
    click DET "https://github.com/grebtsew/floorplantoblender3d/blob/master/FloorplanToBlenderLib/detect.py"
    click DRW "https://github.com/grebtsew/floorplantoblender3d/blob/master/FloorplanToBlenderLib/draw.py"
    click GEN "https://github.com/grebtsew/floorplantoblender3d/blob/master/FloorplanToBlenderLib/generate.py"
    click TRF "https://github.com/grebtsew/floorplantoblender3d/blob/master/FloorplanToBlenderLib/transform.py"
    click CALC "https://github.com/grebtsew/floorplantoblender3d/blob/master/FloorplanToBlenderLib/calculate.py"
    click STACK "https://github.com/grebtsew/floorplantoblender3d/blob/master/FloorplanToBlenderLib/stacking.py"
    click EXEC "https://github.com/grebtsew/floorplantoblender3d/blob/master/FloorplanToBlenderLib/execution.py"
    click DLG "https://github.com/grebtsew/floorplantoblender3d/blob/master/FloorplanToBlenderLib/dialog.py"
    click IMG "https://github.com/grebtsew/floorplantoblender3d/blob/master/FloorplanToBlenderLib/image.py"
    click CFG "https://github.com/grebtsew/floorplantoblender3d/blob/master/FloorplanToBlenderLib/config.py"
    click CST "https://github.com/grebtsew/floorplantoblender3d/blob/master/FloorplanToBlenderLib/const.py"
    click FPLAN "https://github.com/grebtsew/floorplantoblender3d/blob/master/FloorplanToBlenderLib/floorplan.py"
    click GENR "https://github.com/grebtsew/floorplantoblender3d/blob/master/FloorplanToBlenderLib/generator.py"

    %% Click Events - External Tools & Deployment
    click DOCKER "https://github.com/grebtsew/floorplantoblender3d/blob/master/docker-compose.yml"

    %% Styles
    classDef client fill:#FFA500,stroke:#333,stroke-width:1px
    classDef server fill:#90EE90,stroke:#333,stroke-width:1px
    classDef process fill:#E6E6FA,stroke:#333,stroke-width:1px
    classDef corelib fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
