# san7o/brenta-engine architecture

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

- Interactive diagram: https://gitdiagram.com/san7o/brenta-engine
- Repository: https://github.com/san7o/brenta-engine

## Overview

##### Project type and purpose
- Brenta Engine is a modular 3D engine library/tool written in modern C++ and OpenGL, employing an Entity-Component-System (ECS) architecture.
- It provides reusable submodules (Screen, Audio, Input, Text, Particles, ECS), a core Engine builder API, an example “game” demo, and example programs.

##### File structure
- Top‐level directories:
- engine/      → core engine submodules (headers, sources, shaders)
- game/        → demo application using the engine and ECS (entities, systems, callbacks)
- examples/    → stand-alone example programs illustrating engine usage
- tests/       → unit tests for engine components
- assets/      → art assets (models, textures, audio, docs)
- lib/         → static third-party libraries (SDL3, Assimp, FreeType, HarfBuzz)
- /     → bundled headers for dependencies (GLFW, SDL3, GLM, ImGui, stb_image)
- Build & config files: CMakeLists.txt, BUILD.md, Makefile, flake.nix, doxygen.conf.

##### README for insights
- Submodules are independent and pluggable via a builder API.
- ECS is provided by viotecs (external) and integrated.
- ImGui is included for debugging UIs.
- Dependencies: SDL3/GLFW for windowing, GLAD for OpenGL loading, Assimp for model import, FreeType & HarfBuzz for text.

