# burned-games/coffee-engine architecture

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

- Interactive diagram: https://gitdiagram.com/burned-games/coffee-engine
- Repository: https://github.com/burned-games/coffee-engine

## Overview

Based on our analysis, Coffee Engine is a cross-platform 3D game engine written in C++ that uses OpenGL and SDL3. This project isn’t just a runtime library—there is an editor (CoffeeEditor), the engine core (CoffeeEngine), a runtime application (Runtime), and even a sandbox example (Sandbox) to showcase or test functionality. In addition, the engine supports a modular design (with subsystems for rendering, physics, audio, scripting, input, etc.) and contains clear separation between platform-specific code (in the Platform folder) and platform-independent core logic.

##### Main Components
a. CoffeeEngine (Core Engine)
- Contains the most critical subsystems:
– Core (Application, Logging, Window, Input, Data Structures, etc.)
– Renderer (OpenGL-based rendering, shader management, textures, materials, 2D/3D rendering)
– Audio subsystem (Audio, AudioFootsteps, AudioZone, etc.)
– Physics (CollisionSystem, RigidBody, PhysicsWorld, etc.)
– Scene Management (Scene, SceneTree, ECS, Entity-Component system)
– Scripting (Lua and C# backends)
– IO and Resource Handling (ResourceLoader, ResourceRegistry, ImportData, Serialization)
– Animation and Particle systems
– Platform abstraction (Linux and Windows specific implementations)
b. CoffeeEditor (Editor Application)
- Built on top of CoffeeEngine for interactive scene and project management.
c. Runtime and Sandbox
- CoffeeRuntimeApp and SandboxApp provide examples or testbeds for executing built projects.
- Sandbox is a simple demonstration app that shows how to use the engine’s features and assets.

##### Relationships and Interactions
- The Engine Core (CoffeeEngine) acts as a set of libraries and subsystems that encapsulate most of the engine functionality. It interacts with:
- The Editor (CoffeeEditor) for building and modifying scenes, resources, and game logic.
- The Runtime and Sandbox, which use the Engine Core to run end-user applications.
- Subsystems within CoffeeEngine are interconnected. For example:
- The Audio subsystem and Engine Input capture user interactions and events.
- The Scripting system hooks into the Engine to allow game logic injection.
- IO modules manage asset loading for both runtime and editor scenarios.
- External libraries (SDL3, GLM, Assimp, spdlog, etc.) support lower-level functionality (logging, math, asset importing, UI with ImGui).

##### Architectural Patterns and Principles
- Modular design: Separate modules (rendering, audio, physics, etc.) reside in their own folders within CoffeeEngine, making it easier to update or extend individual systems.
- MVC-like separation in the Editor: The editor’s panel structure represents the view layer while connecting to engine “models” (the scene, assets, etc.).
- Abstraction layers for platform independence: The Engine has a dedicated Platform folder, encapsulating Windows and Linux specifics.
- Data-driven systems for resource management (import/saver/registry in IO) and scene management (ECS, scene tree).

- Clear labels for each main component (like “Renderer”, “Physics”, “Audio”, etc.).
- A note on build configuration and deployment (the presence of CMakeLists.txt at various levels and vcpkg integration for dependencies).

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "CoffeeEngine"
        CE_Core["Core Subsystems"]:::engine
        CE_Renderer["Renderer"]:::engine
        CE_Audio["Audio Subsystem"]:::engine
        CE_Physics["Physics"]:::engine
        CE_Scene["Scene Management"]:::engine
        CE_Scripting["Scripting"]:::engine
        CE_IO["IO & Resource Handling"]:::engine
        CE_Animation["Animation"]:::engine
        CE_Particle["Particle System"]:::engine
        CE_Platform["Platform Abstraction"]:::engine
    end

    subgraph "CoffeeEditor"
        Editor_Source["Editor Source Code"]:::editor
        Editor_Panels["Editor Panels"]:::editor
    end

    subgraph "Applications"
        Runtime_Source["Runtime Application Source"]:::app
        Sandbox_Source["Sandbox Application Source"]:::app
    end

    subgraph "External Libraries"
        SDL3["SDL3"]:::external
        GLM["GLM"]:::external
        Assimp["Assimp"]:::external
        Spdlog["spdlog"]:::external
        ImGui["ImGui"]:::external
    end

    Build["CMake (Build System)"]:::build

    %% Relationships between main components
    Editor_Source -->|"uses"| CE_Core
    Editor_Panels -->|"visualizes"| CE_Scene
    Runtime_Source -->|"executes using"| CE_Core
    Sandbox_Source -->|"demonstrates"| CE_Core

    %% Relationships within CoffeeEngine subsystems
    CE_Core -->|"initializes"| CE_Renderer
    CE_Core -->|"initializes"| CE_Audio
    CE_Core -->|"initializes"| CE_Physics
    CE_Core -->|"initializes"| CE_Scene
    CE_Core -->|"initializes"| CE_Scripting
    CE_Core -->|"initializes"| CE_IO
    CE_Core -->|"initializes"| CE_Animation
    CE_Core -->|"initializes"| CE_Particle
    CE_Core -->|"interfaces"| CE_Platform
    CE_Scene -->|"supplies data to"| CE_Renderer
    CE_Scripting -->|"hooks into"| CE_Core
    CE_IO -->|"feeds assets to"| CE_Renderer

    %% External libraries dependencies
    SDL3 ---|"supports"| CE_Platform
    GLM ---|"aids"| CE_Renderer
    Assimp ---|"assists"| CE_IO
    Spdlog ---|"logs for"| CE_Core
    ImGui ---|"enhances"| Editor_Panels

    %% Build system connections
    Build ---|"builds"| CE_Core
    Build ---|"builds"| Editor_Source
    Build ---|"builds"| Runtime_Source
    Build ---|"builds"| Sandbox_Source

    %% Click events for CoffeeEngine components
    click CE_Core "https://github.com/burned-games/coffee-engine/tree/main/CoffeeEngine/src/CoffeeEngine/Core"
    click CE_Renderer "https://github.com/burned-games/coffee-engine/tree/main/CoffeeEngine/src/CoffeeEngine/Renderer"
    click CE_Audio "https://github.com/burned-games/coffee-engine/tree/main/CoffeeEngine/src/CoffeeEngine/Audio"
    click CE_Physics "https://github.com/burned-games/coffee-engine/tree/main/CoffeeEngine/src/CoffeeEngine/Physics"
    click CE_Scene "https://github.com/burned-games/coffee-engine/tree/main/CoffeeEngine/src/CoffeeEngine/Scene"
    click CE_Scripting "https://github.com/burned-games/coffee-engine/tree/main/CoffeeEngine/src/CoffeeEngine/Scripting"
    click CE_IO "https://github.com/burned-games/coffee-engine/tree/main/CoffeeEngine/src/CoffeeEngine/IO"
    click CE_Animation "https://github.com/burned-games/coffee-engine/tree/main/CoffeeEngine/src/CoffeeEngine/Animation"
    click CE_Particle "https://github.com/burned-games/coffee-engine/tree/main/CoffeeEngine/src/CoffeeEngine/ParticleManager"
    click CE_Platform "https://github.com/burned-games/coffee-engine/tree/main/CoffeeEngine/src/Platform"

    %% Click events for CoffeeEditor components
    click Editor_Source "https://github.com/burned-games/coffee-engine/tree/main/CoffeeEditor/src"
    click Editor_Panels "https://github.com/burned-games/coffee-engine/tree/main/CoffeeEditor/Panels"

    %% Click events for Runtime and Sandbox components
    click Runtime_Source "https://github.com/burned-games/coffee-engine/tree/main/Runtime/src"
    click Sandbox_Source "https://github.com/burned-games/coffee-engine/tree/main/Sandbox/src"

    %% Styles
    classDef engine fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef editor fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef app fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef external fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef build fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
