# nexoengine/game-engine architecture

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

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

## Overview

##### Project Type and Purpose
- Type: A C++ desktop & VR game engine with an integrated scene editor.
- Purpose: Provide a modular, high-performance platform for game development (runtime engine) and a WYSIWYG editor (UX/UI layer).

##### File Structure
Top‐level directories:
- common: Shared utilities (logging, exceptions, math).
- engine: Core runtime (ECS, events, rendering, asset management).
- editor: UI application (ImGui-based windows, docking, document windows).
- external: Third-party libs/submodules (ImGui port, stb_image).
- scripts: Build/packaging (CMake/CPack for Windows NSIS & Linux DEB).
- examples & tests: Sample usages and unit tests (gtest).

##### Extract Insights from README
- Build system: CMake with presets, vcpkg integration.
- Targets: nexoEditor (GUI), engine library, tests.
- Dependencies: CMake, C++17+, OpenGL, ImGui, JSON.hpp, stb_image, gtest.

##### Main Components & Their Relationships
a. Components
– Editor Application
- UI Layer (ImGuiBackend → Editor windows & widgets)
- Document Windows (Scene, Assets, Inspector)
– Engine Library
- Core/Event Subsystem (event dispatch, input, window events)
- ECS Subsystem (Entities, Components, Systems, Coordinator)
- Rendering Subsystem
- Renderer API (abstraction) → OpenGLBackend
- Resources: Shaders, Textures, Buffers, Framebuffers
- Asset Management
- AssetImporter, Catalog, Context
- Factory Modules (CameraFactory, EntityFactory2D/3D, LightFactory)
- Component Definitions (Transform, Render2D/3D, Light, Camera)
– Common Utilities (Logger, Exception, Timer, Math)
– External Dependencies
- ImGui, stb_image, JSON.hpp, OpenGL drivers
– Resources (models, textures, shaders)
– Build & Packaging (CMake scripts, CPack)
– Tests & Examples

b. Interactions
1. User → Editor UI → ImGuiBackend
2. Editor → Engine API calls
3. Engine uses Common utilities for logging, timing, math
4. Engine’s Core Event subsystem propagates input/window events to ECS and UI
5. ECS orchestrates Systems; RenderSystem issues RenderCommands to Renderer API
6. Renderer API → OpenGLBackend → GPU via OS window context
7. AssetImporter loads resources from disk (resources/) into AssetCatalog for runtime
8. Build scripts compile modules, link dependencies, produce binaries and installers

##### Architectural Patterns & Technologies
- Layered Modular Architecture: UI (editor) vs. Core (engine) vs. Utilities vs. External libs
- ECS Pattern: decouples data (Components) from logic (Systems)
- Factory Pattern: centralized creation of cameras, lights, entities
- Adapter Pattern: RendererAPI abstracts OpenGL backend
- Publisher/Subscriber: event system (Signals, Listeners)
- Build/CI: CMake presets, vcpkg, GitHub Actions, CodeQL, Doxygen