1. Engine Core
– Builder API (engine::builder)
– Submodules: Screen, Audio, Input, Logger, Text, Particles, ECS interface
2. ECS Layer
– World manager, Entities, Components, Systems (fps_system, physics_system, etc.)
3. Rendering Pipeline
– OpenGL context (via Screen)
– Shader manager, Mesh/model loader (Assimp), Texture loader (stb_image)
– Framebuffer, GUI (ImGui)
4. Demo Game
– Callback handlers (camera, input, audio triggers)
– Game‐specific entities & components
5. Examples
– Independent executables interfacing with Engine Core
6. Third-party libs & headers
– SDL3, GLFW, GLAD, GLM, Assimp, FreeType, HarfBuzz, stb_image, ImGui
7. Assets
– Models, Textures, Audio
- Engine Core ↔ ECS Layer (engine tick invokes registered systems on entities).
- Screen Module → OS/windowing API (SDL3/GLFW) → OpenGL driver.
- Rendering Pipeline → GPU via GLAD/OpenGL calls.
- Model/Text loader modules → Assimp, FreeType/Harfbuzz → Asset files.
- ImGui Module → Engine Core for debug UI.
c. Architectural patterns & principles:
- Entity-Component-System for modular game logic separation.
- Builder pattern for Engine configuration.
- Modular submodule isolation (each subsystem can be toggled on/off).
- Layered architecture (Platform → Engine Core → Game/Examples).
d. Key technologies & frameworks:
- C++17/20, OpenGL (GLAD), SDL3/GLFW, ImGui, Assimp, FreeType, HarfBuzz, GLM maths.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Demo and Examples Layer
    DemoGame["Demo Game Application"]:::demo
    Examples["Examples"]:::demo

    %% Engine Core Submodules
    subgraph "Engine Core"
        BuilderAPI["Builder API"]:::core
        Screen["Screen Module"]:::core
        Audio["Audio Module"]:::core
        Input["Input Module"]:::core
        Logger["Logger Module"]:::core
        Text["Text Module"]:::core
        Particles["Particles Module"]:::core
        ECSInterface["ECS Interface"]:::core
        ShaderMgr["Shader Manager"]:::core
        MeshLoader["Mesh/Model Loader"]:::core
        TextureLoader["Texture Loader"]:::core
        Framebuffer["Framebuffer"]:::core
        GLOps["OpenGL Helpers"]:::core
        GUI["GUI (ImGui)"]:::core
    end

    %% ECS Layer
    subgraph "ECS Layer"
        World["World Manager"]:::ecs
        Entities["Entities"]:::ecs
        Components["Components"]:::ecs
        Systems["Systems"]:::ecs
    end

    %% Third-Party Libraries
    subgraph "Third-Party"
        SDL["SDL3/GLFW"]:::external
        GLAD["GLAD"]:::external
        Assimp["Assimp"]:::external
        FreeType["FreeType/HarfBuzz"]:::external
        stb["stb_image"]:::external
    end

    %% Assets
    Assets["Assets\n(models, textures, audio)"]:::asset

    %% Build & Config
    Build["Build & Config"]:::build

    %% Relations
    DemoGame -->|"uses"| BuilderAPI
    Examples -->|"uses"| BuilderAPI

    BuilderAPI --> Screen
    BuilderAPI --> Audio
    BuilderAPI --> Input
    BuilderAPI --> Logger
    BuilderAPI --> Text
    BuilderAPI --> Particles
    BuilderAPI --> ECSInterface
    BuilderAPI --> ShaderMgr
    BuilderAPI --> MeshLoader
    BuilderAPI --> TextureLoader
    BuilderAPI --> Framebuffer
    BuilderAPI --> GLOps
    BuilderAPI --> GUI

    ECSInterface --> World
    World --> Entities
    Entities --> Components
    Components --> Systems
    Systems --> ECSInterface

    Screen --> SDL
    SDL --> GLOps
    GLOps --> GLAD

    MeshLoader --> Assimp
    MeshLoader --> Assets
    TextureLoader --> stb
    TextureLoader --> Assets

    Assets --> MeshLoader
    Assets --> TextureLoader

    Build --> BuilderAPI
    Build --> Screen
    Build --> Audio
    Build --> Input
    Build --> Logger
    Build --> Text
    Build --> Particles
    Build --> ECSInterface
    Build --> ShaderMgr
    Build --> MeshLoader
    Build --> TextureLoader
    Build --> Framebuffer
    Build --> GLOps
    Build --> GUI
    Build --> SDL
    Build --> GLAD
    Build --> Assimp
    Build --> FreeType
    Build --> stb

    %% Click Events
    click BuilderAPI "https://github.com/san7o/brenta-engine/blob/main/engine/headers/engine.hpp"
    click Screen "https://github.com/san7o/brenta-engine/blob/main/engine/headers/screen.hpp"
    click Audio "https://github.com/san7o/brenta-engine/blob/main/engine/headers/engine_audio.hpp"
    click Input "https://github.com/san7o/brenta-engine/blob/main/engine/headers/engine_input.hpp"
    click Logger "https://github.com/san7o/brenta-engine/blob/main/utils/headers/engine_logger.hpp"
    click Text "https://github.com/san7o/brenta-engine/blob/main/engine/headers/text.hpp"
    click Particles "https://github.com/san7o/brenta-engine/blob/main/engine/headers/particles.hpp"
    click ShaderMgr "https://github.com/san7o/brenta-engine/blob/main/engine/headers/shader.hpp"
    click MeshLoader "https://github.com/san7o/brenta-engine/blob/main/engine/headers/mesh.hpp"
    click TextureLoader "https://github.com/san7o/brenta-engine/blob/main/engine/headers/texture.hpp"
    click Framebuffer "https://github.com/san7o/brenta-engine/blob/main/engine/headers/frame_buffer.hpp"
    click GLOps "https://github.com/san7o/brenta-engine/blob/main/engine/headers/gl_helper.hpp"
    click GUI "https://github.com/san7o/brenta-engine/blob/main/engine/headers/gui.hpp"
    click ECSInterface "https://github.com/san7o/brenta-engine/blob/main/game/headers/game_ecs.hpp"
    click DemoGame "https://github.com/san7o/brenta-engine/blob/main/game/sources/main.cpp"
    click Examples "https://github.com/san7o/brenta-engine/tree/main/examples/"
    click Assets "https://github.com/san7o/brenta-engine/tree/main/assets/models/"
    click SDL "https://github.com/san7o/brenta-engine/tree/main/include/SDL3/"
    click GLAD "https://github.com/san7o/brenta-engine/tree/main/include/glad/"
    click Assimp "https://github.com/san7o/brenta-engine/tree/main/include/assimp/"
    click FreeType "https://github.com/san7o/brenta-engine/tree/main/include/freetype/"
    click stb "https://github.com/san7o/brenta-engine/blob/main/include/stb_image.h"
    click Build "https://github.com/san7o/brenta-engine/blob/main/CMakeLists.txt"

    %% Styles
    classDef core fill:#e0f7fa,stroke:#006064,color:#006064
    classDef ecs fill:#e8f5e9,stroke:#2e7d32,color:#2e7d32
    classDef demo fill:#fff3e0,stroke:#ef6c00,color:#e65100
    classDef external fill:#eeeeee,stroke:#616161,color:#424242
    classDef asset fill:#fff9c4,stroke:#fbc02d,color:#f57f17
    classDef build fill:#f5f5f5,stroke:#9e9e9e,color:#616161
```
