# syamkushaini/kempen-222-game architecture

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

- Interactive diagram: https://gitdiagram.com/syamkushaini/kempen-222-game
- Repository: https://github.com/syamkushaini/kempen-222-game

## Overview

Kempen 222 is a browser-based Malaysian political strategy game. Players choose a by-election, state or general contest, a hung-parliament negotiation, or a multi-term career; they manage a party and campaign, then see election results and, where needed, form a government. The browser UI dispatches player choices through a central store into campaign and election simulation modules. The README documents broad features such as polling, party management, House business and career events; some of those implementations were not sampled, so their connections are shown only where documented or indexed.

Main entry points: [`src/state/store.ts`](https://github.com/syamkushaini/kempen-222-game/blob/main/src/state/store.ts) (Game command store), [`src/sim/election.ts`](https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/election.ts) (Election outcomes), [`src/ui/App.tsx`](https://github.com/syamkushaini/kempen-222-game/blob/main/src/ui/App.tsx) (Game screens), [`src/sim/campaign/career.ts`](https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/campaign/career.ts) (Career simulation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Browser interface"]
  node_app["Game screens<br/>[App.tsx]"]
  node_campaign_ui["Campaign screens<br/>[ActionsTab.tsx]"]
  node_talks_ui["Government talks<br/>[Formation.tsx]"]
  node_results_ui["Election night<br/>[ElectionNight.tsx]"]
  node_map_ui["Contest map<br/>[MapView.tsx]"]
end

subgraph group_state["Game state"]
  node_store["Game command store<br/>[store.ts]"]
  node_game_state["Game setup and migration<br/>[game.ts]"]
  node_save_data[("Saves and profile<br/>[saves.ts]")]
end

subgraph group_campaign["Campaign and career"]
  node_campaign_turn["Campaign turns<br/>[turn.ts]"]
  node_actions["Campaign actions<br/>[actions.ts]"]
  node_career["Career simulation<br/>[career.ts]"]
  node_diplomacy["Party diplomacy<br/>[diplomacy.ts]"]
  node_formation["Government formation<br/>[formation.ts]"]
  node_government["House and government<br/>[govern.ts]"]
  node_polls["Campaign polling<br/>[polls.ts]"]
  node_career_events["Career events<br/>[events.ts]"]
end

subgraph group_simulation["Election simulation"]
  node_election["Election outcomes<br/>[election.ts]"]
  node_projection["Seat projection<br/>[project.ts]"]
  node_dynamics["Voter dynamics<br/>[dynamics.ts]"]
end

subgraph group_content["Game data and language"]
  node_world["Contest scenarios<br/>[world.ts]"]
  node_strings["Localized game text<br/>[strings.ts]"]
end

node_player(("Player"))

node_player -->|"plays"| node_app
node_app -->|"dispatches choices"| node_store
node_campaign_ui -->|"dispatches actions"| node_store
node_talks_ui -->|"dispatches offers"| node_store
node_store -->|"loads scenario"| node_world
node_store -->|"calls career logic"| node_career
node_store -->|"resolves scenes"| node_diplomacy
node_store -->|"handles offers"| node_formation
node_store -->|"calls government logic"| node_government
node_store -->|"mutates game state"| node_game_state
node_store -->|"persists saves"| node_save_data
node_app -->|"renders screens"| node_campaign_ui
node_app -->|"renders talks"| node_talks_ui
node_results_ui -->|"reads game state"| node_store
node_map_ui -->|"reads game state"| node_store
node_campaign_turn -->|"applies actions"| node_actions
node_campaign_turn -->|"runs diplomacy"| node_diplomacy
node_career -->|"advances campaign"| node_campaign_turn
node_career -->|"processes events"| node_career_events
node_career -->|"runs House systems"| node_government
node_diplomacy -->|"projects pact effects"| node_election
node_formation -.->|"uses seat results"| node_election
node_election -->|"projects seats"| node_projection
node_election -->|"applies voter shifts"| node_dynamics
node_world -->|"builds contest world"| node_election
node_campaign_ui -.->|"shows polling"| node_polls
node_results_ui -->|"shows election results"| node_election
node_app -.->|"localizes interface"| node_strings

click node_app "https://github.com/syamkushaini/kempen-222-game/blob/main/src/ui/App.tsx"
click node_campaign_ui "https://github.com/syamkushaini/kempen-222-game/blob/main/src/ui/ActionsTab.tsx"
click node_talks_ui "https://github.com/syamkushaini/kempen-222-game/blob/main/src/ui/Formation.tsx"
click node_results_ui "https://github.com/syamkushaini/kempen-222-game/blob/main/src/ui/ElectionNight.tsx"
click node_map_ui "https://github.com/syamkushaini/kempen-222-game/blob/main/src/ui/MapView.tsx"
click node_store "https://github.com/syamkushaini/kempen-222-game/blob/main/src/state/store.ts"
click node_game_state "https://github.com/syamkushaini/kempen-222-game/blob/main/src/state/game.ts"
click node_save_data "https://github.com/syamkushaini/kempen-222-game/blob/main/src/state/saves.ts"
click node_world "https://github.com/syamkushaini/kempen-222-game/blob/main/src/data/world.ts"
click node_strings "https://github.com/syamkushaini/kempen-222-game/blob/main/src/i18n/strings.ts"
click node_campaign_turn "https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/campaign/turn.ts"
click node_actions "https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/campaign/actions.ts"
click node_career "https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/campaign/career.ts"
click node_diplomacy "https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/campaign/diplomacy.ts"
click node_formation "https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/campaign/formation.ts"
click node_government "https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/campaign/govern.ts"
click node_election "https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/election.ts"
click node_projection "https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/project.ts"
click node_dynamics "https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/dynamics.ts"
click node_polls "https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/campaign/polls.ts"
click node_career_events "https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/campaign/events.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_campaign_ui,node_talks_ui,node_results_ui,node_map_ui toneBlue
class node_store,node_game_state,node_save_data toneAmber
class node_campaign_turn,node_actions,node_career,node_diplomacy,node_formation,node_government,node_polls,node_career_events toneMint
class node_election,node_projection,node_dynamics toneRose
class node_world,node_strings,node_player toneIndigo
```

## Components

### Browser interface

- [Game screens](https://github.com/syamkushaini/kempen-222-game/blob/main/src/ui/App.tsx): `src/ui/App.tsx`
- [Campaign screens](https://github.com/syamkushaini/kempen-222-game/blob/main/src/ui/ActionsTab.tsx): `src/ui/ActionsTab.tsx`
- [Government talks](https://github.com/syamkushaini/kempen-222-game/blob/main/src/ui/Formation.tsx): `src/ui/Formation.tsx`
- [Election night](https://github.com/syamkushaini/kempen-222-game/blob/main/src/ui/ElectionNight.tsx): `src/ui/ElectionNight.tsx`
- [Contest map](https://github.com/syamkushaini/kempen-222-game/blob/main/src/ui/MapView.tsx): `src/ui/MapView.tsx`

### Game state

- [Game command store](https://github.com/syamkushaini/kempen-222-game/blob/main/src/state/store.ts): `src/state/store.ts`
- [Game setup and migration](https://github.com/syamkushaini/kempen-222-game/blob/main/src/state/game.ts): `src/state/game.ts`
- [Saves and profile](https://github.com/syamkushaini/kempen-222-game/blob/main/src/state/saves.ts): `src/state/saves.ts`

### Campaign and career

- [Campaign turns](https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/campaign/turn.ts): `src/sim/campaign/turn.ts`
- [Campaign actions](https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/campaign/actions.ts): `src/sim/campaign/actions.ts`
- [Career simulation](https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/campaign/career.ts): `src/sim/campaign/career.ts`
- [Party diplomacy](https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/campaign/diplomacy.ts): `src/sim/campaign/diplomacy.ts`
- [Government formation](https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/campaign/formation.ts): `src/sim/campaign/formation.ts`
- [House and government](https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/campaign/govern.ts): `src/sim/campaign/govern.ts`
- [Campaign polling](https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/campaign/polls.ts): `src/sim/campaign/polls.ts`
- [Career events](https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/campaign/events.ts): `src/sim/campaign/events.ts`

### Election simulation

- [Election outcomes](https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/election.ts): `src/sim/election.ts`
- [Seat projection](https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/project.ts): `src/sim/project.ts`
- [Voter dynamics](https://github.com/syamkushaini/kempen-222-game/blob/main/src/sim/dynamics.ts): `src/sim/dynamics.ts`

### Game data and language

- [Contest scenarios](https://github.com/syamkushaini/kempen-222-game/blob/main/src/data/world.ts): `src/data/world.ts`
- [Localized game text](https://github.com/syamkushaini/kempen-222-game/blob/main/src/i18n/strings.ts): `src/i18n/strings.ts`

### Other components

- **Player**

## Connections

- Player → Game screens: plays (evidence: `README.md`)
- Game screens → Game command store: dispatches choices (evidence: `src/ui/App.tsx`)
- Campaign screens → Game command store: dispatches actions
- Government talks → Game command store: dispatches offers (evidence: `src/ui/Formation.tsx`)
- Game command store → Contest scenarios: loads scenario (evidence: `src/state/store.ts`)
- Game command store → Career simulation: calls career logic (evidence: `src/state/store.ts`)
- Game command store → Party diplomacy: resolves scenes (evidence: `src/state/store.ts`)
- Game command store → Government formation: handles offers (evidence: `src/state/store.ts`)
- Game command store → House and government: calls government logic (evidence: `src/state/store.ts`)
- Game command store → Game setup and migration: mutates game state (evidence: `src/state/store.ts`)
- Game command store → Saves and profile: persists saves (evidence: `src/state/store.ts`)
- Game screens → Campaign screens: renders screens (evidence: `src/ui/App.tsx`)
- Game screens → Government talks: renders talks (evidence: `src/ui/App.tsx`)
- Election night → Game command store: reads game state (evidence: `src/ui/ElectionNight.tsx`)
- Contest map → Game command store: reads game state (evidence: `src/ui/MapView.tsx`)
- Campaign turns → Campaign actions: applies actions (evidence: `src/sim/campaign/turn.ts`)
- Campaign turns → Party diplomacy: runs diplomacy (evidence: `src/sim/campaign/turn.ts`)
- Career simulation → Campaign turns: advances campaign (evidence: `src/sim/campaign/career.ts`)
- Career simulation → Career events: processes events (evidence: `src/sim/campaign/career.ts`)
- Career simulation → House and government: runs House systems (evidence: `src/sim/campaign/career.ts`)
- Party diplomacy → Election outcomes: projects pact effects (evidence: `src/sim/campaign/diplomacy.ts`)
- Government formation → Election outcomes: uses seat results
- Election outcomes → Seat projection: projects seats (evidence: `src/sim/election.ts`)
- Election outcomes → Voter dynamics: applies voter shifts (evidence: `src/sim/election.ts`)
- Contest scenarios → Election outcomes: builds contest world (evidence: `src/data/world.ts`)
- Campaign screens → Campaign polling: shows polling (evidence: `README.md`)
- Election night → Election outcomes: shows election results (evidence: `src/ui/ElectionNight.tsx`)
- Game screens → Localized game text: localizes interface (evidence: `README.md`)
