# jdtrepanier/kakistocracy architecture

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

- Interactive diagram: https://gitdiagram.com/jdtrepanier/kakistocracy
- Repository: https://github.com/jdtrepanier/kakistocracy

## Overview

Kakistocracy is a browser-based satirical term-survival simulation. The player starts a run, takes executive actions and navigates monthly resolution, reports, and eventual endings; city driving, room exploration, and tactical battles provide distinct gameplay branches. The graph emphasizes the app’s screen router, Zustand game state, simulation engine, and domain data. Several subsystem links rely on the SOURCE INDEX or README because their implementation excerpts were not provided; those links are dashed where the runtime relationship is not directly shown.

Main entry points: [`src/store/gameStore.ts`](https://github.com/jdtrepanier/kakistocracy/blob/main/src/store/gameStore.ts) (Game state), [`src/App.tsx`](https://github.com/jdtrepanier/kakistocracy/blob/main/src/App.tsx) (Screen router), [`src/ui/city/CityScreen.tsx`](https://github.com/jdtrepanier/kakistocracy/blob/main/src/ui/city/CityScreen.tsx) (City screen), [`src/ui/battle/BattleView.tsx`](https://github.com/jdtrepanier/kakistocracy/blob/main/src/ui/battle/BattleView.tsx) (Battle display)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Game interface"]
  node_app["Screen router<br/>[App.tsx]"]
  node_intro["Intro screen<br/>[IntroScreen.tsx]"]
  node_game_screen["Game screen<br/>[GameScreen.tsx]"]
  node_city_screen["City screen<br/>[CityScreen.tsx]"]
  node_report["Month report<br/>[MonthEndReport.tsx]"]
  node_ending["Ending screen<br/>[EndingScreen.tsx]"]
  node_hud["Status HUD<br/>[Hud.tsx]"]
  node_battle_view["Battle display<br/>[BattleView.tsx]"]
end

subgraph group_state["Run orchestration"]
  node_store["Game state<br/>[gameStore.ts]"]
end

subgraph group_simulation["Simulation engine"]
  node_resolve["Action resolution<br/>[resolve.ts]"]
  node_economy["Monthly economy<br/>[economy.ts]"]
end

subgraph group_world["World and encounters"]
  node_battle["Tactical battle<br/>[battle.ts]"]
  node_movement["Grid movement<br/>[movement.ts]"]
  node_driving["Driving rules<br/>[driving.ts]"]
  node_pedestrians["Pedestrian behavior<br/>[pedestrians.ts]"]
end

subgraph group_content["Game content"]
  node_city_data["City map<br/>[cityMap.ts]"]
  node_actions_data["Executive actions<br/>[actions.ts]"]
  node_balance["Balance data<br/>[balance.ts]"]
  node_battlegrounds["Battle maps<br/>[battlegrounds.ts]"]
  node_rosters["Battle rosters<br/>[battleRosters.ts]"]
  node_characters["Characters<br/>[characters.ts]"]
  node_driving_data["Driving data<br/>[driving.ts]"]
  node_translations["Translations<br/>[translate.ts]"]
  node_english["English strings<br/>[en.ts]"]
  node_french["French strings<br/>[fr.ts]"]
end

node_player(("Player"))

node_player -->|"plays"| node_app
node_app -->|"routes to"| node_intro
node_app -->|"routes to"| node_game_screen
node_app -->|"routes to"| node_city_screen
node_app -->|"routes to"| node_report
node_app -->|"routes to"| node_ending
node_app -->|"reads state"| node_store
node_app -->|"renders"| node_hud
node_intro -.->|"updates run"| node_store
node_game_screen -.->|"dispatches actions"| node_store
node_city_screen -.->|"updates city play"| node_store
node_store -->|"resolves actions"| node_resolve
node_store -->|"advances battle"| node_battle
node_store -.->|"ticks month"| node_economy
node_store -->|"gets action"| node_actions_data
node_store -->|"gets balance"| node_balance
node_store -.->|"gets map"| node_battlegrounds
node_store -.->|"gets roster"| node_rosters
node_resolve -->|"uses balance"| node_balance
node_economy -->|"uses balance"| node_balance
node_battle -->|"checks tiles"| node_movement
node_battle_view -.->|"reads battle state"| node_store
node_battle_view -.->|"renders battle"| node_battle
node_battle_view -.->|"renders map"| node_battlegrounds
node_battle_view -.->|"renders units"| node_characters
node_city_screen -.->|"loads map"| node_city_data
node_city_screen -.->|"uses driving rules"| node_driving
node_city_screen -.->|"updates pedestrians"| node_pedestrians
node_city_data -.->|"uses map data"| node_driving_data
node_translations -.->|"selects language"| node_english
node_translations -.->|"selects language"| node_french

click node_app "https://github.com/jdtrepanier/kakistocracy/blob/main/src/App.tsx"
click node_intro "https://github.com/jdtrepanier/kakistocracy/blob/main/src/ui/screens/IntroScreen.tsx"
click node_game_screen "https://github.com/jdtrepanier/kakistocracy/blob/main/src/ui/screens/GameScreen.tsx"
click node_city_screen "https://github.com/jdtrepanier/kakistocracy/blob/main/src/ui/city/CityScreen.tsx"
click node_report "https://github.com/jdtrepanier/kakistocracy/blob/main/src/ui/screens/MonthEndReport.tsx"
click node_ending "https://github.com/jdtrepanier/kakistocracy/blob/main/src/ui/screens/EndingScreen.tsx"
click node_hud "https://github.com/jdtrepanier/kakistocracy/blob/main/src/ui/hud/Hud.tsx"
click node_store "https://github.com/jdtrepanier/kakistocracy/blob/main/src/store/gameStore.ts"
click node_resolve "https://github.com/jdtrepanier/kakistocracy/blob/main/src/engine/resolve.ts"
click node_economy "https://github.com/jdtrepanier/kakistocracy/blob/main/src/engine/economy.ts"
click node_battle "https://github.com/jdtrepanier/kakistocracy/blob/main/src/engine/battle.ts"
click node_movement "https://github.com/jdtrepanier/kakistocracy/blob/main/src/engine/movement.ts"
click node_driving "https://github.com/jdtrepanier/kakistocracy/blob/main/src/engine/driving.ts"
click node_pedestrians "https://github.com/jdtrepanier/kakistocracy/blob/main/src/engine/pedestrians.ts"
click node_battle_view "https://github.com/jdtrepanier/kakistocracy/blob/main/src/ui/battle/BattleView.tsx"
click node_city_data "https://github.com/jdtrepanier/kakistocracy/blob/main/src/data/cityMap.ts"
click node_actions_data "https://github.com/jdtrepanier/kakistocracy/blob/main/src/data/actions.ts"
click node_balance "https://github.com/jdtrepanier/kakistocracy/blob/main/src/data/balance.ts"
click node_battlegrounds "https://github.com/jdtrepanier/kakistocracy/blob/main/src/data/battlegrounds.ts"
click node_rosters "https://github.com/jdtrepanier/kakistocracy/blob/main/src/data/battleRosters.ts"
click node_characters "https://github.com/jdtrepanier/kakistocracy/blob/main/src/data/characters.ts"
click node_driving_data "https://github.com/jdtrepanier/kakistocracy/blob/main/src/data/driving.ts"
click node_translations "https://github.com/jdtrepanier/kakistocracy/blob/main/src/i18n/translate.ts"
click node_english "https://github.com/jdtrepanier/kakistocracy/blob/main/src/i18n/en.ts"
click node_french "https://github.com/jdtrepanier/kakistocracy/blob/main/src/i18n/fr.ts"

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_app,node_intro,node_game_screen,node_city_screen,node_report,node_ending,node_hud,node_battle_view toneBlue
class node_store toneAmber
class node_resolve,node_economy toneMint
class node_battle,node_movement,node_driving,node_pedestrians toneRose
class node_city_data,node_actions_data,node_balance,node_battlegrounds,node_rosters,node_characters,node_driving_data,node_translations,node_english,node_french,node_player toneIndigo
```

## Components

### Game interface

- [Screen router](https://github.com/jdtrepanier/kakistocracy/blob/main/src/App.tsx): `src/App.tsx`
- [Intro screen](https://github.com/jdtrepanier/kakistocracy/blob/main/src/ui/screens/IntroScreen.tsx): `src/ui/screens/IntroScreen.tsx`
- [Game screen](https://github.com/jdtrepanier/kakistocracy/blob/main/src/ui/screens/GameScreen.tsx): `src/ui/screens/GameScreen.tsx`
- [City screen](https://github.com/jdtrepanier/kakistocracy/blob/main/src/ui/city/CityScreen.tsx): `src/ui/city/CityScreen.tsx`
- [Month report](https://github.com/jdtrepanier/kakistocracy/blob/main/src/ui/screens/MonthEndReport.tsx): `src/ui/screens/MonthEndReport.tsx`
- [Ending screen](https://github.com/jdtrepanier/kakistocracy/blob/main/src/ui/screens/EndingScreen.tsx): `src/ui/screens/EndingScreen.tsx`
- [Status HUD](https://github.com/jdtrepanier/kakistocracy/blob/main/src/ui/hud/Hud.tsx): `src/ui/hud/Hud.tsx`
- [Battle display](https://github.com/jdtrepanier/kakistocracy/blob/main/src/ui/battle/BattleView.tsx): `src/ui/battle/BattleView.tsx`

### Run orchestration

- [Game state](https://github.com/jdtrepanier/kakistocracy/blob/main/src/store/gameStore.ts): `src/store/gameStore.ts`

### Simulation engine

- [Action resolution](https://github.com/jdtrepanier/kakistocracy/blob/main/src/engine/resolve.ts): `src/engine/resolve.ts`
- [Monthly economy](https://github.com/jdtrepanier/kakistocracy/blob/main/src/engine/economy.ts): `src/engine/economy.ts`

### World and encounters

- [Tactical battle](https://github.com/jdtrepanier/kakistocracy/blob/main/src/engine/battle.ts): `src/engine/battle.ts`
- [Grid movement](https://github.com/jdtrepanier/kakistocracy/blob/main/src/engine/movement.ts): `src/engine/movement.ts`
- [Driving rules](https://github.com/jdtrepanier/kakistocracy/blob/main/src/engine/driving.ts): `src/engine/driving.ts`
- [Pedestrian behavior](https://github.com/jdtrepanier/kakistocracy/blob/main/src/engine/pedestrians.ts): `src/engine/pedestrians.ts`

### Game content

- [City map](https://github.com/jdtrepanier/kakistocracy/blob/main/src/data/cityMap.ts): `src/data/cityMap.ts`
- [Executive actions](https://github.com/jdtrepanier/kakistocracy/blob/main/src/data/actions.ts): `src/data/actions.ts`
- [Balance data](https://github.com/jdtrepanier/kakistocracy/blob/main/src/data/balance.ts): `src/data/balance.ts`
- [Battle maps](https://github.com/jdtrepanier/kakistocracy/blob/main/src/data/battlegrounds.ts): `src/data/battlegrounds.ts`
- [Battle rosters](https://github.com/jdtrepanier/kakistocracy/blob/main/src/data/battleRosters.ts): `src/data/battleRosters.ts`
- [Characters](https://github.com/jdtrepanier/kakistocracy/blob/main/src/data/characters.ts): `src/data/characters.ts`
- [Driving data](https://github.com/jdtrepanier/kakistocracy/blob/main/src/data/driving.ts): `src/data/driving.ts`
- [Translations](https://github.com/jdtrepanier/kakistocracy/blob/main/src/i18n/translate.ts): `src/i18n/translate.ts`
- [English strings](https://github.com/jdtrepanier/kakistocracy/blob/main/src/i18n/en.ts): `src/i18n/en.ts`
- [French strings](https://github.com/jdtrepanier/kakistocracy/blob/main/src/i18n/fr.ts): `src/i18n/fr.ts`

### Other components

- **Player**

## Connections

- Player → Screen router: plays (evidence: `README.md`)
- Screen router → Intro screen: routes to (evidence: `src/App.tsx`)
- Screen router → Game screen: routes to (evidence: `src/App.tsx`)
- Screen router → City screen: routes to (evidence: `src/App.tsx`)
- Screen router → Month report: routes to (evidence: `src/App.tsx`)
- Screen router → Ending screen: routes to (evidence: `src/App.tsx`)
- Screen router → Game state: reads state (evidence: `src/App.tsx`)
- Screen router → Status HUD: renders (evidence: `src/App.tsx`)
- Intro screen → Game state: updates run (evidence: `src/ui/screens/IntroScreen.tsx`)
- Game screen → Game state: dispatches actions
- City screen → Game state: updates city play (evidence: `src/ui/city/CityScreen.tsx`)
- Game state → Action resolution: resolves actions (evidence: `src/store/gameStore.ts`)
- Game state → Tactical battle: advances battle (evidence: `src/store/gameStore.ts`)
- Game state → Monthly economy: ticks month (evidence: `src/store/gameStore.ts`)
- Game state → Executive actions: gets action (evidence: `src/store/gameStore.ts`)
- Game state → Balance data: gets balance (evidence: `src/store/gameStore.ts`)
- Game state → Battle maps: gets map (evidence: `src/store/gameStore.ts`)
- Game state → Battle rosters: gets roster (evidence: `src/store/gameStore.ts`)
- Action resolution → Balance data: uses balance (evidence: `src/engine/resolve.ts`)
- Monthly economy → Balance data: uses balance (evidence: `src/engine/economy.ts`)
- Tactical battle → Grid movement: checks tiles (evidence: `src/engine/battle.ts`)
- Battle display → Game state: reads battle state (evidence: `src/ui/battle/BattleView.tsx`)
- Battle display → Tactical battle: renders battle (evidence: `src/ui/battle/BattleView.tsx`)
- Battle display → Battle maps: renders map (evidence: `src/ui/battle/BattleView.tsx`)
- Battle display → Characters: renders units (evidence: `src/ui/battle/BattleView.tsx`)
- City screen → City map: loads map (evidence: `src/ui/city/CityScreen.tsx`)
- City screen → Driving rules: uses driving rules (evidence: `src/ui/city/CityScreen.tsx`)
- City screen → Pedestrian behavior: updates pedestrians (evidence: `src/ui/city/CityScreen.tsx`)
- City map → Driving data: uses map data
- Translations → English strings: selects language (evidence: `src/i18n/translate.ts`)
- Translations → French strings: selects language (evidence: `src/i18n/translate.ts`)
