# seedyrom/stabby architecture

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

- Interactive diagram: https://gitdiagram.com/seedyrom/stabby
- Repository: https://github.com/seedyrom/stabby

## Overview

##### Project Type and Purpose
- This is a C++-based 2D game project (“Stabby”) composed of:
- A custom game engine (“STE”: Stabby Engine)
- A standalone game binary that uses the engine
- A lightweight level‐editing tool (“Editor”) built on the same engine
- Purpose: provide a platform‐independent, modern C++ game engine with ECS, rendering, audio, input, etc., plus tools to build and run a 2D hack-and-slash game.

##### File Structure
Top-level structure:
- build scripts & config: CMakeLists.txt, Makefile, conanfile.txt, BUILD.md, .github/workflows
- assets/ (maps, textures, audio, fonts)
- src/
– engine/ (core subsystems)
– editor/ (editor UI and entrypoint)
– game/ (game-specific code and entrypoint)
Engine subsystems (under src/engine):
- assets (async resource loading, asset manager)
- async (thread pool, lock-free queues)
- audio (engine, file loader, queue, manager, system)
- gui (portable dialogs, UI primitives)
- input (keyboard/mouse)
- rendering (window, shaders, textures, 2D batch renderer, fonts, camera)
- time (game timer)
- world (ECS, scene/map, serialization, quadtree)

##### README for Insights
- Core engine features: modern C++20/23, lock-free async, RAII, batch rendering, thread pool
- Dependencies: SDL2 (window/input), OpenGL (rendering), GLAD (loader), GLM (math), Conan (pkg mgr)
- Separate engine from game via CMake; reproducible multi-platform builds

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Applications"
        EditorApp["Editor App"]:::apps
        GameApp["Game App"]:::apps
    end

    subgraph "Engine Core"
        AssetMgmt["Asset Management"]:::engine
        Async["Async / Thread Pool"]:::engine
        Audio["Audio Subsystem"]:::engine
        Rendering["Rendering Subsystem"]:::engine
        Input["Input Manager"]:::engine
        World["World / ECS & Scene Manager"]:::engine
        GUI["GUI Utilities"]:::engine
        Time["Time / Game Timer"]:::engine
    end

    subgraph "Platform / Runtime"
        SDL2["SDL2"]:::platform
        GLAD["GLAD (OpenGL Loader)"]:::platform
        OpenGL["OpenGL"]:::platform
        GLM["GLM"]:::platform
        PFD["Portable File Dialogs"]:::platform
        OS["OS & GPU Drivers"]:::platform
    end

    AssetsRepo["Assets Repository"]:::data
    Build["Build Pipeline & CI"]:::pipeline

    %% Application to Engine Core
    EditorApp -->|"calls APIs"| AssetMgmt
    EditorApp -->|"calls APIs"| Rendering
    EditorApp -->|"calls APIs"| GUI
    EditorApp -->|"calls APIs"| Input
    EditorApp -->|"calls APIs"| World
    EditorApp -->|"calls APIs"| Audio
    EditorApp -->|"uses timer"| Time

    GameApp -->|"calls APIs"| AssetMgmt
    GameApp -->|"calls APIs"| Rendering
    GameApp -->|"calls APIs"| Input
    GameApp -->|"calls APIs"| World
    GameApp -->|"calls APIs"| Audio
    GameApp -->|"uses timer"| Time

    %% Engine Core interactions
    AssetMgmt -->|"delegates tasks to"| Async
    AssetMgmt -->|"loads from"| AssetsRepo
    Async -->|"threads for"| AssetMgmt
    Audio -->|"pushes audio buffers via"| SDL2
    Audio -->|"uses queue from"| Async
    Rendering -->|"submits draw commands via"| GLAD
    GLAD -->|"binds to"| OpenGL
    Rendering -->|"window & input via"| SDL2
    Rendering -->|"renders on"| OS
    Input -->|"polls events from"| SDL2
    World -->|"serializes maps in"| AssetsRepo
    GUI -->|"dialogs via"| PFD
    Time -->|"drives loop"| GameApp
    Time -->|"drives loop"| EditorApp

    %% Build Pipeline
    Build -->|"builds"| EditorApp
    Build -->|"builds"| GameApp

    %% Click Events
    click EditorApp "https://github.com/seedyrom/stabby/blob/develop/src/editor/main.cpp"
    click GameApp "https://github.com/seedyrom/stabby/blob/develop/src/game/main.cpp"
    click EngineCore "https://github.com/seedyrom/stabby/blob/develop/src/engine/engine.h"
    click AssetMgmt "https://github.com/seedyrom/stabby/blob/develop/src/engine/assets/asset_loader.cpp"
    click Async "https://github.com/seedyrom/stabby/blob/develop/src/engine/async/thread_pool.cpp"
    click Audio "https://github.com/seedyrom/stabby/blob/develop/src/engine/audio/audio_engine.cpp"
    click Rendering "https://github.com/seedyrom/stabby/blob/develop/src/engine/rendering/window.cpp"
    click Input "https://github.com/seedyrom/stabby/blob/develop/src/engine/input/input_manager.cpp"
    click World "https://github.com/seedyrom/stabby/blob/develop/src/engine/world/ecs.h"
    click GUI "https://github.com/seedyrom/stabby/blob/develop/src/engine/gui/portable-file-dialogs.h"
    click Time "https://github.com/seedyrom/stabby/blob/develop/src/engine/time/game_timer.cpp"
    click AssetsRepo "https://github.com/seedyrom/stabby/tree/develop/assets"
    click Build "https://github.com/seedyrom/stabby/blob/develop/CMakeLists.txt"

    %% Styles
    classDef engine fill:#cfe2f3,stroke:#0366d6
    classDef apps fill:#d1e7dd,stroke:#0f5132
    classDef platform fill:#ffe5d9,stroke:#d9480f
    classDef data fill:#fff3cd,stroke:#664d03
    classDef pipeline fill:#e2e3e5,stroke:#495057
```
