# alexiynew/engine_v2 architecture

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

- Interactive diagram: https://gitdiagram.com/alexiynew/engine_v2
- Repository: https://github.com/alexiynew/engine_v2

## Overview

##### Project type and purpose
- This is a C++ “modular” game engine, built with CMake, that provides a core API (Engine Core) and a set of pluggable modules (backend, graphics, input, resource management). A small “game” in the top-level game/ directory demonstrates how to use the engine.

##### File structure
Top level:
- engine/        ← engine source, headers, modules, tests, CMake files
- game/          ← sample game, assets, shaders, CMake
- CMakeLists.txt, presets, .clang-format, .gitignore, LICENSE, etc.
Under engine/:
- /engine      ← public engine API (Engine, Game, Events, Graphics, Input, ResourceManager interfaces)
- src/                ← engine implementation (engine_impl, event_system, renderer_impl, resource_manager_impl)
- modules/            ← module definitions and implementations
– backend/glfw      ← real window/input backend
– backend/stub      ← fallback stub backend
– graphics/opengl   ← real OpenGL renderer, texture, shader, mesh implementations
– graphics/stub     ← stub graphics
– include/modules   ← module interfaces & module‐locator
- entry_point/        ← small “main” that bootstraps the engine
- tests/              ← unit tests for engine_impl, events, etc.
- third_party/        ← external CMake wrappers (glm, gtest)

##### README
- The README simply states “Game engine.” It implies the project’s purpose is to provide a reusable engine core plus modules to build games.

##### Components
a. Main components
- Engine Core
– EntryPoint
– Engine (engine_impl)
– Event System
– Resource Manager
– Renderer (abstract)
– Module Locator
- Modules
– Backend Module (GLFW or Stub)
– Graphics Module (OpenGL or Stub)
– Input, Resource Loader modules
- Game Layer
– Game code (game_create, game.cpp)
– Assets (models, shaders)
- Third-Party Libraries
– GLFW, Glad, GLM, GTest
- Build System
– CMake entry points and presets

b. Relationships & interactions
- EntryPoint → Engine Core: initialization
- Engine Core ↔ Module Locator: discovers & loads backend/graphics modules
- Engine Core → Backend Module: window management & input events
- Backend Module → Engine Event System: injects input/window events
- Engine Core → Graphics Module: render commands
- Graphics Module → ResourceManager: loads shaders, meshes, textures
- ResourceManager → file system / third-party loaders
- Game Layer → Engine Core: calls start/update/render via Engine API
- Engine Core → Game Layer: event callbacks (e.g. OnUpdate, OnRender)

c. Architectural patterns & design principles
- Modular architecture with module-locator (dependency injection-like)
- Separation of interface (include/) vs implementation (src/)
- Pluggable backends & graphics implementations (stub vs real)
- Clear layering: Core → Modules → Third-Party

d. Key technologies/frameworks
- CMake for build configuration & cross-platform builds
- GLFW for windowing & input
- OpenGL via Glad for rendering
- GLM for math types
- GTest for unit tests

