# motzky/ugame architecture

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

- Interactive diagram: https://gitdiagram.com/motzky/ugame
- Repository: https://github.com/motzky/ugame

## Overview

µgame is a C++ game application with a Lua-driven level system, real-time input, rendering, and physics. Its user-facing flow begins by launching the game, then proceeds through game state and routines toward level interaction and rendered output. The tree also shows resource loading, scripting, messaging, and platform-specific windowing. The README documents supplying a resource pack; sampled-source evidence is limited, so uncertain routine orchestration is shown as unverified rather than asserted.

Main entry points: [`src/primitives/entity.cpp`](https://github.com/motzky/ugame/blob/main/src/primitives/entity.cpp) (Entities), [`src/game/routines`](https://github.com/motzky/ugame/tree/main/src/game/routines) (Game Routines), [`src/game/levels/lua_level.cpp`](https://github.com/motzky/ugame/blob/main/src/game/levels/lua_level.cpp) (Lua Level), [`src/graphics/renderer.cpp`](https://github.com/motzky/ugame/blob/main/src/graphics/renderer.cpp) (Renderer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game Runtime"]
  node_player["Player<br/>[player.h]"]
  node_game["Game<br/>[game.cpp]"]
  node_routines["Game Routines"]
  node_lua_level["Lua Level<br/>[lua_level.cpp]"]
end

subgraph group_presentation["Input and Graphics"]
  node_window["Platform Window<br/>[window.cpp]"]
  node_input["Input Events"]
  node_renderer["Renderer<br/>[renderer.cpp]"]
  node_graphics_assets["Graphics Assets"]
end

subgraph group_world["World and Physics"]
  node_entity["Entities<br/>[entity.cpp]"]
  node_physics["Physics System<br/>[physics_system.cpp]"]
  node_shapes["Collision Shapes<br/>[shape.h]"]
end

subgraph group_support["Runtime Services"]
  node_resources["Resource Loading"]
  node_tlv["Resource Format<br/>[tlv_reader.cpp]"]
  node_scripting["Lua Scripting<br/>[lua_script.cpp]"]
  node_messaging["Message Bus<br/>[message_bus.cpp]"]
  node_scheduler["Scheduler<br/>[scheduler.cpp]"]
  node_math["Math Types<br/>[vector3.h]"]
end

node_entry["Game Entry<br/>[main.cpp]"]
node_user(("Player"))

node_user -->|"launches"| node_entry
node_entry -->|"starts"| node_game
node_window -->|"emits events"| node_input
node_renderer -->|"renders"| node_entity
node_entity -->|"uses physics"| node_physics
node_physics -->|"uses shapes"| node_shapes
node_lua_level -->|"uses scripts"| node_scripting
node_lua_level -->|"loads resources"| node_resources
node_renderer -->|"reads data"| node_tlv
node_scheduler -->|"uses bus"| node_messaging
node_messaging -->|"dispatches events"| node_input
node_entity -->|"references assets"| node_graphics_assets
node_routines -.->|"handles input"| node_input
node_routines -.->|"updates physics"| node_physics
node_routines -.->|"draws frames"| node_renderer
node_game -.->|"runs routines"| node_routines
node_lua_level -.->|"builds world"| node_entity
node_player -.->|"controls"| node_entity
node_entity -->|"uses vectors"| node_math

click node_player "https://github.com/motzky/ugame/blob/main/include/game/player.h"
click node_game "https://github.com/motzky/ugame/blob/main/src/game/game.cpp"
click node_routines "https://github.com/motzky/ugame/tree/main/src/game/routines"
click node_lua_level "https://github.com/motzky/ugame/blob/main/src/game/levels/lua_level.cpp"
click node_window "https://github.com/motzky/ugame/blob/main/src/glfw/window.cpp"
click node_input "https://github.com/motzky/ugame/tree/main/include/events"
click node_renderer "https://github.com/motzky/ugame/blob/main/src/graphics/renderer.cpp"
click node_graphics_assets "https://github.com/motzky/ugame/tree/main/include/graphics"
click node_entity "https://github.com/motzky/ugame/blob/main/src/primitives/entity.cpp"
click node_physics "https://github.com/motzky/ugame/blob/main/src/physics/physics_system.cpp"
click node_shapes "https://github.com/motzky/ugame/blob/main/include/physics/shape.h"
click node_resources "https://github.com/motzky/ugame/blob/main/src/resources/resource_loader.cpp"
click node_tlv "https://github.com/motzky/ugame/blob/main/src/tlv/tlv_reader.cpp"
click node_scripting "https://github.com/motzky/ugame/blob/main/src/scripting/lua_script.cpp"
click node_messaging "https://github.com/motzky/ugame/blob/main/src/messaging/message_bus.cpp"
click node_scheduler "https://github.com/motzky/ugame/blob/main/src/scheduler/scheduler.cpp"
click node_math "https://github.com/motzky/ugame/blob/main/include/math/vector3.h"
click node_entry "https://github.com/motzky/ugame/blob/main/src/main.cpp"

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_player,node_game,node_routines,node_lua_level toneBlue
class node_window,node_input,node_renderer,node_graphics_assets toneAmber
class node_entity,node_physics,node_shapes toneMint
class node_resources,node_tlv,node_scripting,node_messaging,node_scheduler,node_math toneRose
class node_entry toneTeal
class node_user toneIndigo
```

## Components

### Game Runtime

- [Player](https://github.com/motzky/ugame/blob/main/include/game/player.h): `include/game/player.h`
- [Game](https://github.com/motzky/ugame/blob/main/src/game/game.cpp): `src/game/game.cpp`
- [Game Routines](https://github.com/motzky/ugame/tree/main/src/game/routines): `src/game/routines`
- [Lua Level](https://github.com/motzky/ugame/blob/main/src/game/levels/lua_level.cpp): `src/game/levels/lua_level.cpp`

### Input and Graphics

- [Platform Window](https://github.com/motzky/ugame/blob/main/src/glfw/window.cpp): `src/glfw/window.cpp`
- [Input Events](https://github.com/motzky/ugame/tree/main/include/events): `include/events`
- [Renderer](https://github.com/motzky/ugame/blob/main/src/graphics/renderer.cpp): `src/graphics/renderer.cpp`
- [Graphics Assets](https://github.com/motzky/ugame/tree/main/include/graphics): `include/graphics`

### World and Physics

- [Entities](https://github.com/motzky/ugame/blob/main/src/primitives/entity.cpp): `src/primitives/entity.cpp`
- [Physics System](https://github.com/motzky/ugame/blob/main/src/physics/physics_system.cpp): `src/physics/physics_system.cpp`
- [Collision Shapes](https://github.com/motzky/ugame/blob/main/include/physics/shape.h): `include/physics/shape.h`

### Runtime Services

- [Resource Loading](https://github.com/motzky/ugame/blob/main/src/resources/resource_loader.cpp): `src/resources/resource_loader.cpp`
- [Resource Format](https://github.com/motzky/ugame/blob/main/src/tlv/tlv_reader.cpp): `src/tlv/tlv_reader.cpp`
- [Lua Scripting](https://github.com/motzky/ugame/blob/main/src/scripting/lua_script.cpp): `src/scripting/lua_script.cpp`
- [Message Bus](https://github.com/motzky/ugame/blob/main/src/messaging/message_bus.cpp): `src/messaging/message_bus.cpp`
- [Scheduler](https://github.com/motzky/ugame/blob/main/src/scheduler/scheduler.cpp): `src/scheduler/scheduler.cpp`
- [Math Types](https://github.com/motzky/ugame/blob/main/include/math/vector3.h): `include/math/vector3.h`

### Other components

- [Game Entry](https://github.com/motzky/ugame/blob/main/src/main.cpp): `src/main.cpp`
- **Player**

## Connections

- Player → Game Entry: launches
- Game Entry → Game: starts (evidence: `src/main.cpp`)
- Platform Window → Input Events: emits events (evidence: `src/glfw/window.cpp`)
- Renderer → Entities: renders (evidence: `src/graphics/renderer.cpp`)
- Entities → Physics System: uses physics
- Physics System → Collision Shapes: uses shapes
- Lua Level → Lua Scripting: uses scripts (evidence: `src/game/levels/lua_level.cpp`)
- Lua Level → Resource Loading: loads resources (evidence: `src/game/levels/lua_level.cpp`)
- Renderer → Resource Format: reads data (evidence: `src/graphics/renderer.cpp`)
- Scheduler → Message Bus: uses bus (evidence: `src/scheduler/scheduler.cpp`)
- Message Bus → Input Events: dispatches events (evidence: `src/messaging/message_bus.cpp`)
- Entities → Graphics Assets: references assets (evidence: `src/primitives/entity.cpp`)
- Game Routines → Input Events: handles input
- Game Routines → Physics System: updates physics
- Game Routines → Renderer: draws frames
- Game → Game Routines: runs routines
- Lua Level → Entities: builds world
- Player → Entities: controls
- Entities → Math Types: uses vectors (evidence: `src/primitives/entity.cpp`)
