# ybz777/underworld-rise-of-a-kingpin architecture

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

- Interactive diagram: https://gitdiagram.com/ybz777/underworld-rise-of-a-kingpin
- Repository: https://github.com/ybz777/underworld-rise-of-a-kingpin

## Overview

Underworld: Rise of a Kingpin is a browser-based crime-management strategy game. The player establishes an organization, manages its people, equipment, territory, businesses, and contracts, then advances through simulation and resolves major operations with tactical crisis choices. App.tsx is the documented UI/state orchestrator; game modules supply initialization, simulation, persistence, combat, crisis logic, audio, and visuals. The README only documents local setup and a Gemini API key; it does not establish an API integration. Some screen and simulation details are unsampled, so links are limited to shown imports and calls.

Main entry points: [`src/App.tsx`](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/App.tsx) (Game interface), [`src/game/initialState.ts`](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/game/initialState.ts) (Game initialization), [`src/game/simulation.ts`](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/game/simulation.ts) (Day simulation), [`src/game/crisisEngine.ts`](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/game/crisisEngine.ts) (Crisis engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_play["Game orchestration"]
  node_app["Game interface<br/>[App.tsx]"]
  node_dashboard["Dashboard"]
  node_news["News feed<br/>[NewsScreen.tsx]"]
  node_stats["Statistics"]
  node_achievements["Achievements"]
end

subgraph group_world["World and operations"]
  node_contracts["Contracts catalog<br/>[contracts.ts]"]
  node_operations["Operations board"]
  node_crisis["Crisis engine<br/>[crisisEngine.ts]"]
  node_crisis_ui["Crisis decisions<br/>[CrisisModal.tsx]"]
  node_combat_ui["Tactical battle"]
  node_territory["Territories"]
  node_factions["Factions<br/>[FactionsScreen.tsx]"]
  node_events_ui["Event decisions<br/>[EventModal.tsx]"]
end

subgraph group_management["Organization management"]
  node_members["Crew management<br/>[MembersScreen.tsx]"]
  node_recruits["Recruit templates<br/>[recruits.ts]"]
  node_skills["Skill trees<br/>[skills.ts]"]
  node_arsenal["Arsenal<br/>[ArsenalScreen.tsx]"]
  node_weapons["Weapon catalog<br/>[weapons.ts]"]
  node_market["Market<br/>[MarketScreen.tsx]"]
  node_businesses["Businesses"]
  node_garage["Vehicle garage<br/>[GarageScreen.tsx]"]
  node_regions["Starting regions<br/>[regions.ts]"]
end

subgraph group_engine["Game runtime"]
  node_initial["Game initialization<br/>[initialState.ts]"]
  node_simulation["Day simulation<br/>[simulation.ts]"]
  node_combat["Combat simulation"]
  node_storage[("Save storage<br/>[storage.ts]")]
  node_types["Game state model<br/>[types.ts]"]
  node_visuals["Visual assets<br/>[visuals.ts]"]
  node_entity_image["Entity imagery<br/>[EntityImage.tsx]"]
  node_audio["Audio engine<br/>[audio.ts]"]
  node_ach_data["Achievement catalog<br/>[achievements.ts]"]
  node_business_data["Business catalog<br/>[businesses.ts]"]
  node_event_data["Event catalog<br/>[events.ts]"]
end

node_player(("Player"))

node_player -->|"plays"| node_app
node_app -->|"initializes"| node_initial
node_app -->|"loads and saves"| node_storage
node_app -->|"advances"| node_simulation
node_app -->|"renders"| node_dashboard
node_app -->|"renders"| node_operations
node_app -->|"renders"| node_arsenal
node_app -->|"renders"| node_market
node_app -->|"renders"| node_members
node_app -->|"renders"| node_territory
node_app -->|"renders"| node_businesses
node_app -.->|"renders"| node_news
node_app -.->|"renders"| node_stats
node_app -.->|"renders"| node_achievements
node_app -.->|"renders"| node_crisis_ui
node_app -.->|"renders"| node_combat_ui
node_app -.->|"renders"| node_events_ui
node_operations -->|"creates crisis"| node_crisis
node_operations -.->|"uses combat"| node_combat
node_crisis_ui -.->|"uses crisis logic"| node_crisis
node_combat_ui -->|"simulates combat"| node_combat
node_initial -->|"creates crew"| node_recruits
node_initial -->|"generates contracts"| node_contracts
node_initial -->|"seeds equipment"| node_weapons
node_initial -->|"uses regions"| node_regions
node_recruits -->|"assigns skill trees"| node_skills
node_simulation -->|"uses event catalog"| node_event_data
node_simulation -->|"uses contracts"| node_contracts
node_simulation -->|"uses weapon data"| node_weapons
node_entity_image -->|"gets imagery"| node_visuals
node_weapons -->|"gets weapon art"| node_visuals
node_crisis -->|"gets scene art"| node_visuals
node_crisis -->|"uses state types"| node_types
node_combat -->|"uses state types"| node_types
node_business_data -.->|"defines catalog types"| node_types
node_ach_data -.->|"uses game types"| node_types
node_territory -.->|"uses combat"| node_combat
node_garage -.->|"renders imagery"| node_entity_image

click node_app "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/App.tsx"
click node_dashboard "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/DashboardScreen.tsx"
click node_news "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/NewsScreen.tsx"
click node_stats "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/StatisticsScreen.tsx"
click node_achievements "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/AchievementsScreen.tsx"
click node_contracts "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/data/contracts.ts"
click node_operations "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/OperationsScreen.tsx"
click node_crisis "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/game/crisisEngine.ts"
click node_crisis_ui "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/components/CrisisModal.tsx"
click node_combat_ui "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/components/TacticalBattleModal.tsx"
click node_territory "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/TerritoryScreen.tsx"
click node_factions "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/FactionsScreen.tsx"
click node_events_ui "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/components/EventModal.tsx"
click node_members "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/MembersScreen.tsx"
click node_recruits "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/data/recruits.ts"
click node_skills "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/data/skills.ts"
click node_arsenal "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/ArsenalScreen.tsx"
click node_weapons "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/data/weapons.ts"
click node_market "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/MarketScreen.tsx"
click node_businesses "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/BusinessesScreen.tsx"
click node_garage "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/GarageScreen.tsx"
click node_regions "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/data/regions.ts"
click node_initial "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/game/initialState.ts"
click node_simulation "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/game/simulation.ts"
click node_combat "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/game/combatSimulation.ts"
click node_storage "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/game/storage.ts"
click node_types "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/game/types.ts"
click node_visuals "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/game/visuals.ts"
click node_entity_image "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/components/EntityImage.tsx"
click node_audio "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/game/audio.ts"
click node_ach_data "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/data/achievements.ts"
click node_business_data "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/data/businesses.ts"
click node_event_data "https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/data/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_dashboard,node_news,node_stats,node_achievements toneBlue
class node_contracts,node_operations,node_crisis,node_crisis_ui,node_combat_ui,node_territory,node_factions,node_events_ui toneAmber
class node_members,node_recruits,node_skills,node_arsenal,node_weapons,node_market,node_businesses,node_garage,node_regions toneMint
class node_initial,node_simulation,node_combat,node_storage,node_types,node_visuals,node_entity_image,node_audio,node_ach_data,node_business_data,node_event_data toneRose
class node_player toneIndigo
```

## Components

### Game orchestration

- [Game interface](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/App.tsx): `src/App.tsx`
- [Dashboard](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/DashboardScreen.tsx): `src/screens/DashboardScreen.tsx`
- [News feed](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/NewsScreen.tsx): `src/screens/NewsScreen.tsx`
- [Statistics](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/StatisticsScreen.tsx): `src/screens/StatisticsScreen.tsx`
- [Achievements](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/AchievementsScreen.tsx): `src/screens/AchievementsScreen.tsx`

### World and operations

- [Contracts catalog](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/data/contracts.ts): `src/data/contracts.ts`
- [Operations board](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/OperationsScreen.tsx): `src/screens/OperationsScreen.tsx`
- [Crisis engine](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/game/crisisEngine.ts): `src/game/crisisEngine.ts`
- [Crisis decisions](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/components/CrisisModal.tsx): `src/components/CrisisModal.tsx`
- [Tactical battle](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/components/TacticalBattleModal.tsx): `src/components/TacticalBattleModal.tsx`
- [Territories](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/TerritoryScreen.tsx): `src/screens/TerritoryScreen.tsx`
- [Factions](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/FactionsScreen.tsx): `src/screens/FactionsScreen.tsx`
- [Event decisions](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/components/EventModal.tsx): `src/components/EventModal.tsx`

### Organization management

- [Crew management](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/MembersScreen.tsx): `src/screens/MembersScreen.tsx`
- [Recruit templates](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/data/recruits.ts): `src/data/recruits.ts`
- [Skill trees](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/data/skills.ts): `src/data/skills.ts`
- [Arsenal](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/ArsenalScreen.tsx): `src/screens/ArsenalScreen.tsx`
- [Weapon catalog](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/data/weapons.ts): `src/data/weapons.ts`
- [Market](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/MarketScreen.tsx): `src/screens/MarketScreen.tsx`
- [Businesses](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/BusinessesScreen.tsx): `src/screens/BusinessesScreen.tsx`
- [Vehicle garage](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/screens/GarageScreen.tsx): `src/screens/GarageScreen.tsx`
- [Starting regions](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/data/regions.ts): `src/data/regions.ts`

### Game runtime

- [Game initialization](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/game/initialState.ts): `src/game/initialState.ts`
- [Day simulation](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/game/simulation.ts): `src/game/simulation.ts`
- [Combat simulation](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/game/combatSimulation.ts): `src/game/combatSimulation.ts`
- [Save storage](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/game/storage.ts): `src/game/storage.ts`
- [Game state model](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/game/types.ts): `src/game/types.ts`
- [Visual assets](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/game/visuals.ts): `src/game/visuals.ts`
- [Entity imagery](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/components/EntityImage.tsx): `src/components/EntityImage.tsx`
- [Audio engine](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/game/audio.ts): `src/game/audio.ts`
- [Achievement catalog](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/data/achievements.ts): `src/data/achievements.ts`
- [Business catalog](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/data/businesses.ts): `src/data/businesses.ts`
- [Event catalog](https://github.com/ybz777/underworld-rise-of-a-kingpin/blob/main/src/data/events.ts): `src/data/events.ts`

### Other components

- **Player**

## Connections

- Player → Game interface: plays
- Game interface → Game initialization: initializes (evidence: `src/App.tsx`)
- Game interface → Save storage: loads and saves (evidence: `src/App.tsx`)
- Game interface → Day simulation: advances (evidence: `src/App.tsx`)
- Game interface → Dashboard: renders (evidence: `src/App.tsx`)
- Game interface → Operations board: renders (evidence: `src/App.tsx`)
- Game interface → Arsenal: renders (evidence: `src/App.tsx`)
- Game interface → Market: renders (evidence: `src/App.tsx`)
- Game interface → Crew management: renders (evidence: `src/App.tsx`)
- Game interface → Territories: renders (evidence: `src/App.tsx`)
- Game interface → Businesses: renders (evidence: `src/App.tsx`)
- Game interface → News feed: renders (evidence: `src/App.tsx`)
- Game interface → Statistics: renders (evidence: `src/App.tsx`)
- Game interface → Achievements: renders (evidence: `src/App.tsx`)
- Game interface → Crisis decisions: renders (evidence: `src/App.tsx`)
- Game interface → Tactical battle: renders (evidence: `src/App.tsx`)
- Game interface → Event decisions: renders (evidence: `src/App.tsx`)
- Operations board → Crisis engine: creates crisis (evidence: `src/screens/OperationsScreen.tsx`)
- Operations board → Combat simulation: uses combat (evidence: `src/screens/OperationsScreen.tsx`)
- Crisis decisions → Crisis engine: uses crisis logic (evidence: `src/components/CrisisModal.tsx`)
- Tactical battle → Combat simulation: simulates combat (evidence: `src/components/TacticalBattleModal.tsx`)
- Game initialization → Recruit templates: creates crew (evidence: `src/game/initialState.ts`)
- Game initialization → Contracts catalog: generates contracts (evidence: `src/game/initialState.ts`)
- Game initialization → Weapon catalog: seeds equipment (evidence: `src/game/initialState.ts`)
- Game initialization → Starting regions: uses regions (evidence: `src/game/initialState.ts`)
- Recruit templates → Skill trees: assigns skill trees (evidence: `src/data/recruits.ts`)
- Day simulation → Event catalog: uses event catalog (evidence: `src/game/simulation.ts`)
- Day simulation → Contracts catalog: uses contracts (evidence: `src/game/simulation.ts`)
- Day simulation → Weapon catalog: uses weapon data (evidence: `src/game/simulation.ts`)
- Entity imagery → Visual assets: gets imagery (evidence: `src/components/EntityImage.tsx`)
- Weapon catalog → Visual assets: gets weapon art (evidence: `src/data/weapons.ts`)
- Crisis engine → Visual assets: gets scene art (evidence: `src/game/crisisEngine.ts`)
- Crisis engine → Game state model: uses state types (evidence: `src/game/crisisEngine.ts`)
- Combat simulation → Game state model: uses state types (evidence: `src/game/combatSimulation.ts`)
- Business catalog → Game state model: defines catalog types (evidence: `src/data/businesses.ts`)
- Achievement catalog → Game state model: uses game types (evidence: `src/data/achievements.ts`)
- Territories → Combat simulation: uses combat (evidence: `src/screens/TerritoryScreen.tsx`)
- Vehicle garage → Entity imagery: renders imagery (evidence: `src/screens/GarageScreen.tsx`)
