# martijnhagenaars/lagged architecture

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

- Interactive diagram: https://gitdiagram.com/martijnhagenaars/lagged
- Repository: https://github.com/martijnhagenaars/lagged

## Overview

##### Project Type and Purpose
- LAGGED is a custom game engine and sample game project. Its purpose is to explore graphics and engine development. It is not a typical client-server or web stack, but a full C++ game engine with a modular architecture: engine core, ECS, editor tools, platform abstraction layer, platform-specific renderers, and a small sample game.

##### File Structure Analysis
- Top-level directories:
- External — third-party libraries (GLFW, GLEW, GLM, ImGui/ImGuizmo, FastNoise2, TinyGLTF, stb).
- LAGGED — the engine code itself, subdivided into Core, ECS, Editor, Platform (abstraction), Utility.
- Platforms — concrete backends (OpenGL in this repo; potentially DirectX, Vulkan later).
- Game — a minimal “hello world” that links against the engine to instantiate and drive a world.
- Solution and project files (.sln, .vcxproj) orchestrate builds for engine, backend, and game.

##### Key Components
a. External Libraries
b. Engine Core (LAGGED/src/Core)
- Subcomponents: ApplicationInterface, Engine, EntryPoint, IO (File I/O, watcher), Input, Resources (ResourceManager).
c. Entity–Component System (LAGGED/src/ECS)
- Components, Systems, Scene, Reflection, Views.
d. Editor Framework (LAGGED/src/Editor)
- UI helpers, Tools, ToolManager, Reflection widgets.
e. Platform Abstraction
- RenderBackend interface, Window interface, common utility types.
f. Platform Implementation (Platforms/OpenGL)
- GL_RenderBackend, GL_Window, GL_Resources (buffers, textures, shaders…), GL_Utility.
g. Sample Game (Game)
- Uses public engine API (Engine, World, Chunk), demonstrating engine usage.
h. Utility Modules
- Logging, Profiler, Timer, Noise, stb_image, tiny_gltf, StringUtility.

##### Relationships and Data Flow
- Game → Engine Core API → ECS / World / ApplicationInterface.
- Engine Core → Platform Abstraction → Platform Implementation (OpenGL).
- Engine Core / ECS / Editor → External libs (GLFW/GLEW for context/input, GLM for math, ImGui/ImGuizmo for UI, FastNoise2, TinyGLTF, stb_image for asset loading).
- ResourceManager → IO module → filesystem / watchers.
- Editor tools ↔ ECS (using Reflection) to inspect/modify scene.

