# zerok-rts/zero-k architecture

> Architecture diagram of the GitHub repository zerok-rts/zero-k, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zerok-rts/zero-k
- Repository: https://github.com/zerok-rts/zero-k

## Overview

Zero-K is a real-time strategy game module for the Spring Engine, with physical projectiles, smart units, and a powerful UI. The broad workflow is a player interacting through the game UI while game rules govern units and combat; the repository also contains map/game configuration, Gaia gadgets, and intro content. The tree supports these subsystem boundaries, but the sampled source does not show runtime wiring between them, so those relationships are omitted. The sampled COB headers document unit-state and engine-constant conventions, not their callers.

Main entry points: [`LuaRules/Gadgets`](https://github.com/zerok-rts/zero-k/tree/master/LuaRules/Gadgets) (Game rules), [`LuaUI`](https://github.com/zerok-rts/zero-k/tree/master/LuaUI) (Game UI), [`scripts`](https://github.com/zerok-rts/zero-k/tree/master/scripts) (Unit scripts), [`units`](https://github.com/zerok-rts/zero-k/tree/master/units) (Unit definitions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Player interface"]
  node_ui["Game UI"]
  node_widgets["UI widgets"]
  node_ui_configs["UI configuration"]
end

subgraph group_simulation["Game simulation"]
  node_rules["Game rules"]
  node_rule_configs["Rule configuration"]
  node_gaia["Gaia gadgets"]
end

subgraph group_content["Game content"]
  node_unit_defs["Unit definitions"]
  node_weapon_defs["Weapon definitions"]
  node_unit_scripts["Unit scripts"]
  node_state_change["Unit state changes<br/>[statechg.h]"]
  node_engine_constants["Engine constants<br/>[constants.h]"]
  node_effects["Visual effects"]
  node_map_config["Map configuration"]
end

subgraph group_support["Game support"]
  node_intro["Game introduction"]
  node_music["Intro music<br/>[music.lua]"]
end

node_player(("Player"))
node_spring["Spring Engine"]

node_player -.->|"interacts through"| node_ui
node_ui -->|"runs with"| node_spring
node_spring -.->|"runs game rules"| node_rules
node_spring -.->|"hosts interface"| node_ui
node_rules -.->|"uses definitions"| node_unit_defs
node_rules -.->|"resolves combat"| node_weapon_defs
node_rules -.->|"uses configuration"| node_rule_configs
node_gaia -.->|"affects gameplay"| node_rules
node_ui -.->|"includes widgets"| node_widgets
node_ui -.->|"uses configuration"| node_ui_configs
node_unit_defs -.->|"uses scripts"| node_unit_scripts
node_unit_scripts -.->|"includes state logic"| node_state_change
node_unit_scripts -.->|"uses constants"| node_engine_constants
node_weapon_defs -.->|"configures effects"| node_effects
node_intro -.->|"loads addon"| node_music
node_map_config -.->|"configures map play"| node_rules

click node_ui "https://github.com/zerok-rts/zero-k/tree/master/LuaUI"
click node_widgets "https://github.com/zerok-rts/zero-k/tree/master/LuaUI/Widgets"
click node_ui_configs "https://github.com/zerok-rts/zero-k/tree/master/LuaUI/Configs"
click node_rules "https://github.com/zerok-rts/zero-k/tree/master/LuaRules/Gadgets"
click node_rule_configs "https://github.com/zerok-rts/zero-k/tree/master/LuaRules/Configs"
click node_gaia "https://github.com/zerok-rts/zero-k/tree/master/LuaGaia/Gadgets"
click node_unit_defs "https://github.com/zerok-rts/zero-k/tree/master/units"
click node_weapon_defs "https://github.com/zerok-rts/zero-k/tree/master/weapons"
click node_unit_scripts "https://github.com/zerok-rts/zero-k/tree/master/scripts"
click node_state_change "https://github.com/zerok-rts/zero-k/blob/master/scripts/statechg.h"
click node_engine_constants "https://github.com/zerok-rts/zero-k/blob/master/scripts/constants.h"
click node_effects "https://github.com/zerok-rts/zero-k/tree/master/effects"
click node_map_config "https://github.com/zerok-rts/zero-k/tree/master/LuaRules/Configs/StartBoxes"
click node_intro "https://github.com/zerok-rts/zero-k/tree/master/LuaIntro"
click node_music "https://github.com/zerok-rts/zero-k/blob/master/LuaIntro/Addons/music.lua"

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_ui,node_widgets,node_ui_configs toneBlue
class node_rules,node_rule_configs,node_gaia toneAmber
class node_unit_defs,node_weapon_defs,node_unit_scripts,node_state_change,node_engine_constants,node_effects,node_map_config toneMint
class node_intro,node_music toneRose
class node_player,node_spring toneIndigo
```

## Components

### Player interface

- [Game UI](https://github.com/zerok-rts/zero-k/tree/master/LuaUI): `LuaUI`
- [UI widgets](https://github.com/zerok-rts/zero-k/tree/master/LuaUI/Widgets): `LuaUI/Widgets`
- [UI configuration](https://github.com/zerok-rts/zero-k/tree/master/LuaUI/Configs): `LuaUI/Configs`

### Game simulation

- [Game rules](https://github.com/zerok-rts/zero-k/tree/master/LuaRules/Gadgets): `LuaRules/Gadgets`
- [Rule configuration](https://github.com/zerok-rts/zero-k/tree/master/LuaRules/Configs): `LuaRules/Configs`
- [Gaia gadgets](https://github.com/zerok-rts/zero-k/tree/master/LuaGaia/Gadgets): `LuaGaia/Gadgets`

### Game content

- [Unit definitions](https://github.com/zerok-rts/zero-k/tree/master/units): `units`
- [Weapon definitions](https://github.com/zerok-rts/zero-k/tree/master/weapons): `weapons`
- [Unit scripts](https://github.com/zerok-rts/zero-k/tree/master/scripts): `scripts`
- [Unit state changes](https://github.com/zerok-rts/zero-k/blob/master/scripts/statechg.h): `scripts/statechg.h`
- [Engine constants](https://github.com/zerok-rts/zero-k/blob/master/scripts/constants.h): `scripts/constants.h`
- [Visual effects](https://github.com/zerok-rts/zero-k/tree/master/effects): `effects`
- [Map configuration](https://github.com/zerok-rts/zero-k/tree/master/LuaRules/Configs/StartBoxes): `LuaRules/Configs/StartBoxes`

### Game support

- [Game introduction](https://github.com/zerok-rts/zero-k/tree/master/LuaIntro): `LuaIntro`
- [Intro music](https://github.com/zerok-rts/zero-k/blob/master/LuaIntro/Addons/music.lua): `LuaIntro/Addons/music.lua`

### Other components

- **Player**
- **Spring Engine**

## Connections

- Player → Game UI: interacts through
- Game UI → Spring Engine: runs with (evidence: `README.md`)
- Spring Engine → Game rules: runs game rules
- Spring Engine → Game UI: hosts interface
- Game rules → Unit definitions: uses definitions
- Game rules → Weapon definitions: resolves combat
- Game rules → Rule configuration: uses configuration
- Gaia gadgets → Game rules: affects gameplay
- Game UI → UI widgets: includes widgets
- Game UI → UI configuration: uses configuration
- Unit definitions → Unit scripts: uses scripts
- Unit scripts → Unit state changes: includes state logic
- Unit scripts → Engine constants: uses constants
- Weapon definitions → Visual effects: configures effects
- Game introduction → Intro music: loads addon
- Map configuration → Game rules: configures map play
