# code-guy/bamboo architecture

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

- Interactive diagram: https://gitdiagram.com/code-guy/bamboo
- Repository: https://github.com/code-guy/bamboo

## Overview

##### Main High-Level Components
a. Editor Module
- UI Subsystem (ImGui via external/imgui)
- Editor Core (source/editor): asset UI, folder tree, property panels, simulation/PIE controls
b. Engine Core Module (source/engine)
- Core Systems: Logging (spdlog), Config (yaml-cpp), Event (eventpp), Math
- Platform Abstractions: File I/O, Timer, Thread-safe queues
- Reflection/Serialization (rttr + cereal)
c. Function Layers (within Engine)
- Framework (scene graph, entities, components)
- Physics System (Jolt Physics integration)
- Rendering System
- Render passes (deferred, forward, shadow, postprocess)
- Render Data & Pipeline (Vulkan RHI in source/engine/core/vulkan)
- Resource Management
- Asset Importers (tinygltf, ktx, custom)
- Shader Management
d. External Libraries
- Vulkan Memory Allocator (vma), GLFW, GLM, ImGui, spdlog, yaml-cpp, tinygltf, ktx, cereal, rttr, eventpp, random
e. GPU & OS Interfaces
- Vulkan Driver & GPU
- Windowing/Input (GLFW)

##### Relationships & Data Flows
- Editor ↔ Engine API: the Editor module calls into the Engine Core (entities, resource loader, simulation) via a well-defined API layer.
- Engine Core → Resource Manager: loading assets (meshes, textures, shaders), parsing config via yaml-cpp, serializing scenes via cereal/rttr.
- Engine Core → Physics System: updates, collision queries, body creation via Jolt.
- Vulkan RHI → OS & GPU: interacts with GLFW for window/surface, communicates with Vulkan driver.
- Event System: an internal bus (eventpp) delivering UI events, simulation events, and system events across modules.
- Logging & Config: global singletons accessed by all subsystems.

##### Architectural Patterns & Principles
- Modular layering: clear separation of Editor, Engine Core, Function Layers, and External Dependencies.
- Component-Entity System: scene graph uses entity/component pattern (source/engine/function/framework).
- Pipeline-based Rendering: sequence of render passes, configurable mix of deferred + forward.
- Data-driven design: YAML-based config, reflection via rttr for serialization and editor inspectors.
- Dependency isolation: engine/editor/game code compiled as static libs, minimal circular dependencies.

a. Three horizontal strata:
1. Editor Layer (top)
2. Engine Core Layer (middle) subdivided into subsystems: Core, Function, Resource, Physics, Render
3. External/Hardware Layer (bottom)
c. In Engine Core, arrange:
- Core Systems (Event, Logging, Config) at left
- Resource Manager centrally (AssetImporter, ShaderManager)
- Physics System (Jolt) at left-middle
- Rendering Pipeline (RenderPasses → VulkanRHI) at right-middle
- Framework (Entity/Component, WorldManager) between Core and Physics/Render
d. In External/Hardware layer, list:
- Disk/Filesystem (via FileSystem abstraction)
- Vulkan Driver & GPU
- Windowing/Input (GLFW)
e. Resource Manager downward to Disk (Load assets) and up to Framework. Connect Render Pipeline downward to Vulkan/GPU. Connect GLFW to both Editor (UI events) and VulkanRHI (surface).

