# yairm210/unciv architecture

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

- Interactive diagram: https://gitdiagram.com/yairm210/unciv
- Repository: https://github.com/yairm210/unciv

## Overview

Unciv is a moddable Civilization V-style 4X game for Android and desktop. Players set up or load a world, manage cities, civilizations, and units, then advance turns toward victory; the game also supports AI automation, ruleset-driven content, and online multiplayer. The graph highlights those product stages and the shared game/runtime layers. Some links are dashed because the relevant implementation was not excerpted; documented capabilities and the source index help identify subsystems but do not prove every runtime call.

Main entry points: [`core/src/com/unciv/logic/GameInfo.kt`](https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/GameInfo.kt) (Game state), [`core/src/com/unciv/UncivGame.kt`](https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/UncivGame.kt) (Game runtime), [`server/src/com/unciv/app/server/UncivServer.kt`](https://github.com/yairm210/unciv/blob/master/server/src/com/unciv/app/server/UncivServer.kt) (Multiplayer server), [`core/src/com/unciv/logic/civilization/Civilization.kt`](https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/civilization/Civilization.kt) (Civilization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client and presentation"]
  node_unciv["Game runtime<br/>[UncivGame.kt]"]
  node_android["Android client<br/>[AndroidLauncher.kt]"]
  node_desktop["Desktop client<br/>[DesktopLauncher.kt]"]
  node_gameview["Game view"]
end

subgraph group_session["Game session"]
  node_gameinfo["Game state<br/>[GameInfo.kt]"]
  node_turns["Turn progression<br/>[TurnManager.kt]"]
  node_civilization["Civilization<br/>[Civilization.kt]"]
  node_city["City management<br/>[City.kt]"]
  node_automation["AI automation"]
  node_save["Save and load<br/>[UncivFiles.kt]"]
end

subgraph group_world["World and rules"]
  node_ruleset["Rulesets and mods<br/>[Ruleset.kt]"]
  node_uniques["Rule effects<br/>[Unique.kt]"]
  node_unit["Units<br/>[MapUnit.kt]"]
  node_tile["Hex map<br/>[Tile.kt]"]
  node_battle["Combat<br/>[Battle.kt]"]
  node_stats["Game statistics<br/>[Stats.kt]"]
end

subgraph group_multiplayer["Online play"]
  node_multiplayer["Multiplayer client<br/>[Multiplayer.kt]"]
  node_api["Network API<br/>[ApiV2.kt]"]
  node_server["Multiplayer server<br/>[UncivServer.kt]"]
  node_storage[("Server storage")]
end

node_player(("Player"))
node_remote(("Remote players"))

node_player -.->|"plays on"| node_android
node_player -.->|"plays on"| node_desktop
node_android -.->|"starts"| node_unciv
node_desktop -.->|"starts"| node_unciv
node_unciv -->|"loads state"| node_gameinfo
node_unciv -->|"loads rules"| node_ruleset
node_gameinfo -.->|"presents"| node_gameview
node_gameview -.->|"shows game"| node_player
node_gameinfo -->|"advances turn"| node_turns
node_civilization -->|"uses"| node_automation
node_turns -.->|"updates"| node_civilization
node_city -->|"belongs to"| node_civilization
node_ruleset -.->|"defines effects"| node_uniques
node_unit -.->|"owned by"| node_civilization
node_unit -.->|"occupies"| node_tile
node_battle -.->|"resolves combat"| node_unit
node_city -.->|"produces yields"| node_stats
node_gameinfo -.->|"persists"| node_save
node_player -.->|"joins online"| node_multiplayer
node_multiplayer -.->|"uses API"| node_api
node_remote -.->|"sends turns"| node_server
node_server -->|"uses services"| node_multiplayer
node_server -->|"stores files"| node_storage
node_storage -->|"serves requests"| node_server

click node_unciv "https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/UncivGame.kt"
click node_android "https://github.com/yairm210/unciv/blob/master/android/src/com/unciv/app/AndroidLauncher.kt"
click node_desktop "https://github.com/yairm210/unciv/blob/master/desktop/src/com/unciv/app/desktop/DesktopLauncher.kt"
click node_gameview "https://github.com/yairm210/unciv/tree/master/core/src/com/unciv/view"
click node_gameinfo "https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/GameInfo.kt"
click node_turns "https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/civilization/managers/TurnManager.kt"
click node_civilization "https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/civilization/Civilization.kt"
click node_city "https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/city/City.kt"
click node_automation "https://github.com/yairm210/unciv/tree/master/core/src/com/unciv/logic/automation"
click node_ruleset "https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/models/ruleset/Ruleset.kt"
click node_uniques "https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/models/ruleset/unique/Unique.kt"
click node_unit "https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/map/mapunit/MapUnit.kt"
click node_tile "https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/map/tile/Tile.kt"
click node_battle "https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/battle/Battle.kt"
click node_stats "https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/models/stats/Stats.kt"
click node_save "https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/files/UncivFiles.kt"
click node_multiplayer "https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/multiplayer/Multiplayer.kt"
click node_api "https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/multiplayer/apiv2/ApiV2.kt"
click node_server "https://github.com/yairm210/unciv/blob/master/server/src/com/unciv/app/server/UncivServer.kt"
click node_storage "https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/multiplayer/storage/UncivServerFileStorage.kt"

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_unciv,node_android,node_desktop,node_gameview toneBlue
class node_gameinfo,node_turns,node_civilization,node_city,node_automation,node_save toneAmber
class node_ruleset,node_uniques,node_unit,node_tile,node_battle,node_stats toneMint
class node_multiplayer,node_api,node_server,node_storage toneRose
class node_player,node_remote toneIndigo
```

## Components

### Client and presentation

- [Game runtime](https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/UncivGame.kt): `core/src/com/unciv/UncivGame.kt`
- [Android client](https://github.com/yairm210/unciv/blob/master/android/src/com/unciv/app/AndroidLauncher.kt): `android/src/com/unciv/app/AndroidLauncher.kt`
- [Desktop client](https://github.com/yairm210/unciv/blob/master/desktop/src/com/unciv/app/desktop/DesktopLauncher.kt): `desktop/src/com/unciv/app/desktop/DesktopLauncher.kt`
- [Game view](https://github.com/yairm210/unciv/tree/master/core/src/com/unciv/view): `core/src/com/unciv/view`

### Game session

- [Game state](https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/GameInfo.kt): `core/src/com/unciv/logic/GameInfo.kt`
- [Turn progression](https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/civilization/managers/TurnManager.kt): `core/src/com/unciv/logic/civilization/managers/TurnManager.kt`
- [Civilization](https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/civilization/Civilization.kt): `core/src/com/unciv/logic/civilization/Civilization.kt`
- [City management](https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/city/City.kt): `core/src/com/unciv/logic/city/City.kt`
- [AI automation](https://github.com/yairm210/unciv/tree/master/core/src/com/unciv/logic/automation): `core/src/com/unciv/logic/automation`
- [Save and load](https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/files/UncivFiles.kt): `core/src/com/unciv/logic/files/UncivFiles.kt`

### World and rules

- [Rulesets and mods](https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/models/ruleset/Ruleset.kt): `core/src/com/unciv/models/ruleset/Ruleset.kt`
- [Rule effects](https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/models/ruleset/unique/Unique.kt): `core/src/com/unciv/models/ruleset/unique/Unique.kt`
- [Units](https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/map/mapunit/MapUnit.kt): `core/src/com/unciv/logic/map/mapunit/MapUnit.kt`
- [Hex map](https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/map/tile/Tile.kt): `core/src/com/unciv/logic/map/tile/Tile.kt`
- [Combat](https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/battle/Battle.kt): `core/src/com/unciv/logic/battle/Battle.kt`
- [Game statistics](https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/models/stats/Stats.kt): `core/src/com/unciv/models/stats/Stats.kt`

### Online play

- [Multiplayer client](https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/multiplayer/Multiplayer.kt): `core/src/com/unciv/logic/multiplayer/Multiplayer.kt`
- [Network API](https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/multiplayer/apiv2/ApiV2.kt): `core/src/com/unciv/logic/multiplayer/apiv2/ApiV2.kt`
- [Multiplayer server](https://github.com/yairm210/unciv/blob/master/server/src/com/unciv/app/server/UncivServer.kt): `server/src/com/unciv/app/server/UncivServer.kt`
- [Server storage](https://github.com/yairm210/unciv/blob/master/core/src/com/unciv/logic/multiplayer/storage/UncivServerFileStorage.kt): `core/src/com/unciv/logic/multiplayer/storage/UncivServerFileStorage.kt`

### Other components

- **Player**
- **Remote players**

## Connections

- Player → Android client: plays on
- Player → Desktop client: plays on
- Android client → Game runtime: starts
- Desktop client → Game runtime: starts
- Game runtime → Game state: loads state (evidence: `core/src/com/unciv/UncivGame.kt`)
- Game runtime → Rulesets and mods: loads rules (evidence: `core/src/com/unciv/UncivGame.kt`)
- Game state → Game view: presents
- Game view → Player: shows game
- Game state → Turn progression: advances turn (evidence: `core/src/com/unciv/logic/GameInfo.kt`)
- Civilization → AI automation: uses (evidence: `core/src/com/unciv/logic/civilization/Civilization.kt`)
- Turn progression → Civilization: updates
- City management → Civilization: belongs to (evidence: `core/src/com/unciv/logic/city/City.kt`)
- Rulesets and mods → Rule effects: defines effects (evidence: `core/src/com/unciv/models/ruleset/unique/Unique.kt`)
- Units → Civilization: owned by (evidence: `core/src/com/unciv/logic/map/mapunit/MapUnit.kt`)
- Units → Hex map: occupies (evidence: `core/src/com/unciv/logic/map/mapunit/MapUnit.kt`)
- Combat → Units: resolves combat
- City management → Game statistics: produces yields
- Game state → Save and load: persists
- Player → Multiplayer client: joins online
- Multiplayer client → Network API: uses API
- Remote players → Multiplayer server: sends turns
- Multiplayer server → Multiplayer client: uses services (evidence: `server/src/com/unciv/app/server/UncivServer.kt`)
- Multiplayer server → Server storage: stores files (evidence: `core/src/com/unciv/logic/multiplayer/storage/UncivServerFileStorage.kt`)
- Server storage → Multiplayer server: serves requests (evidence: `core/src/com/unciv/logic/multiplayer/storage/UncivServerFileStorage.kt`)