##### Architectural Patterns & Principles
- Entity-Component System to decouple data (components) from logic (systems).
- Abstraction layer (RenderBackend, Window) to support multiple graphics APIs.
- Modular external library integration via includes and libs under External/.
- Separation of concerns: Core <→ ECS <→ Editor <→ Platform <→ Game.
- Resource Manager centralizes asset loading and caching.
- Reflection subsystem supports Editor integration at runtime.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Game Layer
    subgraph "Sample Game" 
        direction TB
        GameApp["Game Application"]:::game
        WorldModule["World / Chunk"]:::game
    end

    %% Engine Layer
    subgraph "Engine Modules"
        direction TB

        subgraph Core
            direction TB
            AppInterface["ApplicationInterface"]:::engine
            EngineCore["Engine"]:::engine
            EntryPoint["EntryPoint"]:::engine
            IO["IO (File I/O & Watcher)"]:::engine
            InputMod["Input"]:::engine
            ResourcesMod["ResourceManager"]:::engine
        end

        subgraph ECS
            direction TB
            Components["Components"]:::engine
            Systems["Systems"]:::engine
            SceneMod["Scene"]:::engine
            Reflection["Reflection"]:::engine
            Views["Views"]:::engine
        end

        subgraph Editor
            direction TB
            ToolsCore["ToolManager & ToolBase"]:::engine
            Tools["Editor Tools"]:::engine
            UIHelpers["UI Helpers"]:::engine
            RefWidgets["Reflection Widgets"]:::engine
        end

        subgraph Utility
            direction TB
            Logger["Logging"]:::engine
            Profiler["Profiler"]:::engine
            TimerMod["Timer"]:::engine
            NoiseMod["Noise"]:::engine
            StbLoader["stb_image Loader"]:::engine
            GltfLoader["TinyGLTF Loader"]:::engine
            StrUtil["StringUtility & Hash"]:::engine
            Natvis["Natvis Visualizers"]:::engine
        end
    end

    %% Platform Abstraction
    subgraph "Platform Abstraction"
        direction TB
        RenderBackend["RenderBackend Interface"]:::platform
        WindowIface["Window Interface"]:::platform
        PlatDefines["Defines & Includes"]:::platform
        PlatResHeaders["Shared Resources Headers"]:::platform
    end

    %% Platform Implementation
    subgraph "Platforms/OpenGL"
        direction TB
        GLBackend["GL_RenderBackend & GL_Window"]:::platform
        GLResources["GL Resources (Buffers, Textures, Shaders…)"]:::platform
        GLUtil["GL Utility"]:::platform
    end

    %% External Libraries
    ExternalLibs["External Libraries"]:::external

    %% Relationships
    GameApp -->|"uses Engine API"| AppInterface
    GameApp -->|drives| WorldModule
    WorldModule -->|updates| SceneMod

    AppInterface -->|initializes| EngineCore
    EntryPoint -->|boots| EngineCore
    EngineCore -->|manages| IO
    EngineCore -->|manages| InputMod
    EngineCore -->|manages| ResourcesMod
    EngineCore -->|hosts ECS & Editor| Components
    Components -->|defines data| Systems
    Systems -->|updates| SceneMod
    SceneMod -->|provides data| GLBackend
    Reflection -->|enables| Editor
    UIHelpers -->|builds UI| RefWidgets
    ToolsCore -->|manages| Tools
    Tools -->|inspects/modifies| Components

    ResourcesMod -->|loads assets via| IO
    IO -->|reads files| ExternalLibs
    GLBackend -->|renders| GLResources
    GLBackend -->|uses| RenderBackend
    RenderBackend -->|abstracts to| GLBackend
    WindowIface -->|abstracts to| GLBackend
    EngineCore -->|uses| PlatDefines
    EngineCore -->|uses| PlatResHeaders

    EngineCore -->|uses| ExternalLibs
    Components -->|uses| ExternalLibs
    Systems -->|uses| ExternalLibs
    Editor -->|uses| ExternalLibs

    %% Click Events
    click ExternalLibs "https://github.com/martijnhagenaars/lagged/tree/main/External/"
    click AppInterface "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/Core/ApplicationInterface.h"
    click EngineCore "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/Core/Engine.cpp"
    click EntryPoint "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/Core/EntryPoint.h"
    click IO "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/Core/IO/FileIO.cpp"
    click IO "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/Core/IO/FileWatch.cpp"
    click InputMod "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/Core/Input/Input.cpp"
    click ResourcesMod "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/Core/Resources/ResourceManager.cpp"
    click Components "https://github.com/martijnhagenaars/lagged/tree/main/LAGGED/src/ECS/Components/"
    click Systems "https://github.com/martijnhagenaars/lagged/tree/main/LAGGED/src/ECS/Systems/"
    click SceneMod "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/ECS/Scene.cpp"
    click Reflection "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/ECS/Reflection/SceneReflect.cpp"
    click Views "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/ECS/Views.cpp"
    click ToolsCore "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/Editor/ToolsManager.cpp"
    click Tools "https://github.com/martijnhagenaars/lagged/tree/main/LAGGED/src/Editor/Tools/"
    click UIHelpers "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/Editor/UI/EditorGuiHelper.cpp"
    click RefWidgets "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/Editor/Reflection/EditorTypesReflectionWidgets.h"
    click RenderBackend "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/Platform/RenderBackend.h"
    click WindowIface "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/Platform/Window.cpp"
    click PlatDefines "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/Platform/Defines.h"
    click PlatResHeaders "https://github.com/martijnhagenaars/lagged/tree/main/LAGGED/src/Platform/Resources/"
    click GLBackend "https://github.com/martijnhagenaars/lagged/blob/main/Platforms/OpenGL/src/GL_RenderBackend.cpp"
    click GLResources "https://github.com/martijnhagenaars/lagged/blob/main/Platforms/OpenGL/src/Resources/GL_Mesh.cpp"
    click GLUtil "https://github.com/martijnhagenaars/lagged/blob/main/Platforms/OpenGL/src/Utility/GL_DebugLine.cpp"
    click GameApp "https://github.com/martijnhagenaars/lagged/blob/main/Game/src/Game.cpp"
    click WorldModule "https://github.com/martijnhagenaars/lagged/blob/main/Game/src/World/World.cpp"
    click Logger "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/Utility/Logger.cpp"
    click Profiler "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/Utility/Profiler.cpp"
    click TimerMod "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/Utility/Timer.cpp"
    click NoiseMod "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/Utility/Noise.cpp"
    click StbLoader "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/Utility/stb_image.cpp"
    click GltfLoader "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/Utility/tiny_gltf.cpp"
    click StrUtil "https://github.com/martijnhagenaars/lagged/blob/main/LAGGED/src/Utility/StringUtility.h"
    click Natvis "https://github.com/martijnhagenaars/lagged/tree/main/LAGGED/src/Utility/Natvis/"

    %% Styles
    classDef game fill:#ffe4b5,stroke:#cc7a00
    classDef engine fill:#b2ffc2,stroke:#339933
    classDef platform fill:#c2d4ff,stroke:#3366cc
    classDef external fill:#ffcccc,stroke:#cc3333
    class GameApp,WorldModule game
    class AppInterface,EngineCore,EntryPoint,IO,InputMod,ResourcesMod,Components,Systems,SceneMod,Reflection,Views,ToolsCore,Tools,UIHelpers,RefWidgets,Logger,Profiler,TimerMod,NoiseMod,StbLoader,GltfLoader,StrUtil,Natvis engine
    class RenderBackend,WindowIface,PlatDefines,PlatResHeaders,GLBackend,GLResources,GLUtil platform
    class ExternalLibs external
```
