# rurouni88/pc3-ptsd architecture

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

- Interactive diagram: https://gitdiagram.com/rurouni88/pc3-ptsd
- Repository: https://github.com/rurouni88/pc3-ptsd

## Overview

PTSD is a mobile-first satirical roguelike in which the player chooses a relative and tries to resolve device problems before time or battery runs out. The documented flow is boot and difficulty/seed selection, a timed phone-interface run with interruptions and mini-games, then results and replay; a separate gym offers mini-games. Supporting branches provide saved runs, achievements/leaderboard, settings, localization and audio/haptic feedback. The main orchestration links are supported by the SOURCE INDEX and excerpts; unsampled mini-game internals are represented by their registry/directory, not inferred as separate runtime stages.

Main entry points: [`src/hooks/useGameEngine.ts`](https://github.com/rurouni88/pc3-ptsd/blob/main/src/hooks/useGameEngine.ts) (Run state engine), [`src/App.tsx`](https://github.com/rurouni88/pc3-ptsd/blob/main/src/App.tsx) (Application flow), [`src/screens/BootScreen.tsx`](https://github.com/rurouni88/pc3-ptsd/blob/main/src/screens/BootScreen.tsx) (Boot and selection), [`src/components/SettingsModal.tsx`](https://github.com/rurouni88/pc3-ptsd/blob/main/src/components/SettingsModal.tsx) (Settings controls)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gameplay["Game flow"]
  node_app["Application flow<br/>[App.tsx]"]
  node_boot["Boot and selection<br/>[BootScreen.tsx]"]
  node_os["Timed phone run<br/>[OSInterface.tsx]"]
  node_engine["Run state engine<br/>[useGameEngine.ts]"]
  node_timer["Game timer<br/>[useGameTimer.ts]"]
  node_minigames["Mini-game registry<br/>[registry.tsx]"]
  node_minigame_impl["Mini-game challenges"]
  node_gym["Mini-game gym<br/>[MiniGameGym.tsx]"]
  node_results["Run results<br/>[Results.tsx]"]
end

subgraph group_content["Game content"]
  node_levels["Difficulty content<br/>[levels.ts]"]
  node_rng["Seeded randomness<br/>[seeded-rng.ts]"]
  node_translations["Game translations<br/>[translations.ts]"]
end

subgraph group_persistence["Progress and records"]
  node_save[("Run saves<br/>[save.ts]")]
  node_meta[("Leaderboard records<br/>[meta.ts]")]
  node_achievements[("Achievements<br/>[achievements.ts]")]
end

subgraph group_experience["Player experience"]
  node_leaderboard_ui["Leaderboard view"]
  node_achievement_ui["Achievement view"]
  node_settings["Settings controls<br/>[SettingsModal.tsx]"]
  node_theme[("Theme preferences<br/>[theme.ts]")]
  node_font[("Font scaling<br/>[font-scale.ts]")]
end

subgraph group_feedback["Feedback systems"]
  node_sound["Sound effects<br/>[sound.ts]"]
  node_bgm["Background music<br/>[bgm.ts]"]
  node_haptics["Haptic feedback<br/>[haptics.ts]"]
end

node_player(("Player"))

node_player -->|"plays"| node_app
node_app -->|"shows"| node_boot
node_boot -->|"starts run"| node_app
node_boot -->|"offers difficulty"| node_levels
node_boot -->|"seeds run"| node_rng
node_app -->|"routes to run"| node_os
node_app -->|"selects level"| node_levels
node_os -->|"uses run state"| node_engine
node_engine -->|"uses timer"| node_timer
node_os -->|"dispatches challenges"| node_minigames
node_minigames -.->|"registers games"| node_minigame_impl
node_app -->|"opens gym"| node_gym
node_gym -->|"selects challenge"| node_minigames
node_engine -.->|"selects issues"| node_rng
node_engine -.->|"persists run"| node_save
node_app -->|"loads continuation"| node_save
node_engine -->|"checks results"| node_achievements
node_engine -.->|"records run"| node_meta
node_engine -->|"completes run"| node_app
node_app -->|"shows outcome"| node_results
node_results -->|"reads records"| node_meta
node_results -->|"reads unlocks"| node_achievements
node_boot -->|"opens achievements"| node_achievement_ui
node_boot -->|"opens leaderboard"| node_leaderboard_ui
node_achievement_ui -->|"reads achievements"| node_achievements
node_leaderboard_ui -->|"reads records"| node_meta
node_boot -->|"opens settings"| node_settings
node_settings -->|"loads and saves"| node_theme
node_settings -->|"loads and saves"| node_font
node_settings -->|"configures audio"| node_sound
node_settings -->|"configures music"| node_bgm
node_engine -->|"plays effects"| node_sound
node_engine -->|"triggers vibration"| node_haptics
node_bgm -->|"reads volume"| node_sound
node_minigame_impl -->|"uses translations"| node_translations

click node_app "https://github.com/rurouni88/pc3-ptsd/blob/main/src/App.tsx"
click node_boot "https://github.com/rurouni88/pc3-ptsd/blob/main/src/screens/BootScreen.tsx"
click node_levels "https://github.com/rurouni88/pc3-ptsd/blob/main/src/config/levels.ts"
click node_rng "https://github.com/rurouni88/pc3-ptsd/blob/main/src/engine/seeded-rng.ts"
click node_os "https://github.com/rurouni88/pc3-ptsd/blob/main/src/screens/OSInterface.tsx"
click node_engine "https://github.com/rurouni88/pc3-ptsd/blob/main/src/hooks/useGameEngine.ts"
click node_timer "https://github.com/rurouni88/pc3-ptsd/blob/main/src/hooks/useGameTimer.ts"
click node_minigames "https://github.com/rurouni88/pc3-ptsd/blob/main/src/components/mini-games/registry.tsx"
click node_minigame_impl "https://github.com/rurouni88/pc3-ptsd/tree/main/src/components/mini-games"
click node_gym "https://github.com/rurouni88/pc3-ptsd/blob/main/src/screens/MiniGameGym.tsx"
click node_results "https://github.com/rurouni88/pc3-ptsd/blob/main/src/screens/Results.tsx"
click node_save "https://github.com/rurouni88/pc3-ptsd/blob/main/src/engine/save.ts"
click node_meta "https://github.com/rurouni88/pc3-ptsd/blob/main/src/engine/meta.ts"
click node_achievements "https://github.com/rurouni88/pc3-ptsd/blob/main/src/engine/achievements.ts"
click node_leaderboard_ui "https://github.com/rurouni88/pc3-ptsd/blob/main/src/components/LeaderboardModal.tsx"
click node_achievement_ui "https://github.com/rurouni88/pc3-ptsd/blob/main/src/components/AchievementsModal.tsx"
click node_settings "https://github.com/rurouni88/pc3-ptsd/blob/main/src/components/SettingsModal.tsx"
click node_theme "https://github.com/rurouni88/pc3-ptsd/blob/main/src/engine/theme.ts"
click node_font "https://github.com/rurouni88/pc3-ptsd/blob/main/src/engine/font-scale.ts"
click node_translations "https://github.com/rurouni88/pc3-ptsd/blob/main/src/config/translations.ts"
click node_sound "https://github.com/rurouni88/pc3-ptsd/blob/main/src/engine/sound.ts"
click node_bgm "https://github.com/rurouni88/pc3-ptsd/blob/main/src/engine/bgm.ts"
click node_haptics "https://github.com/rurouni88/pc3-ptsd/blob/main/src/engine/haptics.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_boot,node_os,node_engine,node_timer,node_minigames,node_minigame_impl,node_gym,node_results toneBlue
class node_levels,node_rng,node_translations toneAmber
class node_save,node_meta,node_achievements toneMint
class node_leaderboard_ui,node_achievement_ui,node_settings,node_theme,node_font toneRose
class node_sound,node_bgm,node_haptics,node_player toneIndigo
```

## Components

### Game flow

- [Application flow](https://github.com/rurouni88/pc3-ptsd/blob/main/src/App.tsx): `src/App.tsx`
- [Boot and selection](https://github.com/rurouni88/pc3-ptsd/blob/main/src/screens/BootScreen.tsx): `src/screens/BootScreen.tsx`
- [Timed phone run](https://github.com/rurouni88/pc3-ptsd/blob/main/src/screens/OSInterface.tsx): `src/screens/OSInterface.tsx`
- [Run state engine](https://github.com/rurouni88/pc3-ptsd/blob/main/src/hooks/useGameEngine.ts): `src/hooks/useGameEngine.ts`
- [Game timer](https://github.com/rurouni88/pc3-ptsd/blob/main/src/hooks/useGameTimer.ts): `src/hooks/useGameTimer.ts`
- [Mini-game registry](https://github.com/rurouni88/pc3-ptsd/blob/main/src/components/mini-games/registry.tsx): `src/components/mini-games/registry.tsx`
- [Mini-game challenges](https://github.com/rurouni88/pc3-ptsd/tree/main/src/components/mini-games): `src/components/mini-games`
- [Mini-game gym](https://github.com/rurouni88/pc3-ptsd/blob/main/src/screens/MiniGameGym.tsx): `src/screens/MiniGameGym.tsx`
- [Run results](https://github.com/rurouni88/pc3-ptsd/blob/main/src/screens/Results.tsx): `src/screens/Results.tsx`

### Game content

- [Difficulty content](https://github.com/rurouni88/pc3-ptsd/blob/main/src/config/levels.ts): `src/config/levels.ts`
- [Seeded randomness](https://github.com/rurouni88/pc3-ptsd/blob/main/src/engine/seeded-rng.ts): `src/engine/seeded-rng.ts`
- [Game translations](https://github.com/rurouni88/pc3-ptsd/blob/main/src/config/translations.ts): `src/config/translations.ts`

### Progress and records

- [Run saves](https://github.com/rurouni88/pc3-ptsd/blob/main/src/engine/save.ts): `src/engine/save.ts`
- [Leaderboard records](https://github.com/rurouni88/pc3-ptsd/blob/main/src/engine/meta.ts): `src/engine/meta.ts`
- [Achievements](https://github.com/rurouni88/pc3-ptsd/blob/main/src/engine/achievements.ts): `src/engine/achievements.ts`

### Player experience

- [Leaderboard view](https://github.com/rurouni88/pc3-ptsd/blob/main/src/components/LeaderboardModal.tsx): `src/components/LeaderboardModal.tsx`
- [Achievement view](https://github.com/rurouni88/pc3-ptsd/blob/main/src/components/AchievementsModal.tsx): `src/components/AchievementsModal.tsx`
- [Settings controls](https://github.com/rurouni88/pc3-ptsd/blob/main/src/components/SettingsModal.tsx): `src/components/SettingsModal.tsx`
- [Theme preferences](https://github.com/rurouni88/pc3-ptsd/blob/main/src/engine/theme.ts): `src/engine/theme.ts`
- [Font scaling](https://github.com/rurouni88/pc3-ptsd/blob/main/src/engine/font-scale.ts): `src/engine/font-scale.ts`

### Feedback systems

- [Sound effects](https://github.com/rurouni88/pc3-ptsd/blob/main/src/engine/sound.ts): `src/engine/sound.ts`
- [Background music](https://github.com/rurouni88/pc3-ptsd/blob/main/src/engine/bgm.ts): `src/engine/bgm.ts`
- [Haptic feedback](https://github.com/rurouni88/pc3-ptsd/blob/main/src/engine/haptics.ts): `src/engine/haptics.ts`

### Other components

- **Player**

## Connections

- Player → Application flow: plays (evidence: `src/App.tsx`)
- Application flow → Boot and selection: shows (evidence: `src/App.tsx`)
- Boot and selection → Application flow: starts run (evidence: `src/App.tsx`)
- Boot and selection → Difficulty content: offers difficulty (evidence: `src/screens/BootScreen.tsx`)
- Boot and selection → Seeded randomness: seeds run (evidence: `src/screens/BootScreen.tsx`)
- Application flow → Timed phone run: routes to run (evidence: `src/App.tsx`)
- Application flow → Difficulty content: selects level (evidence: `src/App.tsx`)
- Timed phone run → Run state engine: uses run state (evidence: `src/screens/OSInterface.tsx`)
- Run state engine → Game timer: uses timer (evidence: `src/hooks/useGameEngine.ts`)
- Timed phone run → Mini-game registry: dispatches challenges (evidence: `src/screens/OSInterface.tsx`)
- Mini-game registry → Mini-game challenges: registers games
- Application flow → Mini-game gym: opens gym (evidence: `src/App.tsx`)
- Mini-game gym → Mini-game registry: selects challenge (evidence: `src/screens/MiniGameGym.tsx`)
- Run state engine → Seeded randomness: selects issues (evidence: `src/hooks/useGameEngine.ts`)
- Run state engine → Run saves: persists run (evidence: `src/hooks/useGameEngine.ts`)
- Application flow → Run saves: loads continuation (evidence: `src/App.tsx`)
- Run state engine → Achievements: checks results (evidence: `src/hooks/useGameEngine.ts`)
- Run state engine → Leaderboard records: records run (evidence: `src/hooks/useGameEngine.ts`)
- Run state engine → Application flow: completes run (evidence: `src/App.tsx`)
- Application flow → Run results: shows outcome (evidence: `src/App.tsx`)
- Run results → Leaderboard records: reads records (evidence: `src/screens/Results.tsx`)
- Run results → Achievements: reads unlocks (evidence: `src/screens/Results.tsx`)
- Boot and selection → Achievement view: opens achievements (evidence: `src/screens/BootScreen.tsx`)
- Boot and selection → Leaderboard view: opens leaderboard (evidence: `src/screens/BootScreen.tsx`)
- Achievement view → Achievements: reads achievements (evidence: `src/components/AchievementsModal.tsx`)
- Leaderboard view → Leaderboard records: reads records (evidence: `src/components/LeaderboardModal.tsx`)
- Boot and selection → Settings controls: opens settings (evidence: `src/screens/BootScreen.tsx`)
- Settings controls → Theme preferences: loads and saves (evidence: `src/components/SettingsModal.tsx`)
- Settings controls → Font scaling: loads and saves (evidence: `src/components/SettingsModal.tsx`)
- Settings controls → Sound effects: configures audio (evidence: `src/components/SettingsModal.tsx`)
- Settings controls → Background music: configures music (evidence: `src/components/SettingsModal.tsx`)
- Run state engine → Sound effects: plays effects (evidence: `src/hooks/useGameEngine.ts`)
- Run state engine → Haptic feedback: triggers vibration (evidence: `src/hooks/useGameEngine.ts`)
- Background music → Sound effects: reads volume (evidence: `src/engine/bgm.ts`)
- Mini-game challenges → Game translations: uses translations (evidence: `src/components/mini-games/PasskeySetup.tsx`)
