# wjnct55555/liberty-unquenched architecture

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

- Interactive diagram: https://gitdiagram.com/wjnct55555/liberty-unquenched
- Repository: https://github.com/wjnct55555/liberty-unquenched

## Overview

#### Purpose and runtime

Liberty Unquenched is a browser-only historical political and war simulation centered on CNT-FAI during Spain’s Second Republic and Civil War. React 19 and TypeScript run all rules and UI client-side; there is no backend, persistence layer, API key, or external game service. Vite boots from `index.html` through `src/main.tsx`, with the application root in `src/App.tsx`.

#### Application composition

`App` assembles the game’s screen-level experience: start flow, primary political interface, modal panels, events, ending states, music, and the optional war map. The main layout is divided into status/navigation surfaces and interactive content:
- `src/components/MainArea.tsx`
- `src/components/SidePanel.tsx`
- `src/components/TopBar.tsx`

Specialized overlays expose domestic politics, policy/economy, advisors, journals, achievements, super-events, and conclusions.

#### Central game state boundary

`src/game/GameContext.tsx` is the primary political-simulation state and mutation boundary, likely providing shared state/actions to UI and rules. Its domain contract is defined by:
- `src/game/types.ts`
- `src/game/data.ts`
- `src/game/constants.ts`

Political state includes date/progression, resources, parties, factions, social-class support, government, effects, active events, and related unlock/condition state. Game UI should consume and mutate this context rather than embedding rule decisions in components.

#### Content-driven political rule modules

Historical and player-driven content is organized as TypeScript rule definitions rather than remote data:
- `src/game/action_affairs/index.ts`
- `src/game/government_affairs/index.ts`
- `src/game/military_affairs/index.ts`

These modules define available decisions such as organizing, propaganda, policy, labor, diplomacy, and militia actions, including prerequisites, costs, cooldowns, and effects. Advisors and long-term objectives are parallel registries:
- `src/game/advisors/index.ts`
- `src/game/journal/index.ts`

The UI presents these definitions and previews effects via components such as `src/components/AdvisorPanel.tsx` and `src/components/EffectPreviewTooltip.tsx`.

#### Events and progression

The event registry drives timed/conditional historical progression and player choices:
- `src/game/events/index.ts`
- `src/game/events/elections_1931_results.tsx`
- `src/game/events/civil_war/civil_war_setup.ts`

Events read political state, apply mutations, and can branch into elections, crises, organization formation, revolts, civil-war setup, surrender, or ending outcomes. `src/components/EventBoard.tsx` renders regular choices; `src/components/SuperEvent.tsx` and `src/components/EndingScreen.tsx` handle high-impact narrative/state transitions.

#### Politics, electoral computation, and visualization

Party definitions, display names, coalitions, law stances, and election calculations form an interdependent political subsystem:
- `src/game/parties.ts`
- `src/game/coalitions.ts`
- `src/game/utils/election.ts`

Results feed domestic-politics UI and D3 seat visualization:
- `src/components/DomesticPoliticsModal.tsx`
- `src/components/ParliamentChart.tsx`
- `src/lib/d3-parliament.ts`

Changes to parties, support, or coalitions must preserve these shared type and calculation contracts.

#### Map and war subsystem

The province war game is a distinct state/model boundary from ordinary political state:
- `src/map/types_map.ts`
- `src/map/MapView.tsx`
- `src/map/map_constants.ts`

It models provinces, control, armies, resources, buildings, supply, combat, and military actions. `src/map/ProvinceMap.tsx` renders geographic interaction using bundled GeoJSON under `public/date/`; `src/map/Sidebar.tsx` provides command controls; `src/map/lib/gameAi.ts` supplies AI behavior. `src/map/WarSummary.tsx` aggregates opposing war capacity and outcomes.

#### Assets and deployment

