# enormousapplepie/lekmod architecture

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

- Interactive diagram: https://gitdiagram.com/enormousapplepie/lekmod
- Repository: https://github.com/enormousapplepie/lekmod

## Overview

Lekmod is a Civilization V gameplay mod, accompanied by a desktop installer/updater. The main user workflow is selecting a release and UI variant in the installer, downloading the mod, and configuring files for a Civilization V installation; in-game, the DLL provides gameplay rules, AI, and map-related capabilities. The README also documents a custom Lekmap mapscript, but its source is not present in the supplied tree. Several DLL subsystems are represented from filenames and documentation; unsampled implementation links are omitted rather than inferred.

Main entry points: [`LekmodInstaller/installer.py`](https://github.com/enormousapplepie/lekmod/blob/main/LekmodInstaller/installer.py) (Installer GUI), [`LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvPlayer.cpp`](https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvPlayer.cpp) (Player simulation), [`LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvGame.cpp`](https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvGame.cpp) (Game state), [`LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvMap.h`](https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvMap.h) (Map state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_install["Installer"]
  node_installer["Installer GUI<br/>[installer.py]"]
  node_release["Release lookup<br/>[updater.py]"]
  node_download["Mod downloader"]
  node_ui_config["UI configuration<br/>[ui_manager.py]"]
  node_self_update["Installer updater"]
end

subgraph group_gameplay["Gameplay Engine"]
  node_game["Game state<br/>[CvGame.cpp]"]
  node_rules["Gameplay rules<br/>[CvInfos.cpp]"]
  node_database[("Game database<br/>[Database.h]")]
  node_db_cache["Data loading"]
  node_players["Player simulation<br/>[CvPlayer.cpp]"]
  node_cities["City simulation<br/>[CvCity.cpp]"]
  node_units["Unit simulation<br/>[CvUnit.cpp]"]
  node_diplomacy["Diplomacy<br/>[CvDiplomacyAI.h]"]
end

subgraph group_decision["AI and Strategy"]
  node_ai["Player AI<br/>[CvPlayerAI.cpp]"]
  node_minor_ai["City-state AI<br/>[CvMinorCivAI.h]"]
  node_deals["Deals<br/>[CvDealClasses.h]"]
end

subgraph group_world["World and Maps"]
  node_map["Map state<br/>[CvMap.h]"]
  node_mapgen["Map generation<br/>[CvMapGenerator.cpp]"]
  node_lekmap["Lekmap script"]
end

subgraph group_bridge["Game Integration"]
  node_lua["Lua bindings<br/>[CvLuaPlayer.cpp]"]
  node_interfaces["DLL interfaces<br/>[CvDllInterfaces.h]"]
  node_worldbuilder["World Builder maps"]
end

node_player(("Mod user"))
node_drive["Google Drive"]
node_civ5["Civilization V"]

node_player -->|"chooses release"| node_installer
node_installer -->|"checks versions"| node_release
node_installer -->|"downloads release"| node_download
node_download -->|"fetches archive"| node_drive
node_installer -->|"configures UI"| node_ui_config
node_ui_config -->|"detects installation"| node_civ5
node_installer -->|"checks updates"| node_self_update
node_installer -.->|"installs mod"| node_civ5
node_player -->|"plays mod"| node_civ5
node_civ5 -.->|"runs gameplay"| node_game
node_database -.->|"provides game data"| node_db_cache
node_game -.->|"updates players"| node_players
node_players -.->|"manages cities"| node_cities
node_players -.->|"manages units"| node_units
node_players -.->|"uses AI"| node_ai
node_players -.->|"uses city-state AI"| node_minor_ai
node_diplomacy -.->|"evaluates deals"| node_deals
node_game -.->|"uses map state"| node_map
node_mapgen -.->|"generates map"| node_map
node_player -->|"customizes map"| node_lekmap
node_lua -->|"exposes player actions"| node_players
node_interfaces -.->|"exposes DLL API"| node_civ5
node_worldbuilder -.->|"represents map data"| node_map

click node_installer "https://github.com/enormousapplepie/lekmod/blob/main/LekmodInstaller/installer.py"
click node_release "https://github.com/enormousapplepie/lekmod/blob/main/LekmodInstaller/updater.py"
click node_download "https://github.com/enormousapplepie/lekmod/blob/main/LekmodInstaller/google_drive_api.py"
click node_ui_config "https://github.com/enormousapplepie/lekmod/blob/main/LekmodInstaller/ui_manager.py"
click node_self_update "https://github.com/enormousapplepie/lekmod/blob/main/LekmodInstaller/installer_updater.py"
click node_game "https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvGame.cpp"
click node_rules "https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvInfos.cpp"
click node_database "https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvGameDatabase/include/Database.h"
click node_db_cache "https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvGameCoreDLLUtil/include/ICvDLLDatabaseUtility.h"
click node_players "https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvPlayer.cpp"
click node_cities "https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvCity.cpp"
click node_units "https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvUnit.cpp"
click node_diplomacy "https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvDiplomacyAI.h"
click node_ai "https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvPlayerAI.cpp"
click node_minor_ai "https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvMinorCivAI.h"
click node_deals "https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvDealClasses.h"
click node_map "https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvMap.h"
click node_mapgen "https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvMapGenerator.cpp"
click node_lua "https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/Lua/CvLuaPlayer.cpp"
click node_interfaces "https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvGameCoreDLLUtil/include/CvDllInterfaces.h"
click node_worldbuilder "https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvWorldBuilderMap/include/CvWorldBuilderMap.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_installer,node_release,node_download,node_ui_config,node_self_update,node_player toneBlue
class node_game,node_rules,node_database,node_db_cache,node_players,node_cities,node_units,node_diplomacy toneAmber
class node_ai,node_minor_ai,node_deals toneMint
class node_map,node_mapgen,node_lekmap toneRose
class node_lua,node_interfaces,node_worldbuilder,node_drive,node_civ5 toneIndigo
```

## Components

### Installer

- [Installer GUI](https://github.com/enormousapplepie/lekmod/blob/main/LekmodInstaller/installer.py): `LekmodInstaller/installer.py`
- [Release lookup](https://github.com/enormousapplepie/lekmod/blob/main/LekmodInstaller/updater.py): `LekmodInstaller/updater.py`
- [Mod downloader](https://github.com/enormousapplepie/lekmod/blob/main/LekmodInstaller/google_drive_api.py): `LekmodInstaller/google_drive_api.py`
- [UI configuration](https://github.com/enormousapplepie/lekmod/blob/main/LekmodInstaller/ui_manager.py): `LekmodInstaller/ui_manager.py`
- [Installer updater](https://github.com/enormousapplepie/lekmod/blob/main/LekmodInstaller/installer_updater.py): `LekmodInstaller/installer_updater.py`

### Gameplay Engine

- [Game state](https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvGame.cpp): `LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvGame.cpp`
- [Gameplay rules](https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvInfos.cpp): `LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvInfos.cpp`
- [Game database](https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvGameDatabase/include/Database.h): `LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvGameDatabase/include/Database.h`
- [Data loading](https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvGameCoreDLLUtil/include/ICvDLLDatabaseUtility.h): `LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvGameCoreDLLUtil/include/ICvDLLDatabaseUtility.h`
- [Player simulation](https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvPlayer.cpp): `LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvPlayer.cpp`
- [City simulation](https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvCity.cpp): `LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvCity.cpp`
- [Unit simulation](https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvUnit.cpp): `LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvUnit.cpp`
- [Diplomacy](https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvDiplomacyAI.h): `LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvDiplomacyAI.h`

### AI and Strategy

- [Player AI](https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvPlayerAI.cpp): `LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvPlayerAI.cpp`
- [City-state AI](https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvMinorCivAI.h): `LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvMinorCivAI.h`
- [Deals](https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvDealClasses.h): `LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvDealClasses.h`

### World and Maps

- [Map state](https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvMap.h): `LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvMap.h`
- [Map generation](https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvMapGenerator.cpp): `LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvMapGenerator.cpp`
- **Lekmap script**

### Game Integration

- [Lua bindings](https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/Lua/CvLuaPlayer.cpp): `LEKMOD_DLL/CvGameCoreDLL_Expansion2/Lua/CvLuaPlayer.cpp`
- [DLL interfaces](https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvGameCoreDLLUtil/include/CvDllInterfaces.h): `LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvGameCoreDLLUtil/include/CvDllInterfaces.h`
- [World Builder maps](https://github.com/enormousapplepie/lekmod/blob/main/LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvWorldBuilderMap/include/CvWorldBuilderMap.h): `LEKMOD_DLL/CvGameCoreDLL_Expansion2/CvWorldBuilderMap/include/CvWorldBuilderMap.h`

### Other components

- **Mod user**
- **Google Drive**
- **Civilization V**

## Connections

- Mod user → Installer GUI: chooses release (evidence: `LekmodInstaller/installer.py`)
- Installer GUI → Release lookup: checks versions (evidence: `LekmodInstaller/installer.py`)
- Installer GUI → Mod downloader: downloads release (evidence: `LekmodInstaller/installer.py`)
- Mod downloader → Google Drive: fetches archive (evidence: `LekmodInstaller/google_drive_api.py`)
- Installer GUI → UI configuration: configures UI (evidence: `LekmodInstaller/installer.py`)
- UI configuration → Civilization V: detects installation (evidence: `LekmodInstaller/ui_manager.py`)
- Installer GUI → Installer updater: checks updates (evidence: `LekmodInstaller/installer.py`)
- Installer GUI → Civilization V: installs mod
- Mod user → Civilization V: plays mod
- Civilization V → Game state: runs gameplay
- Game database → Data loading: provides game data
- Game state → Player simulation: updates players
- Player simulation → City simulation: manages cities
- Player simulation → Unit simulation: manages units
- Player simulation → Player AI: uses AI
- Player simulation → City-state AI: uses city-state AI
- Diplomacy → Deals: evaluates deals
- Game state → Map state: uses map state
- Map generation → Map state: generates map
- Mod user → Lekmap script: customizes map
- Lua bindings → Player simulation: exposes player actions (evidence: `LEKMOD_DLL/CvGameCoreDLL_Expansion2/Lua/CvLuaPlayer.cpp`)
- DLL interfaces → Civilization V: exposes DLL API
- World Builder maps → Map state: represents map data
