# embercraft/ember architecture

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

- Interactive diagram: https://gitdiagram.com/embercraft/ember
- Repository: https://github.com/embercraft/ember

## Overview

##### Project type and purpose
- Ember is a C++-based, cross-platform game engine (2D now, 3D soon), packaged as a library (Ember/) with an integrated Editor (Foundry/) and a Sandbox/demo application (Sandbox/).
- The README confirms core features (rendering, ECS, telemetry, UI), planned extensions (Vulkan, scripting, audio), and the build/run scripts.

##### File structure
- Top-level modules:
- Ember/    → the engine “core” (CMakeLists, src/, Vendor)
- Foundry/  → engine-powered game editor (EditorLayer, panels)
- Sandbox/  → demo application using the engine
- Scripts/  → Python tooling for build & codegen
- build/run scripts and config (run.sh, configure.sh, .gitmodules)
- Within Ember/:
- Core/        → Application, Window, Input, Logging, Timing, Layer stack
- Events/      → Event abstractions (application, keyboard, mouse)
- Math/        → vector/matrix utilities
- Renderer/    → abstract RendererAPI, 2D/Batch/Shader, Texture, Framebuffer, Cameras, Command interface
- ImGui/       → Editor UI integration layer
- Scene/       → ECS: Entity, Components, Scene graph, serialization
- Platform/    → OS‐binding (Linux Window/Input) and graphics backends (OpenGL)
- Debug/       → Instrumentor for profiling
- Foundry/ and Sandbox/ link against Ember as a static/shared library.

##### README for additional insights
- Confirms current focus (OpenGL, 2D, ECS, UI), upcoming modules (Vulkan/API, visual scripting).
- Build script arguments choose engine vs. sandbox startup, debug vs. release, GPU support.

##### Detail without over-splitting
- Do not list every header; instead, show logical subsystems and their interconnections.
- Editor and Sandbox apps are shown as “clients” of the Engine library.

## Diagram (Mermaid)

```mermaid
graph TB

    subgraph "Engine Core Library"
        CoreSubsystem["Core (Application, Window, Input, Logger, Timer, LayerStack)"]:::engine
        EventsSubsystem["Events Subsystem"]:::engine
        MathLib["Math Library"]:::engine
        Renderer["Renderer Abstraction"]:::engine
        Scene["ECS/Scene Subsystem"]:::engine
        ImGui["ImGui Integration Layer"]:::engine
        Debug["Debug / Telemetry (Instrumentor)"]:::engine
    end

    subgraph "Platform Backends"
        OpenGLBackend["OpenGL Backend"]:::platform
        LinuxPlatform["Linux Platform Layer"]:::platform
    end

    subgraph "Applications"
        Editor["Editor (Foundry)"]:::editor
        SandboxApp["Sandbox Demo App"]:::sandbox
    end

    subgraph "Asset Stores"
        FoundryAssets["Foundry Assets (shaders, textures, scenes)"]:::editor
        SandboxAssets["Sandbox Assets (shaders, fonts, textures)"]:::sandbox
    end

    BuildTools["Build & Tooling Scripts"]:::external
    ExternalSystems["External OS & GPU Driver"]:::external

    %% Runtime Flows
    CoreSubsystem -->|"uses"| MathLib
    CoreSubsystem -->|"uses"| ImGui
    CoreSubsystem -->|"uses"| Debug

    CoreSubsystem -->|"initializes"| LinuxPlatform
    CoreSubsystem -->|"initializes"| OpenGLBackend

    LinuxPlatform -->|"OS events"| EventsSubsystem
    EventsSubsystem -->|"dispatch"| CoreSubsystem

    CoreSubsystem -->|"update/render"| Renderer
    Renderer -->|"RendererAPI calls"| OpenGLBackend
    OpenGLBackend -->|"GPU calls"| ExternalSystems
    LinuxPlatform -->|"system calls"| ExternalSystems

    Scene -->|"loads scenes"| FoundryAssets
    Scene -->|"loads assets"| SandboxAssets
    Scene -->|"populates ECS"| CoreSubsystem

    Debug -->|"telemetry data"| ExternalSystems

    Editor -->|"uses"| CoreSubsystem
    Editor -->|"hooks ImGuiLayer"| ImGui

    SandboxApp -->|"uses"| CoreSubsystem

    %% Build-time Dependencies
    Editor -.->|"links against"| CoreSubsystem
    SandboxApp -.->|"links against"| CoreSubsystem
    BuildTools -.-> Editor
    BuildTools -.-> SandboxApp
    BuildTools -.-> CoreSubsystem

    %% External system link
    ExternalSystems --- OpenGLBackend
    ExternalSystems --- LinuxPlatform

    %% Click Events
    click CoreSubsystem "https://github.com/embercraft/ember/tree/master/Ember/src/Ember/Core"
    click EventsSubsystem "https://github.com/embercraft/ember/tree/master/Ember/src/Ember/Events"
    click MathLib "https://github.com/embercraft/ember/tree/master/Ember/src/Ember/Math"
    click Renderer "https://github.com/embercraft/ember/tree/master/Ember/src/Ember/Renderer"
    click OpenGLBackend "https://github.com/embercraft/ember/tree/master/Ember/src/Platform/OpenGL"
    click LinuxPlatform "https://github.com/embercraft/ember/tree/master/Ember/src/Platform/Linux"
    click Scene "https://github.com/embercraft/ember/tree/master/Ember/src/Ember/Scene"
    click ImGui "https://github.com/embercraft/ember/tree/master/Ember/src/Ember/ImGui"
    click Debug "https://github.com/embercraft/ember/tree/master/Ember/src/Ember/Debug"
    click Editor "https://github.com/embercraft/ember/tree/master/Foundry/src"
    click SandboxApp "https://github.com/embercraft/ember/tree/master/Sandbox/src"
    click FoundryAssets "https://github.com/embercraft/ember/tree/master/Foundry/assets"
    click SandboxAssets "https://github.com/embercraft/ember/tree/master/Sandbox/assets"
    click BuildTools "https://github.com/embercraft/ember/tree/master/Scripts/"

    %% Styles
    classDef engine fill:#D6EAF8,stroke:#2980B9,color:#1B4F72
    classDef platform fill:#D5F5E3,stroke:#27AE60,color:#145A32
    classDef editor fill:#FDEBD0,stroke:#E67E22,color:#935116
    classDef sandbox fill:#EBDEF0,stroke:#8E44AD,color:#512E5F
    classDef external fill:#F2F4F4,stroke:#95A5A6,color:#566573
```