##### Details
- Shader folder as a pipeline input → ShaderManager.
- Static libs linking: Engine Core compiles into libBambooEngine.a, Editor into libBambooEditor.a.
- Reflection/serialization round-trip between Engine Core and Editor for runtime data inspection.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Editor Layer
    subgraph "Editor Layer"
        UI["ImGui UI (UI Subsystem)"]:::editor
        AssetUI["Asset UI"]:::editor
        FolderTreeUI["FolderTree UI"]:::editor
        PropertyUI["Property Panels UI"]:::editor
        SimulationUI["Simulation/PIE Controls UI"]:::editor
    end

    %% Engine Core Layer
    subgraph "Engine Core Layer"
        subgraph "Core Systems"
            Log["Logging (spdlog)"]:::engine
            Config["Config Manager"]:::engine
            Event["Event System"]:::engine
            Math["Math Utilities"]:::engine
        end
        subgraph "Platform Abstractions"
            FS["FileSystem"]:::engine
            Timer["Timer"]:::engine
            TSQ["Thread-Safe Queue"]:::engine
        end
        subgraph "Reflection/Serialization"
            RTTR["Reflection (rttr)"]:::external
            Cereal["Serialization (cereal)"]:::external
        end
        subgraph "Resource Management"
            AssetMgr["Asset Manager"]:::engine
            GLTFImp["GLTF Importer"]:::engine
            ShaderMgr["Shader Manager"]:::engine
        end
        subgraph "Function Layers"
            Framework["Entity/Component System"]:::engine
            Physics["Physics System"]:::engine
            subgraph "Rendering Pipeline"
                Passes["Render Passes"]:::engine
                RenderData["Render Data"]:::engine
                VulkanRHI["Vulkan RHI"]:::engine
            end
        end
    end

    %% External / Hardware Layer
    subgraph "External / Hardware Layer"
        subgraph "External Libraries"
            extGLFW["GLFW"]:::external
            extVMA["Vulkan Memory Allocator"]:::external
            extGLM["GLM"]:::external
            extTINY["tinygltf"]:::external
            extKTX["ktx"]:::external
            extYAML["yaml-cpp"]:::external
            extEventpp["eventpp"]:::external
            extCereal["cereal"]:::external
            extRTTR["rttr"]:::external
            extSPDLOG["spdlog"]:::external
        end
        Disk(("Disk/Filesystem")):::hardware
        GPU(("Vulkan Driver & GPU")):::hardware
    end

    %% Connections
    UI -->|"UIEvent"| Event
    AssetUI -->|"ModifyComponent"| Framework
    FolderTreeUI -->|"ModifyComponent"| Framework
    PropertyUI -->|"ModifyComponent"| Framework
    SimulationUI -->|"PIE Start"| Framework

    Framework -->|"SimulationUpdate"| Physics
    Framework -->|"SubmitRenderData"| Passes
    Passes -->|"CommandBuffer"| VulkanRHI
    VulkanRHI -->|"Surface"| extGLFW
    VulkanRHI -->|"Vulkan Calls"| GPU

    FS -->|"ReadAsset"| AssetMgr
    AssetMgr -->|"LoadFromDisk"| Disk
    ShaderMgr -->|"LoadShaders"| Passes

    Config -->|"YAML parse"| Framework
    Config -->|"ConfigData"| AssetMgr

    Event -->|"Broadcast"| Framework
    Event -->|"Broadcast"| AssetUI

    Log -->|"LogEvents"| Framework

    %% Click Events
    click UI "https://github.com/code-guy/bamboo/tree/master/external/imgui"
    click AssetUI "https://github.com/code-guy/bamboo/blob/master/source/editor/asset/asset_ui.cpp"
    click FolderTreeUI "https://github.com/code-guy/bamboo/blob/master/source/editor/base/folder_tree_ui.cpp"
    click PropertyUI "https://github.com/code-guy/bamboo/blob/master/source/editor/property/property_ui.cpp"
    click SimulationUI "https://github.com/code-guy/bamboo/blob/master/source/editor/simulation/simulation_ui.cpp"
    click Log "https://github.com/code-guy/bamboo/blob/master/source/engine/core/log/log_system.cpp"
    click Config "https://github.com/code-guy/bamboo/blob/master/source/engine/core/config/config_manager.cpp"
    click Event "https://github.com/code-guy/bamboo/blob/master/source/engine/core/event/event_system.cpp"
    click FS "https://github.com/code-guy/bamboo/blob/master/source/engine/platform/file/file_system.cpp"
    click Timer "https://github.com/code-guy/bamboo/blob/master/source/engine/platform/timer/timer.cpp"
    click TSQ "https://github.com/code-guy/bamboo/blob/master/source/engine/platform/container/ts_queue.h"
    click AssetMgr "https://github.com/code-guy/bamboo/blob/master/source/engine/resource/asset/asset_manager.cpp"
    click GLTFImp "https://github.com/code-guy/bamboo/blob/master/source/engine/resource/asset/importer/gltf_importer.cpp"
    click ShaderMgr "https://github.com/code-guy/bamboo/blob/master/source/engine/resource/shader/shader_manager.cpp"
    click Framework "https://github.com/code-guy/bamboo/blob/master/source/engine/function/framework/entity/entity.cpp"
    click Physics "https://github.com/code-guy/bamboo/blob/master/source/engine/function/physics/physics_system.cpp"
    click VulkanRHI "https://github.com/code-guy/bamboo/blob/master/source/engine/core/vulkan/vulkan_rhi.cpp"
    click extGLFW "https://github.com/code-guy/bamboo/tree/master/external/glfw"
    click extVMA "https://github.com/code-guy/bamboo/blob/master/external/vma/vk_mem_alloc.h"
    click extGLM "https://github.com/code-guy/bamboo/tree/master/external/glm"
    click extTINY "https://github.com/code-guy/bamboo/tree/master/external/tinygltf"
    click extKTX "https://github.com/code-guy/bamboo/tree/master/external/ktx"
    click extYAML "https://github.com/code-guy/bamboo/tree/master/external/yaml-cpp"
    click extEventpp "https://github.com/code-guy/bamboo/tree/master/external/eventpp"
    click extCereal "https://github.com/code-guy/bamboo/tree/master/external/cereal"
    click extRTTR "https://github.com/code-guy/bamboo/tree/master/external/rttr"
    click extSPDLOG "https://github.com/code-guy/bamboo/tree/master/external/spdlog"

    %% Styles
    classDef editor fill:#9f6,stroke:#333,stroke-width:1px;
    classDef engine fill:#6cf,stroke:#333,stroke-width:1px;
    classDef external fill:#ccc,stroke:#333,stroke-width:1px;
    classDef hardware fill:#fc9,stroke:#333,stroke-width:1px;
```
