# ordinary56/infinitehorde architecture

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

- Interactive diagram: https://gitdiagram.com/ordinary56/infinitehorde
- Repository: https://github.com/ordinary56/infinitehorde

## Overview

1. **Project shape and purpose**
   - *Infinite Horde* is a C++ game project organized around a small engine layer plus game-specific content.
   - The repository is split into reusable core systems, entity/gameplay code, scene orchestration, UI, and platform-specific backends.

2. **Top-level runtime flow**
   - `main.cpp` is the entry point and likely bootstraps the core game object.
   - The central runtime path is: platform setup → input/input polling → scene update → world/entity simulation → rendering.
   - `core/game.h` and `core/gameWorld.h` are the main coordination points for the game loop and shared simulation state.

3. **Platform boundary**
   - `include/platform/platform.h` defines an abstraction over the host environment.
   - `raylibPlatform` and `consolePlatform` indicate two execution modes:
     - a graphical mode using raylib
     - a console-oriented mode for simpler output or debugging
   - This boundary isolates window/input lifecycle and platform-specific startup/shutdown from gameplay code.

4. **Rendering boundary**
   - `core/renderer/renderer.h` is the renderer interface.
   - `raylibRenderer` is the graphical backend, while `consoleRenderer` is a non-graphical backend.
   - Rendering is likely driven from scenes and/or the game world, with sprites and UI elements drawn through this abstraction rather than directly from gameplay classes.

5. **Input and camera**
   - `core/input/inputSystem.h` defines input handling; `raylibInputSystem` connects that interface to raylib.
   - `core/camera/cameraController.h` and `cameraData.h` manage view position/zoom/targeting for gameplay.
   - This suggests input feeds both player control and camera behavior, with the camera remaining separate from entity logic.

6. **Scene architecture**
   - `scene/scene.h` is the scene contract, and `sceneManager.h` owns the active scene.
   - There are at least two scenes:
     - `mainMenuScene`
     - `gameplayScene`
   - Scene transitions are the main boundary between menu flow and in-game simulation, which is a clean place to diagram top-level application states.

7. **Gameplay/world layer**
   - `entity/entity.h` is the base type for in-world actors.
   - Concrete gameplay types include `player`, `enemy`, `projectile`, and `weapon`.
   - Manager classes such as `enemyManager` and `projectileManager` suggest centralized spawning, lifetime management, and updates for those object groups.
   - `gameWorld` likely aggregates these systems and exposes the shared state used by the gameplay scene.

8. **Interaction and decoupling**
   - `core/events/eventManager.hpp` and `handler.h` show an event system for loose coupling between subsystems.
   - This is likely used for game events such as hits, deaths, UI actions, or scene changes without hard wiring all components together.
   - `core/timer/timer.h` provides time measurement, frame timing, or cooldown behavior, which is essential in a real-time action game.

9. **UI subsystem**
   - `ui/uiElement.h`, `ui/uiContainer.h`, and `ui/uiButton.h` define a small retained UI hierarchy.
   - `ui/builders/uiButtonBuilder.h` suggests a construction helper for configurable buttons.
   - The UI layer is separate from gameplay entities, which makes menu screens and overlays easier to manage inside scenes.

10. **Sprites and assets**
   - `sprite/spriteManager.h` and `sprite_entry.h` indicate a resource registry for sprite assets.
   - This sits between raw asset loading and entity/UI drawing, so entities probably reference sprite entries rather than owning graphics data directly.

11. **Math and shared utilities**
   - `core/math/vec2.h` and `rect.h` provide the basic 2D types used across movement, collision, UI layout, and camera logic.
   - `helpers/helpers.h` and `helpers/utils.hpp` contain shared utility code that is reused across systems but does not belong to a single subsystem.

12. **Tooling, tests, and diagnostics**
   - The project uses CMake with Linux and Windows toolchain files, so the architecture is intended to be cross-platform.
   - `tests/main_test.cpp` with `gtest_lite` provides a lightweight test harness.
   - `memtrace` and `raylib.supp` indicate memory/debug tracing support, which is useful for catching leaks or allocation issues in a game loop.

13. **How to draw the architecture**
   - A good diagram would place `main` at the top feeding into `Game`, with `Platform`, `Renderer`, and `InputSystem` as replaceable backends.
   - Below that, show `SceneManager` choosing between `MainMenuScene` and `GameplayScene`.
   - Inside gameplay, show `GameWorld` coordinating `Player`, `Enemies`, `Projectiles`, `Weapons`, `Camera`, `UI`, `Sprites`, and `Events`.
   - The clearest boundaries are: platform/backend, scene/state, world/entity simulation, and UI/resource management.

