# luiscrespo-bot/antigravity-game-engine architecture

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

- Interactive diagram: https://gitdiagram.com/luiscrespo-bot/antigravity-game-engine
- Repository: https://github.com/luiscrespo-bot/antigravity-game-engine

## Overview

1. **Top-level shape**
   - This repo is split into two clear layers: `engine/` is the reusable runtime library, and `game/` is the client application entry point.
   - The architecture is intentionally modular: each subsystem lives in its own module and communicates through engine-level interfaces rather than directly through the game code.

2. **Bootstrapping and lifetime**
   - `game/src/main.cpp` is the application entry.
   - It likely constructs or invokes the engine `Application` layer, which owns the main loop and coordinates startup/shutdown of the other systems.
   - The engine’s lifetime boundary is centered around the `Application` class and the `Window`/graphics context it manages.

3. **Core runtime**
   - The `core` module provides the engine’s foundational services: `Application`, `Window`, `Input`, `Log`, `Timestep`, and `ResourceManager`.
   - `Timestep` indicates a fixed/variable update model.
   - `Input` is a static-style facade over GLFW-style input handling, so gameplay and tools can query input without depending on windowing details.
   - `ResourceManager` is the central asset boundary to avoid duplicated loads and to share resources across renderer, scene, and gameplay systems.

4. **Rendering stack**
   - The `renderer` module contains the OpenGL rendering pipeline and its abstractions: `GraphicsContext`, `OpenGLContext`, `Shader`/`OpenGLShader`, `Framebuffer`, `Mesh`, `Model`, `Camera`, `PerspectiveCamera`, `Light`, `Material`, and `Renderer`.
   - Data flow is: scene/game objects provide renderable meshes/materials and camera state, then `Renderer` turns that into OpenGL draw calls.
   - `Framebuffer` suggests offscreen passes such as shadow maps or render targets.
   - `Model` and `Mesh` indicate imported asset rendering, with `Assimp` handling external model formats.

5. **Scene and entity organization**
   - `scene` contains `Scene` and `SceneManager`, which act as the boundary between engine systems and actual world content.
   - `entity/Entity.h` implies the world is entity-centric, with entities being the common unit passed to physics, scripting, UI inspection, and rendering.
   - The scene layer is where engine systems are coordinated per world or level.

6. **Physics**
   - `physics/PhysicsSystem` is a separate subsystem, suggesting simulation is not embedded inside rendering or scene code.
   - It likely consumes entity transform/collision data from the scene and writes back updated positions or collision state.
   - This keeps simulation independent from frame rendering, which matters for fixed-step updates.

7. **Scripting**
   - `scripting/ScriptSystem` is the Lua integration point, backed by `sol2` per the README.
   - Its role is to attach behavior to entities without recompiling C++, so gameplay logic can be extended dynamically.
   - The script system likely bridges engine objects into Lua and is another consumer/producer of entity state.

8. **UI and editor tooling**
   - `ui/UISystem` wraps Dear ImGui and provides in-engine tooling such as inspectors, light editors, and debug panels.
   - UI is an overlay system: it reads engine state, but should not own it.
   - The README’s docking/viewports support implies the UI runs as an editor-like layer on top of the main rendered scene.

9. **Audio**
   - `audio/AudioSystem` is isolated from rendering and scene management, using `miniaudio` for playback.
   - Its separation indicates audio is treated as its own runtime service rather than as part of gameplay logic or UI.
   - In practice, it likely consumes events or entity-related triggers from the scene/game layer.

10. **Platform and graphics dependencies**
   - The architecture is anchored on C++20, CMake, GLFW, GLAD, GLM, OpenGL 4.1, ImGui, Lua 5.4, sol2, miniaudio, Assimp, and spdlog.
   - GLFW/GLAD/OpenGL define the runtime graphics boundary; GLM provides math types used across camera, renderer, and physics.
   - spdlog is the shared observability layer for the whole engine.

11. **Subsystem interaction pattern**
   - The engine is organized as a set of independent services updated from the main loop: input, scripting, physics, audio, scene updates, UI, and rendering.
   - The main directional flow is from application startup → scene/world state update → render/audio/UI output.
   - Cross-system coupling is minimized by using engine abstractions like `Entity`, `Scene`, `ResourceManager`, and the render/shader interfaces.

12. **Build and packaging boundary**
   - CMake drives the build, and the GitHub workflow suggests multi-platform CI for the engine library and game executable.
   - The engine is intended to be consumed as a local library by the `game` target rather than as a standalone product.
   - For an architecture diagram, the most important separation is: `game` supplies content and entry point; `engine` supplies the runtime services and subsystem orchestration.