##### Capturing Essential Details
- Be exhaustive: include even small modules (e.g., backends/opengl, utils/String).
- Separation of concerns (UI vs. engine logic vs. low-level APIs).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Editor Layer
    subgraph "Editor Application"
        EditorApp["Editor Application"]:::editor
        UILayer["UI Layer (ImGuiBackend)"]:::editor
        DocumentWindows["Document Windows"]:::editor
    end

    %% Engine Core
    subgraph "Engine Library"
        Events["Core Event Subsystem"]:::engine
        ECS["ECS Subsystem"]:::engine
        Rendering["Rendering Subsystem"]:::engine
        RendererAPI["Renderer API & Adapter"]:::engine
        Assets["Asset Management"]:::engine
        Factories["Factory Modules"]:::engine
        ComponentsDef["Component Definitions"]:::engine
    end

    %% Utilities and externals
    subgraph "Common Utilities"
        Common["Common Utilities"]:::common
    end

    subgraph "External Dependencies"
        External["External Dependencies"]:::external
    end

    %% Resources and scripts
    subgraph "Resources"
        Resources["Resources"]:::resources
    end

    subgraph "Build & Packaging"
        Build["Build & Packaging"]:::scripts
    end

    subgraph "Tests & Examples"
        Tests["Tests & Examples"]:::tests
    end

    %% Interactions
    EditorApp -->|"uses UI"| UILayer
    EditorApp -->|"opens windows"| DocumentWindows
    EditorApp -->|"calls Engine API"| Events
    UILayer -->|"dispatchInput()"| Events
    Events -->|"dispatchEvent()"| ECS
    ECS -->|"update() triggers RenderSystem"| Rendering
    Rendering -->|"render()"| RendererAPI
    RendererAPI -->|"OpenGL calls"| External
    EditorApp -->|"importAsset()"| Assets
    Assets -->|"provide resources"| Rendering
    ECS -->|"uses Components"| ComponentsDef
    ECS -->|"factory create()"| Factories
    Events -->|"logs/timing"| Common
    RendererAPI -->|"math ops"| Common
    Assets -->|"path utils"| Common
    Build -->|"builds"| EditorApp
    Build -->|"builds"| Events
    Build -->|"builds"| ECS
    Build -->|"builds"| Rendering
    Tests -->|"tests"| Events
    Tests -->|"tests"| ECS
    Tests -->|"tests"| Rendering

    %% Click events
    click EditorApp "https://github.com/nexoengine/game-engine/blob/main/editor/main.cpp"
    click EditorApp "https://github.com/nexoengine/game-engine/blob/main/editor/src/Editor.cpp"
    click EditorApp "https://github.com/nexoengine/game-engine/blob/main/editor/src/Editor.hpp"
    click UILayer "https://github.com/nexoengine/game-engine/blob/main/editor/src/backends/ImGuiBackend.cpp"
    click UILayer "https://github.com/nexoengine/game-engine/blob/main/editor/src/backends/ImGuiBackend.hpp"
    click UILayer "https://github.com/nexoengine/game-engine/blob/main/editor/src/backends/opengl/openglImGuiBackend.cpp"
    click UILayer "https://github.com/nexoengine/game-engine/blob/main/editor/src/backends/opengl/openglImGuiBackend.hpp"
    click DocumentWindows "https://github.com/nexoengine/game-engine/tree/main/editor/src/DocumentWindows/"
    click Events "https://github.com/nexoengine/game-engine/tree/main/engine/src/core/event/"
    click ECS "https://github.com/nexoengine/game-engine/blob/main/engine/src/ecs/Coordinator.cpp"
    click Rendering "https://github.com/nexoengine/game-engine/blob/main/engine/src/renderer/Renderer.cpp"
    click RendererAPI "https://github.com/nexoengine/game-engine/blob/main/engine/src/renderer/RendererAPI.cpp"
    click Assets "https://github.com/nexoengine/game-engine/blob/main/engine/src/assets/AssetImporter.cpp"
    click Factories "https://github.com/nexoengine/game-engine/blob/main/engine/src/CameraFactory.cpp"
    click ComponentsDef "https://github.com/nexoengine/game-engine/blob/main/engine/src/components/Transform.hpp"
    click Common "https://github.com/nexoengine/game-engine/blob/main/common/Logger.hpp"
    click External "https://github.com/nexoengine/game-engine/tree/main/external/vcpkg-ports/imgui"
    click Resources "https://github.com/nexoengine/game-engine/tree/main/resources/shaders/"
    click Build "https://github.com/nexoengine/game-engine/blob/main/CMakeLists.txt"
    click Tests "https://github.com/nexoengine/game-engine/tree/main/tests/common/"

    %% Styles
    classDef editor fill:#cfe2ff,stroke:#4a7ebb,color:#000;
    classDef engine fill:#d4edda,stroke:#256029,color:#000;
    classDef common fill:#fff3cd,stroke:#665c00,color:#000;
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#000;
    classDef resources fill:#ffe5b4,stroke:#cc8400,color:#000;
    classDef scripts fill:#ffe5b4,stroke:#cc8400,color:#000;
    classDef tests fill:#f8d7da,stroke:#842029,color:#000;
```