Static imagery, music, terrain, and geographic datasets ship with the frontend under `public/img/`, `public/music/`, and `public/date/`. GitHub Actions builds and type-checks with Node 20, then deploys Vite output to GitHub Pages:
- `.github/workflows/deploy.yml`
- `vite.config.ts`
- `package.json`

The deployment relies on `VITE_BASE_PATH` so static asset paths work under the repository’s GitHub Pages subpath.

Main entry points: [`src/game/GameContext.tsx`](https://github.com/wjnct55555/liberty-unquenched/blob/main/src/game/GameContext.tsx) (Political game context), [`src/App.tsx`](https://github.com/wjnct55555/liberty-unquenched/blob/main/src/App.tsx) (Application root), [`src/map/MapView.tsx`](https://github.com/wjnct55555/liberty-unquenched/blob/main/src/map/MapView.tsx) (War map view), [`vite.config.ts`](https://github.com/wjnct55555/liberty-unquenched/blob/main/vite.config.ts) (Vite build)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Browser Runtime"]
  node_html["Vite entry page<br/>entrypoint<br/>[index.html]"]
  node_main["React bootstrap<br/>client entry<br/>[main.tsx]"]
  node_app["Application root<br/>React composition<br/>[App.tsx]"]
  node_layout["Main game layout<br/>React UI<br/>[MainArea.tsx]"]
  node_assets["Bundled static assets<br/>public assets"]
end

subgraph group_politics["Political Simulation"]
  node_game_context{{"Political game context<br/>state boundary<br/>[GameContext.tsx]"}}
  node_game_contract["Political domain contract<br/>types and data<br/>[types.ts]"]
  node_affairs["Affairs registries<br/>rule definitions<br/>[index.ts]"]
  node_advisors_journal["Advisors &amp; objectives<br/>content registries<br/>[index.ts]"]
  node_events["Historical event registry<br/>progression rules<br/>[index.ts]"]
  node_event_ui["Events &amp; endings<br/>React overlays<br/>[EventBoard.tsx]"]
  node_elections["Election subsystem<br/>political calculation<br/>[election.ts]"]
  node_parliament_ui["Domestic politics chart<br/>D3 visualization"]
end

subgraph group_war["War Map"]
  node_map_contract{{"War state model<br/>state boundary<br/>[types_map.ts]"}}
  node_map_view["War map view<br/>React feature<br/>[MapView.tsx]"]
  node_province_map["Province map<br/>GeoJSON renderer<br/>[ProvinceMap.tsx]"]
  node_war_ai["War AI<br/>game AI<br/>[gameAi.ts]"]
  node_war_summary["War summary<br/>outcome aggregation<br/>[WarSummary.tsx]"]
end

subgraph group_delivery["Build &amp; Deploy"]
  node_build["Vite build<br/>frontend build<br/>[vite.config.ts]"]
  node_deploy["GitHub Pages deployment<br/>CI/CD workflow<br/>[deploy.yml]"]
end

node_html -->|"loads"| node_main
node_main -->|"mounts"| node_app
node_app -->|"composes"| node_layout
node_app -->|"provides state"| node_game_context
node_app -->|"opens overlays"| node_event_ui
node_app -->|"optionally shows"| node_map_view
node_layout -->|"reads and mutates"| node_game_context
node_game_context -->|"uses"| node_game_contract
node_game_context -->|"evaluates actions"| node_affairs
node_game_context -->|"tracks content"| node_advisors_journal
node_game_context -->|"evaluates progression"| node_events
node_events -->|"supplies choices"| node_event_ui
node_event_ui -->|"applies outcomes"| node_game_context
node_game_context -->|"supplies support and laws"| node_elections
node_elections -->|"produces seats"| node_parliament_ui
node_map_view -->|"reads and mutates"| node_map_contract
node_map_view -->|"renders geography"| node_province_map
node_province_map -->|"loads GeoJSON"| node_assets
node_map_view -->|"runs opposing actions"| node_war_ai
node_map_contract -->|"aggregates capacity"| node_war_summary
node_build -->|"builds entry"| node_html
node_build -->|"serves with base path"| node_assets
node_deploy -->|"runs"| node_build

click node_html "https://github.com/wjnct55555/liberty-unquenched/blob/main/index.html"
click node_main "https://github.com/wjnct55555/liberty-unquenched/blob/main/src/main.tsx"
click node_app "https://github.com/wjnct55555/liberty-unquenched/blob/main/src/App.tsx"
click node_layout "https://github.com/wjnct55555/liberty-unquenched/blob/main/src/components/MainArea.tsx"
click node_game_context "https://github.com/wjnct55555/liberty-unquenched/blob/main/src/game/GameContext.tsx"
click node_game_contract "https://github.com/wjnct55555/liberty-unquenched/blob/main/src/game/types.ts"
click node_affairs "https://github.com/wjnct55555/liberty-unquenched/blob/main/src/game/action_affairs/index.ts"
click node_advisors_journal "https://github.com/wjnct55555/liberty-unquenched/blob/main/src/game/advisors/index.ts"
click node_events "https://github.com/wjnct55555/liberty-unquenched/blob/main/src/game/events/index.ts"
click node_event_ui "https://github.com/wjnct55555/liberty-unquenched/blob/main/src/components/EventBoard.tsx"
click node_elections "https://github.com/wjnct55555/liberty-unquenched/blob/main/src/game/utils/election.ts"
click node_parliament_ui "https://github.com/wjnct55555/liberty-unquenched/blob/main/src/components/ParliamentChart.tsx"
click node_map_contract "https://github.com/wjnct55555/liberty-unquenched/blob/main/src/map/types_map.ts"
click node_map_view "https://github.com/wjnct55555/liberty-unquenched/blob/main/src/map/MapView.tsx"
click node_province_map "https://github.com/wjnct55555/liberty-unquenched/blob/main/src/map/ProvinceMap.tsx"
click node_war_ai "https://github.com/wjnct55555/liberty-unquenched/blob/main/src/map/lib/gameAi.ts"
click node_war_summary "https://github.com/wjnct55555/liberty-unquenched/blob/main/src/map/WarSummary.tsx"
click node_build "https://github.com/wjnct55555/liberty-unquenched/blob/main/vite.config.ts"
click node_deploy "https://github.com/wjnct55555/liberty-unquenched/blob/main/.github/workflows/deploy.yml"

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_html,node_main,node_app,node_layout,node_assets toneBlue
class node_game_context,node_game_contract,node_affairs,node_advisors_journal,node_events,node_event_ui,node_elections,node_parliament_ui toneAmber
class node_map_contract,node_map_view,node_province_map,node_war_ai,node_war_summary toneMint
class node_build,node_deploy toneRose
```

## Components

### Browser Runtime

- [Vite entry page](https://github.com/wjnct55555/liberty-unquenched/blob/main/index.html): entrypoint · `index.html`
- [React bootstrap](https://github.com/wjnct55555/liberty-unquenched/blob/main/src/main.tsx): client entry · `src/main.tsx`
- [Application root](https://github.com/wjnct55555/liberty-unquenched/blob/main/src/App.tsx): React composition · Assembles screens, overlays, music, and optional war map. · `src/App.tsx`
- [Main game layout](https://github.com/wjnct55555/liberty-unquenched/blob/main/src/components/MainArea.tsx): React UI · Status, navigation, and interactive content surfaces. · `src/components/MainArea.tsx`
- **Bundled static assets**: public assets · Imagery, music, terrain, and geographic datasets.

### Political Simulation

- [Political game context](https://github.com/wjnct55555/liberty-unquenched/blob/main/src/game/GameContext.tsx): state boundary · Shared political state and mutation actions. · `src/game/GameContext.tsx`
- [Political domain contract](https://github.com/wjnct55555/liberty-unquenched/blob/main/src/game/types.ts): types and data · State types, seed data, and constants. · `src/game/types.ts`
- [Affairs registries](https://github.com/wjnct55555/liberty-unquenched/blob/main/src/game/action_affairs/index.ts): rule definitions · Player decisions, prerequisites, costs, cooldowns, and effects. · `src/game/action_affairs/index.ts`
- [Advisors & objectives](https://github.com/wjnct55555/liberty-unquenched/blob/main/src/game/advisors/index.ts): content registries · `src/game/advisors/index.ts`
- [Historical event registry](https://github.com/wjnct55555/liberty-unquenched/blob/main/src/game/events/index.ts): progression rules · Timed and conditional choices drive historical branches. · `src/game/events/index.ts`
- [Events & endings](https://github.com/wjnct55555/liberty-unquenched/blob/main/src/components/EventBoard.tsx): React overlays · Renders choices, super-events, and conclusions. · `src/components/EventBoard.tsx`
- [Election subsystem](https://github.com/wjnct55555/liberty-unquenched/blob/main/src/game/utils/election.ts): political calculation · Parties, coalitions, stances, and seat calculations. · `src/game/utils/election.ts`
- [Domestic politics chart](https://github.com/wjnct55555/liberty-unquenched/blob/main/src/components/ParliamentChart.tsx): D3 visualization · `src/components/ParliamentChart.tsx`

### War Map

- [War state model](https://github.com/wjnct55555/liberty-unquenched/blob/main/src/map/types_map.ts): state boundary · Provinces, armies, supply, combat, resources, and actions. · `src/map/types_map.ts`
- [War map view](https://github.com/wjnct55555/liberty-unquenched/blob/main/src/map/MapView.tsx): React feature · Hosts geographic interaction and war controls. · `src/map/MapView.tsx`
- [Province map](https://github.com/wjnct55555/liberty-unquenched/blob/main/src/map/ProvinceMap.tsx): GeoJSON renderer · `src/map/ProvinceMap.tsx`
- [War AI](https://github.com/wjnct55555/liberty-unquenched/blob/main/src/map/lib/gameAi.ts): game AI · `src/map/lib/gameAi.ts`
- [War summary](https://github.com/wjnct55555/liberty-unquenched/blob/main/src/map/WarSummary.tsx): outcome aggregation · `src/map/WarSummary.tsx`

### Build & Deploy

- [Vite build](https://github.com/wjnct55555/liberty-unquenched/blob/main/vite.config.ts): frontend build · Uses VITE_BASE_PATH for GitHub Pages asset paths. · `vite.config.ts`
- [GitHub Pages deployment](https://github.com/wjnct55555/liberty-unquenched/blob/main/.github/workflows/deploy.yml): CI/CD workflow · Node 20 build, type-check, and deploy. · `.github/workflows/deploy.yml`

## Connections

- Vite entry page → React bootstrap: loads
- React bootstrap → Application root: mounts
- Application root → Main game layout: composes
- Application root → Political game context: provides state
- Application root → Events & endings: opens overlays
- Application root → War map view: optionally shows
- Main game layout → Political game context: reads and mutates
- Political game context → Political domain contract: uses
- Political game context → Affairs registries: evaluates actions
- Political game context → Advisors & objectives: tracks content
- Political game context → Historical event registry: evaluates progression
- Historical event registry → Events & endings: supplies choices
- Events & endings → Political game context: applies outcomes
- Political game context → Election subsystem: supplies support and laws
- Election subsystem → Domestic politics chart: produces seats
- War map view → War state model: reads and mutates
- War map view → Province map: renders geography
- Province map → Bundled static assets: loads GeoJSON
- War map view → War AI: runs opposing actions
- War state model → War summary: aggregates capacity
- Vite build → Vite entry page: builds entry
- Vite build → Bundled static assets: serves with base path
- GitHub Pages deployment → Vite build: runs