Main entry points: [`engine/src/core/Application.h`](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/core/Application.h) (Application), [`engine/src/scene/Scene.h`](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/scene/Scene.h) (Scene), [`engine/src/renderer/Renderer.h`](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/renderer/Renderer.h) (Renderer), [`engine/src/ui/UISystem.h`](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/ui/UISystem.h) (UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_game["Game"]
  node_game_main["Main<br/>entrypoint<br/>[main.cpp]"]
end

subgraph group_engine_core["Engine Core"]
  node_core_application["Application<br/>engine runtime<br/>[Application.h]"]
  node_core_window["Window<br/>platform layer<br/>[Window.h]"]
  node_core_input["Input<br/>[Input.h]"]
  node_core_log["Log<br/>[Log.h]"]
  node_core_resources[("Resources<br/>asset cache<br/>[ResourceManager.h]")]
end

subgraph group_engine_runtime["Engine Runtime"]
  node_scene_manager["Scene Manager<br/>world coordinator<br/>[SceneManager.h]"]
  node_scene_scene["Scene<br/>world state<br/>[Scene.h]"]
  node_entity_entity(("Entity<br/>world object<br/>[Entity.h]"))
  node_renderer_renderer["Renderer<br/>render pipeline<br/>[Renderer.h]"]
  node_renderer_context["GL Context<br/>graphics backend<br/>[OpenGLContext.h]"]
  node_renderer_shader["Shaders<br/>gpu programs<br/>[Shader.h]"]
  node_renderer_model["Models<br/>asset geometry<br/>[Model.h]"]
  node_renderer_camera["Camera<br/>view state<br/>[Camera.h]"]
  node_physics_system["Physics<br/>simulation<br/>[PhysicsSystem.h]"]
  node_scripting_system["Scripting<br/>lua bridge<br/>[ScriptSystem.h]"]
  node_ui_system["UI<br/>editor overlay<br/>[UISystem.h]"]
  node_audio_system["Audio<br/>sound runtime<br/>[AudioSystem.h]"]
end

node_game_main -->|"bootstraps"| node_core_application
node_core_application -->|"owns"| node_core_window
node_core_application -->|"polls"| node_core_input
node_core_application -->|"reports"| node_core_log
node_core_application -->|"shares assets"| node_core_resources
node_core_application -->|"runs world"| node_scene_manager
node_core_application -->|"drives render"| node_renderer_renderer
node_core_application -->|"ticks sim"| node_physics_system
node_core_application -->|"ticks scripts"| node_scripting_system
node_core_application -->|"updates ui"| node_ui_system
node_core_application -->|"updates audio"| node_audio_system
node_scene_manager -->|"activates"| node_scene_scene
node_scene_scene -->|"contains"| node_entity_entity
node_scene_scene -->|"provides view"| node_renderer_renderer
node_scene_scene -->|"feeds state"| node_physics_system
node_scene_scene -->|"binds gameplay"| node_scripting_system
node_renderer_renderer -->|"uses"| node_renderer_context
node_renderer_renderer -->|"binds"| node_renderer_shader
node_renderer_renderer -->|"draws"| node_renderer_model
node_renderer_renderer -->|"views"| node_renderer_camera
node_renderer_model -->|"loads from"| node_core_resources
node_renderer_shader -->|"loads from"| node_core_resources
node_physics_system -->|"updates"| node_entity_entity
node_scripting_system -->|"controls"| node_entity_entity
node_ui_system -->|"inspects"| node_scene_scene
node_ui_system -->|"overlays"| node_renderer_renderer
node_audio_system -->|"reacts to"| node_scene_scene

click node_game_main "https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/game/src/main.cpp"
click node_core_application "https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/core/Application.h"
click node_core_window "https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/core/Window.h"
click node_core_input "https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/core/Input.h"
click node_core_log "https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/core/Log.h"
click node_core_resources "https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/core/ResourceManager.h"
click node_scene_manager "https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/scene/SceneManager.h"
click node_scene_scene "https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/scene/Scene.h"
click node_entity_entity "https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/entity/Entity.h"
click node_renderer_renderer "https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/renderer/Renderer.h"
click node_renderer_context "https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/renderer/OpenGLContext.h"
click node_renderer_shader "https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/renderer/Shader.h"
click node_renderer_model "https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/renderer/Model.h"
click node_renderer_camera "https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/renderer/Camera.h"
click node_physics_system "https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/physics/PhysicsSystem.h"
click node_scripting_system "https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/scripting/ScriptSystem.h"
click node_ui_system "https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/ui/UISystem.h"
click node_audio_system "https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/audio/AudioSystem.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_game_main toneBlue
class node_core_application,node_core_window,node_core_input,node_core_log,node_core_resources toneAmber
class node_scene_manager,node_scene_scene,node_entity_entity,node_renderer_renderer,node_renderer_context,node_renderer_shader,node_renderer_model,node_renderer_camera,node_physics_system,node_scripting_system,node_ui_system,node_audio_system toneMint
```

## Components

### Game

Application entry point and content-side bootstrap.

- [Main](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/game/src/main.cpp): entrypoint · Starts the game executable and hands control to the engine. · `game/src/main.cpp`

### Engine Core

Lifetime, platform, and shared services.

- [Application](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/core/Application.h): engine runtime · Owns startup, main loop, and subsystem coordination. · `engine/src/core/Application.h`
- [Window](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/core/Window.h): platform layer · Creates and manages the graphics/windowing boundary. · `engine/src/core/Window.h`
- [Input](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/core/Input.h): input facade · Global input queries over the active window and backend. · `engine/src/core/Input.h`
- [Log](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/core/Log.h): logging · Shared logging and diagnostics for the engine. · `engine/src/core/Log.h`
- [Resources](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/core/ResourceManager.h): asset cache · Central asset loading and sharing boundary. · `engine/src/core/ResourceManager.h`

### Engine Runtime

World management and major runtime subsystems.

- [Scene Manager](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/scene/SceneManager.h): world coordinator · Switches and manages active scenes or levels. · `engine/src/scene/SceneManager.h`
- [Scene](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/scene/Scene.h): world state · Owns the active world and coordinates per-frame systems. · `engine/src/scene/Scene.h`
- [Entity](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/entity/Entity.h): world object · Common unit shared across gameplay, rendering, and tools. · `engine/src/entity/Entity.h`
- [Renderer](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/renderer/Renderer.h): render pipeline · Converts scene state into OpenGL draw work. · `engine/src/renderer/Renderer.h`
- [GL Context](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/renderer/OpenGLContext.h): graphics backend · Initializes the OpenGL runtime and device context. · `engine/src/renderer/OpenGLContext.h`
- [Shaders](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/renderer/Shader.h): gpu programs · Loads and manages shader program objects. · `engine/src/renderer/Shader.h`
- [Models](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/renderer/Model.h): asset geometry · Imports and stores mesh/model geometry for rendering. · `engine/src/renderer/Model.h`
- [Camera](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/renderer/Camera.h): view state · Defines the view and projection used by rendering. · `engine/src/renderer/Camera.h`
- [Physics](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/physics/PhysicsSystem.h): simulation · Updates simulation state independently of rendering. · `engine/src/physics/PhysicsSystem.h`
- [Scripting](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/scripting/ScriptSystem.h): lua bridge · Binds engine objects into Lua-driven gameplay behavior. · `engine/src/scripting/ScriptSystem.h`
- [UI](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/ui/UISystem.h): editor overlay · ImGui-based in-engine tools and debug overlays. · `engine/src/ui/UISystem.h`
- [Audio](https://github.com/luiscrespo-bot/antigravity-game-engine/blob/main/engine/src/audio/AudioSystem.h): sound runtime · Plays and manages audio through the audio backend. · `engine/src/audio/AudioSystem.h`

## Connections

- Main → Application: bootstraps · The executable enters through the engine application layer.
- Application → Window: owns · Application creates and drives the window and context boundary.
- Application → Input: polls · Main-loop updates query input state through the core facade.
- Application → Log: reports · Startup and runtime diagnostics flow through logging.
- Application → Resources: shares assets · Application exposes centralized resource loading to subsystems.
- Application → Scene Manager: runs world · Application hands control to scene management and update flow.
- Application → Renderer: drives render · Application schedules the frame rendering path.
- Application → Physics: ticks sim · Application advances fixed-step simulation.
- Application → Scripting: ticks scripts · Application updates Lua gameplay logic.
- Application → UI: updates ui · Application runs the editor/debug overlay.
- Application → Audio: updates audio · Application advances audio playback and events.
- Scene Manager → Scene: activates · Scene manager owns the currently active scene.
- Scene → Entity: contains · Scenes organize the world as entities.
- Scene → Renderer: provides view · Scenes supply renderable world state to the renderer.
- Scene → Physics: feeds state · Physics consumes transforms and collision-relevant entity data.
- Scene → Scripting: binds gameplay · Scripts attach behavior to scene entities.
- Renderer → GL Context: uses · Renderer executes against the OpenGL backend.
- Renderer → Shaders: binds · Rendering relies on shader programs.
- Renderer → Models: draws · Renderer consumes imported model and mesh data.
- Renderer → Camera: views · Camera state defines the active render perspective.
- Models → Resources: loads from · Models are retrieved through the shared asset cache.
- Shaders → Resources: loads from · Shaders are also managed through the resource boundary.
- Physics → Entity: updates · Physics writes back motion and simulation results on entities.
- Scripting → Entity: controls · Lua scripts operate on entities and gameplay state.
- UI → Scene: inspects · UI overlays read scene state for tools and inspection.
- UI → Renderer: overlays · UI is composited on top of the rendered frame.
- Audio → Scene: reacts to · Audio is driven by scene or gameplay events.