##### Detail
- Every major header folder as a component: Events, Graphics, Input, Resource Management
- That there are two implementations (stub vs real) for backend and graphics

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Game Layer
    subgraph "Game Layer"
        Game["Game Layer"]:::game
    end

    %% Engine Core
    subgraph "Engine Core"
        EntryPoint["EntryPoint"]:::core
        EngineCore["Engine Core"]:::core
        EventSystem["Event System"]:::core
        ResourceManager["Resource Manager"]:::core
        RendererAbstract["Renderer (Abstract)"]:::core
        ModuleLocator["Module Locator"]:::core
    end

    %% Modules
    subgraph "Modules"
        subgraph "Backend Modules"
            BackendGLFW["Backend Module (GLFW)"]:::module
            BackendStub["Backend Module (Stub)"]:::module
        end
        subgraph "Graphics Modules"
            GraphicsOpenGL["Graphics Module (OpenGL)"]:::module
            GraphicsStub["Graphics Module (Stub)"]:::module
        end
        ModuleInterfaces["Module Interfaces"]:::module
    end

    %% Third-Party
    subgraph "Third-Party Libraries"
        GLM["GLM"]:::third
        GTest["GTest"]:::third
        Glad["Glad"]:::third
    end

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

    %% Relationships
    Game -->|"calls start/update/render"| EngineCore
    EngineCore -->|"initializes"| EntryPoint
    EngineCore -->|"uses"| ModuleLocator
    ModuleLocator -->|"discovers"| BackendGLFW
    ModuleLocator -->|"discovers"| BackendStub
    ModuleLocator -->|"discovers"| GraphicsOpenGL
    ModuleLocator -->|"discovers"| GraphicsStub
    EngineCore -->|"calls window/input"| BackendGLFW
    EngineCore -->|"calls window/input"| BackendStub
    BackendGLFW -->|"injects events"| EventSystem
    BackendStub -->|"injects events"| EventSystem
    EngineCore -->|"issues render commands"| GraphicsOpenGL
    EngineCore -->|"issues render commands"| GraphicsStub
    GraphicsOpenGL -->|"loads shaders/meshes/textures"| ResourceManager
    GraphicsStub -->|"loads shaders/meshes/textures"| ResourceManager
    ResourceManager -->|"uses loaders"| GLM
    GraphicsOpenGL -->|"uses loaders"| Glad
    CMake -.->|builds| EntryPoint
    CMake -.->|builds| EngineCore
    CMake -.->|builds| BackendGLFW
    CMake -.->|builds| BackendStub
    CMake -.->|builds| GraphicsOpenGL
    CMake -.->|builds| GraphicsStub
    CMake -.->|configures| GLM
    CMake -.->|configures| GTest
    CMake -.->|configures| Glad

    %% Click Events
    click EntryPoint "https://github.com/alexiynew/engine_v2/blob/main/engine/entry_point/src/entry_point.cpp"
    click EngineCore "https://github.com/alexiynew/engine_v2/blob/main/engine/src/engine_impl.cpp"
    click EngineCore "https://github.com/alexiynew/engine_v2/blob/main/engine/src/engine_impl.hpp"
    click EngineCore "https://github.com/alexiynew/engine_v2/blob/main/engine/include/engine/engine.hpp"
    click EventSystem "https://github.com/alexiynew/engine_v2/blob/main/engine/src/events/event_system.cpp"
    click EventSystem "https://github.com/alexiynew/engine_v2/blob/main/engine/include/engine/events/event_system.hpp"
    click ResourceManager "https://github.com/alexiynew/engine_v2/blob/main/engine/src/resource_management/resource_manager_impl.cpp"
    click ResourceManager "https://github.com/alexiynew/engine_v2/blob/main/engine/src/resource_management/resource_manager_impl.hpp"
    click ResourceManager "https://github.com/alexiynew/engine_v2/blob/main/engine/include/engine/resource_management/resource_manager.hpp"
    click RendererAbstract "https://github.com/alexiynew/engine_v2/blob/main/engine/include/engine/graphics/renderer.hpp"
    click ModuleLocator "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/include/modules/module_locator.hpp"
    click BackendGLFW "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/backend/glfw/src/glfw_backend.cpp"
    click BackendGLFW "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/backend/glfw/src/glfw_backend.hpp"
    click BackendGLFW "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/backend/glfw/src/backend_create.cpp"
    click BackendStub "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/backend/stub/src/stub_backend.cpp"
    click BackendStub "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/backend/stub/src/stub_backend.hpp"
    click BackendStub "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/backend/stub/src/backend_create.cpp"
    click GraphicsOpenGL "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/graphics/opengl/src/opengl_renderer.cpp"
    click GraphicsOpenGL "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/graphics/opengl/src/opengl_renderer.hpp"
    click GraphicsOpenGL "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/graphics/opengl/src/graphics_create.cpp"
    click GraphicsOpenGL "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/graphics/opengl/src/opengl_shader.cpp"
    click GraphicsOpenGL "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/graphics/opengl/src/opengl_shader.hpp"
    click GraphicsOpenGL "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/graphics/opengl/src/opengl_mesh.cpp"
    click GraphicsOpenGL "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/graphics/opengl/src/opengl_mesh.hpp"
    click GraphicsOpenGL "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/graphics/opengl/src/opengl_texture.cpp"
    click GraphicsOpenGL "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/graphics/opengl/src/opengl_texture.hpp"
    click GraphicsStub "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/graphics/stub/src/stub_renderer.cpp"
    click GraphicsStub "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/graphics/stub/src/stub_renderer.hpp"
    click GraphicsStub "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/graphics/stub/src/graphics_create.cpp"
    click ModuleInterfaces "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/include/modules/backend/backend_module.hpp"
    click ModuleInterfaces "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/include/modules/graphics/renderer_module.hpp"
    click ModuleInterfaces "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/include/modules/input_handler.hpp"
    click Game "https://github.com/alexiynew/engine_v2/blob/main/game/src/game.cpp"
    click Game "https://github.com/alexiynew/engine_v2/blob/main/game/src/game.hpp"
    click Game "https://github.com/alexiynew/engine_v2/blob/main/game/src/game_create.cpp"
    click Game "https://github.com/alexiynew/engine_v2/blob/main/game/data/3d/cube.obj"
    click Game "https://github.com/alexiynew/engine_v2/blob/main/game/data/3d/cube.mtl"
    click Game "https://github.com/alexiynew/engine_v2/blob/main/game/data/shaders/simple.vert"
    click Game "https://github.com/alexiynew/engine_v2/blob/main/game/data/shaders/simple.frag"
    click GLM "https://github.com/alexiynew/engine_v2/blob/main/engine/third_party/glm.cmake"
    click GTest "https://github.com/alexiynew/engine_v2/blob/main/engine/third_party/gtest.cmake"
    click Glad "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/graphics/opengl/third_party/glad/include/glad/glad.h"
    click CMake "https://github.com/alexiynew/engine_v2/blob/main/CMakeLists.txt"
    click CMake "https://github.com/alexiynew/engine_v2/blob/main/engine/CMakeLists.txt"
    click CMake "https://github.com/alexiynew/engine_v2/blob/main/engine/modules/CMakeLists.txt"
    click CMake "https://github.com/alexiynew/engine_v2/blob/main/CMakePresets.json"
    click CMake "https://github.com/alexiynew/engine_v2/blob/main/engine/CMakePresets.json"

    %% Styles
    classDef core fill:#D0E8FF,stroke:#007ACC,color:#000
    classDef module fill:#DFF2BF,stroke:#4F8A10,color:#000
    classDef third fill:#F0F0F0,stroke:#666,color:#000
    classDef game fill:#FFE4B5,stroke:#CC5500,color:#000
    classDef build fill:#FFFACD,stroke:#CCCC00,color:#000
```