Main entry points: [`include/core/gameWorld.h`](https://github.com/ordinary56/infinitehorde/blob/main/include/core/gameWorld.h) (Game World), [`include/scene/gameplayScene.h`](https://github.com/ordinary56/infinitehorde/blob/main/include/scene/gameplayScene.h) (Gameplay), [`include/core/game.h`](https://github.com/ordinary56/infinitehorde/blob/main/include/core/game.h) (Game), [`include/core/renderer/renderer.h`](https://github.com/ordinary56/infinitehorde/blob/main/include/core/renderer/renderer.h) (Renderer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime flow"]
  node_main["Main<br/>entry<br/>[main.cpp]"]
  node_game["Game<br/>loop coordinator<br/>[game.h]"]
  node_scene_manager["Scene Manager<br/>state router<br/>[sceneManager.h]"]
end

subgraph group_backends["Backends"]
  node_platform["Platform<br/>host abstraction<br/>[platform.h]"]
  node_renderer["Renderer<br/>draw abstraction<br/>[renderer.h]"]
  node_input_system["Input<br/>[inputSystem.h]"]
  node_raylib_platform["Raylib Plat<br/>graphical backend<br/>[raylibPlatform.h]"]
  node_console_platform["Console Plat<br/>debug backend<br/>[consolePlatform.h]"]
  node_raylib_renderer["Raylib Render<br/>graphics backend<br/>[raylibRenderer.h]"]
  node_console_renderer["Console Render<br/>text backend<br/>[consoleRenderer.h]"]
  node_raylib_input["Raylib Input<br/>input backend"]
end

subgraph group_gameplay["Gameplay"]
  node_game_world["Game World<br/>simulation hub<br/>[gameWorld.h]"]
  node_player(("Player<br/>entity<br/>[player.h]"))
  node_enemy_manager["Enemies<br/>entity manager<br/>[enemyManager.h]"]
  node_projectile_manager["Projectiles<br/>entity manager"]
end

subgraph group_presentation["Presentation"]
  node_main_menu["Main Menu<br/>scene<br/>[mainMenuScene.h]"]
  node_gameplay_scene["Gameplay<br/>scene<br/>[gameplayScene.h]"]
  node_sprites["Sprites<br/>asset registry<br/>[spriteManager.h]"]
  node_ui["UI<br/>widget system<br/>[uiElement.h]"]
end

subgraph group_shared["Shared core"]
  node_camera["Camera<br/>view controller<br/>[cameraController.h]"]
  node_events["Events<br/>event bus<br/>[eventManager.hpp]"]
  node_math["Math<br/>geometry types<br/>[vec2.h]"]
  node_timer["Timer<br/>frame timing<br/>[timer.h]"]
end

node_main -->|"boots"| node_game
node_game -->|"uses"| node_platform
node_game -->|"uses"| node_renderer
node_game -->|"uses"| node_input_system
node_game -->|"owns"| node_scene_manager
node_platform -.->|"impl"| node_raylib_platform
node_platform -.->|"impl"| node_console_platform
node_renderer -.->|"impl"| node_raylib_renderer
node_renderer -.->|"impl"| node_console_renderer
node_input_system -.->|"impl"| node_raylib_input
node_scene_manager -->|"activates"| node_main_menu
node_scene_manager -->|"activates"| node_gameplay_scene
node_gameplay_scene -->|"drives"| node_game_world
node_game_world -->|"contains"| node_player
node_game_world -->|"contains"| node_enemy_manager
node_game_world -->|"contains"| node_projectile_manager
node_game_world -->|"updates"| node_camera
node_game_world -->|"publishes"| node_events
node_game_world -->|"references"| node_sprites
node_gameplay_scene -->|"lays out"| node_ui
node_gameplay_scene -->|"draws via"| node_renderer
node_gameplay_scene -->|"reads"| node_input_system
node_gameplay_scene -->|"uses"| node_math
node_game_world -->|"uses"| node_math
node_game_world -->|"uses"| node_timer
node_ui -->|"uses"| node_sprites

click node_main "https://github.com/ordinary56/infinitehorde/blob/main/src/main.cpp"
click node_game "https://github.com/ordinary56/infinitehorde/blob/main/include/core/game.h"
click node_scene_manager "https://github.com/ordinary56/infinitehorde/blob/main/include/scene/sceneManager.h"
click node_platform "https://github.com/ordinary56/infinitehorde/blob/main/include/platform/platform.h"
click node_renderer "https://github.com/ordinary56/infinitehorde/blob/main/include/core/renderer/renderer.h"
click node_input_system "https://github.com/ordinary56/infinitehorde/blob/main/include/core/input/inputSystem.h"
click node_raylib_platform "https://github.com/ordinary56/infinitehorde/blob/main/include/platform/raylibPlatform.h"
click node_console_platform "https://github.com/ordinary56/infinitehorde/blob/main/include/platform/consolePlatform.h"
click node_raylib_renderer "https://github.com/ordinary56/infinitehorde/blob/main/include/core/renderer/raylibRenderer.h"
click node_console_renderer "https://github.com/ordinary56/infinitehorde/blob/main/include/core/renderer/consoleRenderer.h"
click node_raylib_input "https://github.com/ordinary56/infinitehorde/blob/main/include/core/input/raylibInputSystem.h"
click node_main_menu "https://github.com/ordinary56/infinitehorde/blob/main/include/scene/mainMenuScene.h"
click node_gameplay_scene "https://github.com/ordinary56/infinitehorde/blob/main/include/scene/gameplayScene.h"
click node_game_world "https://github.com/ordinary56/infinitehorde/blob/main/include/core/gameWorld.h"
click node_player "https://github.com/ordinary56/infinitehorde/blob/main/include/entity/player.h"
click node_enemy_manager "https://github.com/ordinary56/infinitehorde/blob/main/include/entity/enemyManager.h"
click node_projectile_manager "https://github.com/ordinary56/infinitehorde/blob/main/include/entity/projectileManager.h"
click node_camera "https://github.com/ordinary56/infinitehorde/blob/main/include/core/camera/cameraController.h"
click node_events "https://github.com/ordinary56/infinitehorde/blob/main/include/core/events/eventManager.hpp"
click node_sprites "https://github.com/ordinary56/infinitehorde/blob/main/include/sprite/spriteManager.h"
click node_ui "https://github.com/ordinary56/infinitehorde/blob/main/include/ui/uiElement.h"
click node_math "https://github.com/ordinary56/infinitehorde/blob/main/include/core/math/vec2.h"
click node_timer "https://github.com/ordinary56/infinitehorde/blob/main/include/core/timer/timer.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_main,node_game,node_scene_manager toneBlue
class node_platform,node_renderer,node_input_system,node_raylib_platform,node_console_platform,node_raylib_renderer,node_console_renderer,node_raylib_input toneAmber
class node_game_world,node_player,node_enemy_manager,node_projectile_manager toneMint
class node_main_menu,node_gameplay_scene,node_sprites,node_ui toneRose
class node_camera,node_events,node_math,node_timer toneIndigo
```

## Components

### Runtime flow

Entry point, core loop, and scene orchestration.

- [Main](https://github.com/ordinary56/infinitehorde/blob/main/src/main.cpp): entry · Program entry point. · `src/main.cpp`
- [Game](https://github.com/ordinary56/infinitehorde/blob/main/include/core/game.h): loop coordinator · Owns the top-level application flow and runtime wiring. · `include/core/game.h`
- [Scene Manager](https://github.com/ordinary56/infinitehorde/blob/main/include/scene/sceneManager.h): state router · Selects and switches the active scene. · `include/scene/sceneManager.h`

### Backends

Replaceable platform, input, and rendering implementations.

- [Platform](https://github.com/ordinary56/infinitehorde/blob/main/include/platform/platform.h): host abstraction · Abstracts OS/window lifecycle and startup/shutdown. · `include/platform/platform.h`
- [Renderer](https://github.com/ordinary56/infinitehorde/blob/main/include/core/renderer/renderer.h): draw abstraction · Abstract rendering interface used by scenes and gameplay. · `include/core/renderer/renderer.h`
- [Input](https://github.com/ordinary56/infinitehorde/blob/main/include/core/input/inputSystem.h): input abstraction · Abstract input polling and event translation. · `include/core/input/inputSystem.h`
- [Raylib Plat](https://github.com/ordinary56/infinitehorde/blob/main/include/platform/raylibPlatform.h): graphical backend · Raylib host implementation. · `include/platform/raylibPlatform.h`
- [Console Plat](https://github.com/ordinary56/infinitehorde/blob/main/include/platform/consolePlatform.h): debug backend · Console-oriented host implementation. · `include/platform/consolePlatform.h`
- [Raylib Render](https://github.com/ordinary56/infinitehorde/blob/main/include/core/renderer/raylibRenderer.h): graphics backend · Raylib rendering implementation. · `include/core/renderer/raylibRenderer.h`
- [Console Render](https://github.com/ordinary56/infinitehorde/blob/main/include/core/renderer/consoleRenderer.h): text backend · Non-graphical rendering implementation. · `include/core/renderer/consoleRenderer.h`
- [Raylib Input](https://github.com/ordinary56/infinitehorde/blob/main/include/core/input/raylibInputSystem.h): input backend · Raylib-backed input implementation. · `include/core/input/raylibInputSystem.h`

### Gameplay

World simulation and entity systems.

- [Game World](https://github.com/ordinary56/infinitehorde/blob/main/include/core/gameWorld.h): simulation hub · Shared world state for gameplay systems. · `include/core/gameWorld.h`
- [Player](https://github.com/ordinary56/infinitehorde/blob/main/include/entity/player.h): entity · Player-controlled actor. · `include/entity/player.h`
- [Enemies](https://github.com/ordinary56/infinitehorde/blob/main/include/entity/enemyManager.h): entity manager · Spawns and updates enemies. · `include/entity/enemyManager.h`
- [Projectiles](https://github.com/ordinary56/infinitehorde/blob/main/include/entity/projectileManager.h): entity manager · Creates and manages projectiles. · `include/entity/projectileManager.h`

### Presentation

Scenes, UI, and sprite resources.

- [Main Menu](https://github.com/ordinary56/infinitehorde/blob/main/include/scene/mainMenuScene.h): scene · Menu scene for top-level navigation. · `include/scene/mainMenuScene.h`
- [Gameplay](https://github.com/ordinary56/infinitehorde/blob/main/include/scene/gameplayScene.h): scene · In-game scene that drives simulation and rendering. · `include/scene/gameplayScene.h`
- [Sprites](https://github.com/ordinary56/infinitehorde/blob/main/include/sprite/spriteManager.h): asset registry · Central sprite/resource lookup. · `include/sprite/spriteManager.h`
- [UI](https://github.com/ordinary56/infinitehorde/blob/main/include/ui/uiElement.h): widget system · Retained UI hierarchy for menus and overlays. · `include/ui/uiElement.h`

### Shared core

Cross-cutting math, timing, and events.

- [Camera](https://github.com/ordinary56/infinitehorde/blob/main/include/core/camera/cameraController.h): view controller · Controls viewport position and zoom. · `include/core/camera/cameraController.h`
- [Events](https://github.com/ordinary56/infinitehorde/blob/main/include/core/events/eventManager.hpp): event bus · Loose coupling between gameplay subsystems. · `include/core/events/eventManager.hpp`
- [Math](https://github.com/ordinary56/infinitehorde/blob/main/include/core/math/vec2.h): geometry types · Shared 2D primitives for movement, bounds, and layout. · `include/core/math/vec2.h`
- [Timer](https://github.com/ordinary56/infinitehorde/blob/main/include/core/timer/timer.h): frame timing · Time measurement and cooldown support. · `include/core/timer/timer.h`

## Connections

- Main → Game: boots · Program startup enters the main game coordinator.
- Game → Platform: uses · Game depends on the platform abstraction.
- Game → Renderer: uses · Game depends on the rendering abstraction.
- Game → Input: uses · Game depends on abstract input handling.
- Game → Scene Manager: owns · Game delegates flow to the scene manager.
- Platform → Raylib Plat: impl · Graphical host backend.
- Platform → Console Plat: impl · Console host backend.
- Renderer → Raylib Render: impl · Raylib drawing backend.
- Renderer → Console Render: impl · Console drawing backend.
- Input → Raylib Input: impl · Raylib input backend.
- Scene Manager → Main Menu: activates · Menu scene is one top-level state.
- Scene Manager → Gameplay: activates · Gameplay scene is the in-game state.
- Gameplay → Game World: drives · Gameplay scene updates the simulation world.
- Game World → Player: contains · Player is part of the world state.
- Game World → Enemies: contains · Enemy management lives inside the world.
- Game World → Projectiles: contains · Projectile lifecycle is managed centrally.
- Game World → Camera: updates · World feeds camera behavior and view state.
- Game World → Events: publishes · World events decouple gameplay systems.
- Game World → Sprites: references · World and entities use shared sprite assets.
- Gameplay → UI: lays out · Gameplay and menus can present UI overlays.
- Gameplay → Renderer: draws via · Scene rendering goes through the renderer interface.
- Gameplay → Input: reads · Scene consumes input through the input abstraction.
- Gameplay → Math: uses · Scene logic relies on shared geometry types.
- Game World → Math: uses · Simulation relies on shared geometry types.
- Game World → Timer: uses · Timing supports updates, cooldowns, and frame control.
- UI → Sprites: uses · UI widgets can share the sprite registry.
