# jritchie02/ecs-game-engine architecture

> Architecture diagram of the GitHub repository jritchie02/ecs-game-engine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jritchie02/ecs-game-engine
- Repository: https://github.com/jritchie02/ecs-game-engine

## Overview

- Engine Core: At the center is the Application (see Application.cpp and Application.hpp) that ties together every subsystem.
- Subsystems / Systems: Include core modules like RenderingSystem, PhysicsSystem, InputSystem, ResourceManager, ImGuiLayer, SDLLayer, and possibly game-specific modules such as Board, Scene/SceneView, Spritesheet, and Components.
- External Libraries: Show integrations with SDL (used for rendering and window handling), ImGUI (for editor UI), Box2D (for physics simulation – this is included as a third-party submodule), and pybind (for binding C++ code to Python).
- Assets: Represent the asset management side (art files, level files, fonts, etc.) that the engine loads via ResourceManager.
- Editor & Level Scripts: In the “bin” folder you have several Python scripts (level1.py, level2.py, level3.py, levelBuilder.py, sim.py) that use the built shared object (blockbyte.so) to run levels or operate the level editor.
- Documentation & Build Tools: Although not core to runtime, indicate that documentation (generated by Doxygen in the “docs” folder) and Makefile support the build/deployment process.

##### Relationships and interactions
- SDLLayer to the RenderingSystem and InputSystem, indicating that lower-level SDL operations are abstracted by these higher-level systems.
- Link ImGuiLayer as a UI overlay that interacts with the core engine (for displaying editor windows and panels) and also receives input via InputSystem.
- That ResourceManager loads assets (images, fonts, level data) from the “assets” directory.

##### Architectural patterns and design principles
- Entity–Component–System (ECS) approach – showing that many engine components (as evidenced by Components.hpp) are designed for modularity.
- Decoupling between rendering, physics, and input, which is achieved via a modular design where each subsystem is responsible for a distinct task.
- That the engine is extensible through the editor (ImGui-based panels) and scriptable (via Python binding), which are typical patterns in modern game engines.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Engine Core Modules
    subgraph "Engine Core Modules"
        AC("Application Core"):::core
        RS("Rendering System (SDL+ImGUI)"):::core
        PS("Physics System (Box2D)"):::core
        IS("Input System"):::core
        RM("Resource Manager"):::core
        IM("ImGui Layer"):::core
        SDL("SDLLayer"):::core
        GB("Game Board"):::core
        SM("Scene Management"):::core
        SS("Spritesheet Support"):::core
        ECS("ECS Components"):::core
    end

    %% External Dependencies
    subgraph "External Dependencies"
        SDLib("SDL"):::external
        B2("Box2D"):::external
        ImEx("ImGUI"):::external
    end

    %% Editor & Scripting
    subgraph "Editor & Scripting"
        PScr("Python Scripting & Editor Integration"):::scripting
    end

    %% Support Components
    subgraph "Support Components"
        Assets("Assets"):::assets
        Docs("Documentation & Build Tools"):::documentation
    end

    %% Relationships between Engine Core Modules
    AC -->|"orchestrates"| RS
    AC -->|"orchestrates"| PS
    AC -->|"orchestrates"| IS
    AC -->|"orchestrates"| RM
    AC -->|"integrates"| IM
    AC -->|"manages"| SM
    AC -->|"integrates"| ECS

    %% SDLLayer relationships
    SDL -->|"abstracts"| SDLib
    SDL -->|"providesOps"| RS
    SDL -->|"providesOps"| IS

    %% ImGui Layer relationships
    IM -->|"receivesInput"| IS
    IM -->|"rendersUI"| AC

    %% Resource Manager relationship
    RM -->|"loads"| Assets

    %% Physics System relationship
    PS -->|"uses"| B2

    %% Scene Management relationships
    SM -->|"contains"| GB
    SM -->|"utilizes"| SS

    %% Game Board to ECS
    GB -->|"integrates"| ECS

    %% Python Scripting integration
    PScr -->|"pybindIntegration"| AC

    %% Link ImGUI external dependency to ImGui related modules
    RS -->|"rendersWith"| ImEx

    %% Click Events
    click AC "https://github.com/jritchie02/ecs-game-engine/blob/main/include/Application.hpp"
    click RS "https://github.com/jritchie02/ecs-game-engine/blob/main/include/RenderingSystem.hpp"
    click PS "https://github.com/jritchie02/ecs-game-engine/blob/main/include/PhysicsSystem.hpp"
    click IS "https://github.com/jritchie02/ecs-game-engine/blob/main/include/InputSystem.hpp"
    click RM "https://github.com/jritchie02/ecs-game-engine/blob/main/include/ResourceManager.hpp"
    click IM "https://github.com/jritchie02/ecs-game-engine/blob/main/include/ImGuiLayer.hpp"
    click SDL "https://github.com/jritchie02/ecs-game-engine/blob/main/include/SDLLayer.hpp"
    click GB "https://github.com/jritchie02/ecs-game-engine/blob/main/include/Board.hpp"
    click SM "https://github.com/jritchie02/ecs-game-engine/blob/main/include/Scene.hpp"
    click SS "https://github.com/jritchie02/ecs-game-engine/blob/main/include/Spritesheet.hpp"
    click ECS "https://github.com/jritchie02/ecs-game-engine/blob/main/include/Components.hpp"
    click Assets "https://github.com/jritchie02/ecs-game-engine/tree/main/assets"
    click PScr "https://github.com/jritchie02/ecs-game-engine/tree/main/bin"
    click B2 "https://github.com/jritchie02/ecs-game-engine/tree/main/thirdParty/Box2D"
    click ImEx "https://github.com/jritchie02/ecs-game-engine/tree/main/thirdParty/imgui"
    click Docs "https://github.com/jritchie02/ecs-game-engine/tree/main/docs"

    %% Styling
    classDef core fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef external fill:#FFFACD,stroke:#000,stroke-width:2px;
    classDef assets fill:#98FB98,stroke:#000,stroke-width:2px;
    classDef scripting fill:#DDA0DD,stroke:#000,stroke-width:2px;
    classDef documentation fill:#FFC0CB,stroke:#000,stroke-width:2px;
```
