# kauri-off/th_08 architecture

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

- Interactive diagram: https://gitdiagram.com/kauri-off/th_08
- Repository: https://github.com/kauri-off/th_08

## Overview

This is a clean-room Rust reimplementation of Touhou 8. Its main workflow is: accept keyboard input and original game data, initialize the engine, run menu or stage gameplay frame by frame, render and play audio, then produce results and persist scores. The graph retains the README’s major gameplay, replay, and presentation capabilities. Some domain links rely on documented capabilities or SOURCE INDEX references; unsampled implementation details are not asserted.

Main entry points: [`src/game.rs`](https://github.com/kauri-off/th_08/blob/master/src/game.rs) (Engine context), [`src/app.rs`](https://github.com/kauri-off/th_08/blob/master/src/app.rs) (Window and loop), [`src/anmmgr.rs`](https://github.com/kauri-off/th_08/blob/master/src/anmmgr.rs) (Animation manager), [`src/player.rs`](https://github.com/kauri-off/th_08/blob/master/src/player.rs) (Player and shot types)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and assets"]
  node_app["Window and loop<br/>[app.rs]"]
  node_game["Engine context<br/>[game.rs]"]
  node_archive["Data archive<br/>[archive.rs]"]
  node_input["Input state<br/>[input.rs]"]
  node_task["Task scheduler<br/>[task.rs]"]
end

subgraph group_gameplay["Game flow"]
  node_menu["Menus and selection<br/>[menu.rs]"]
  node_stage["Stages and progression<br/>[stage.rs]"]
  node_gamemgr["Game manager<br/>[gamemgr.rs]"]
  node_ecl["ECL scripts<br/>[eclvm.rs]"]
end

subgraph group_combat["Combat simulation"]
  node_enemy["Enemies and bosses<br/>[enemy.rs]"]
  node_player_logic["Player and shot types<br/>[player.rs]"]
  node_bullets["Bullets and lasers<br/>[bullet.rs]"]
  node_items["Items<br/>[item.rs]"]
  node_bombs["Bombs and spells<br/>[bomb.rs]"]
end

subgraph group_presentation["Presentation"]
  node_anm["Animation manager<br/>[anmmgr.rs]"]
  node_anmvm["Animation VM<br/>[anmvm.rs]"]
  node_gfx["Renderer<br/>[gfx.rs]"]
  node_hud["HUD and dialogue<br/>[hud.rs]"]
  node_audio["Music and sound<br/>[audio.rs]"]
end

subgraph group_records["Replay and records"]
  node_replay["Replay playback<br/>[replay.rs]"]
  node_session["Recorded sessions<br/>[session.rs]"]
  node_result["Results and name entry<br/>[result.rs]"]
  node_score[("Score persistence<br/>[scoredat.rs]")]
end

node_player(("Player"))
node_game_data["Original game data"]

node_player -->|"provides input"| node_app
node_game_data -->|"supplies files"| node_app
node_app -->|"initializes"| node_game
node_app -->|"updates keys"| node_input
node_game -->|"loads archive"| node_archive
node_game -->|"initializes audio"| node_audio
node_game -->|"loads scores"| node_score
node_game -->|"owns game state"| node_gamemgr
node_game -->|"runs frame tasks"| node_task
node_game -->|"draws frames"| node_gfx
node_game -->|"reads controls"| node_input
node_game -->|"logs replay data"| node_replay
node_gamemgr -.->|"supports selection"| node_menu
node_gamemgr -.->|"advances stages"| node_stage
node_stage -.->|"runs stage scripts"| node_ecl
node_ecl -->|"controls enemies"| node_enemy
node_enemy -->|"manages attacks"| node_bullets
node_player_logic -->|"checks collisions"| node_bullets
node_player_logic -->|"collects items"| node_items
node_player_logic -->|"uses bombs"| node_bombs
node_enemy -->|"updates animations"| node_anm
node_anm -->|"runs scripts"| node_anmvm
node_anm -->|"submits sprites"| node_gfx
node_hud -.->|"draws interface"| node_anm
node_game -.->|"presents status"| node_hud
node_game -->|"shows results"| node_result
node_result -->|"saves score"| node_score
node_replay -.->|"replays sessions"| node_session
node_game_data -->|"provides BGM"| node_audio
node_player -->|"records play"| node_session

click node_app "https://github.com/kauri-off/th_08/blob/master/src/app.rs"
click node_game "https://github.com/kauri-off/th_08/blob/master/src/game.rs"
click node_archive "https://github.com/kauri-off/th_08/blob/master/src/archive.rs"
click node_input "https://github.com/kauri-off/th_08/blob/master/src/input.rs"
click node_task "https://github.com/kauri-off/th_08/blob/master/src/task.rs"
click node_menu "https://github.com/kauri-off/th_08/blob/master/src/menu.rs"
click node_stage "https://github.com/kauri-off/th_08/blob/master/src/stage.rs"
click node_gamemgr "https://github.com/kauri-off/th_08/blob/master/src/gamemgr.rs"
click node_ecl "https://github.com/kauri-off/th_08/blob/master/src/eclvm.rs"
click node_enemy "https://github.com/kauri-off/th_08/blob/master/src/enemy.rs"
click node_player_logic "https://github.com/kauri-off/th_08/blob/master/src/player.rs"
click node_bullets "https://github.com/kauri-off/th_08/blob/master/src/bullet.rs"
click node_items "https://github.com/kauri-off/th_08/blob/master/src/item.rs"
click node_bombs "https://github.com/kauri-off/th_08/blob/master/src/bomb.rs"
click node_anm "https://github.com/kauri-off/th_08/blob/master/src/anmmgr.rs"
click node_anmvm "https://github.com/kauri-off/th_08/blob/master/src/anmvm.rs"
click node_gfx "https://github.com/kauri-off/th_08/blob/master/src/gfx.rs"
click node_hud "https://github.com/kauri-off/th_08/blob/master/src/hud.rs"
click node_audio "https://github.com/kauri-off/th_08/blob/master/src/audio.rs"
click node_replay "https://github.com/kauri-off/th_08/blob/master/src/replay.rs"
click node_session "https://github.com/kauri-off/th_08/blob/master/src/session.rs"
click node_result "https://github.com/kauri-off/th_08/blob/master/src/result.rs"
click node_score "https://github.com/kauri-off/th_08/blob/master/src/scoredat.rs"

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_game,node_archive,node_input,node_task toneBlue
class node_menu,node_stage,node_gamemgr,node_ecl toneAmber
class node_enemy,node_player_logic,node_bullets,node_items,node_bombs toneMint
class node_anm,node_anmvm,node_gfx,node_hud,node_audio toneRose
class node_replay,node_session,node_result,node_score,node_player,node_game_data toneIndigo
```

## Components

### Runtime and assets

- [Window and loop](https://github.com/kauri-off/th_08/blob/master/src/app.rs): `src/app.rs`
- [Engine context](https://github.com/kauri-off/th_08/blob/master/src/game.rs): `src/game.rs`
- [Data archive](https://github.com/kauri-off/th_08/blob/master/src/archive.rs): `src/archive.rs`
- [Input state](https://github.com/kauri-off/th_08/blob/master/src/input.rs): `src/input.rs`
- [Task scheduler](https://github.com/kauri-off/th_08/blob/master/src/task.rs): `src/task.rs`

### Game flow

- [Menus and selection](https://github.com/kauri-off/th_08/blob/master/src/menu.rs): `src/menu.rs`
- [Stages and progression](https://github.com/kauri-off/th_08/blob/master/src/stage.rs): `src/stage.rs`
- [Game manager](https://github.com/kauri-off/th_08/blob/master/src/gamemgr.rs): `src/gamemgr.rs`
- [ECL scripts](https://github.com/kauri-off/th_08/blob/master/src/eclvm.rs): `src/eclvm.rs`

### Combat simulation

- [Enemies and bosses](https://github.com/kauri-off/th_08/blob/master/src/enemy.rs): `src/enemy.rs`
- [Player and shot types](https://github.com/kauri-off/th_08/blob/master/src/player.rs): `src/player.rs`
- [Bullets and lasers](https://github.com/kauri-off/th_08/blob/master/src/bullet.rs): `src/bullet.rs`
- [Items](https://github.com/kauri-off/th_08/blob/master/src/item.rs): `src/item.rs`
- [Bombs and spells](https://github.com/kauri-off/th_08/blob/master/src/bomb.rs): `src/bomb.rs`

### Presentation

- [Animation manager](https://github.com/kauri-off/th_08/blob/master/src/anmmgr.rs): `src/anmmgr.rs`
- [Animation VM](https://github.com/kauri-off/th_08/blob/master/src/anmvm.rs): `src/anmvm.rs`
- [Renderer](https://github.com/kauri-off/th_08/blob/master/src/gfx.rs): `src/gfx.rs`
- [HUD and dialogue](https://github.com/kauri-off/th_08/blob/master/src/hud.rs): `src/hud.rs`
- [Music and sound](https://github.com/kauri-off/th_08/blob/master/src/audio.rs): `src/audio.rs`

### Replay and records

- [Replay playback](https://github.com/kauri-off/th_08/blob/master/src/replay.rs): `src/replay.rs`
- [Recorded sessions](https://github.com/kauri-off/th_08/blob/master/src/session.rs): `src/session.rs`
- [Results and name entry](https://github.com/kauri-off/th_08/blob/master/src/result.rs): `src/result.rs`
- [Score persistence](https://github.com/kauri-off/th_08/blob/master/src/scoredat.rs): `src/scoredat.rs`

### Other components

- **Player**
- **Original game data**

## Connections

- Player → Window and loop: provides input
- Original game data → Window and loop: supplies files
- Window and loop → Engine context: initializes (evidence: `src/app.rs`)
- Window and loop → Input state: updates keys (evidence: `src/app.rs`)
- Engine context → Data archive: loads archive (evidence: `src/game.rs`)
- Engine context → Music and sound: initializes audio (evidence: `src/game.rs`)
- Engine context → Score persistence: loads scores (evidence: `src/game.rs`)
- Engine context → Game manager: owns game state (evidence: `src/game.rs`)
- Engine context → Task scheduler: runs frame tasks (evidence: `src/game.rs`)
- Engine context → Renderer: draws frames (evidence: `src/game.rs`)
- Engine context → Input state: reads controls (evidence: `src/game.rs`)
- Engine context → Replay playback: logs replay data (evidence: `src/game.rs`)
- Game manager → Menus and selection: supports selection
- Game manager → Stages and progression: advances stages
- Stages and progression → ECL scripts: runs stage scripts
- ECL scripts → Enemies and bosses: controls enemies (evidence: `src/eclvm.rs`)
- Enemies and bosses → Bullets and lasers: manages attacks (evidence: `src/enemy.rs`)
- Player and shot types → Bullets and lasers: checks collisions (evidence: `src/player.rs`)
- Player and shot types → Items: collects items (evidence: `src/player.rs`)
- Player and shot types → Bombs and spells: uses bombs (evidence: `src/player.rs`)
- Enemies and bosses → Animation manager: updates animations (evidence: `src/enemy.rs`)
- Animation manager → Animation VM: runs scripts (evidence: `src/anmmgr.rs`)
- Animation manager → Renderer: submits sprites (evidence: `src/anmmgr.rs`)
- HUD and dialogue → Animation manager: draws interface
- Engine context → HUD and dialogue: presents status
- Engine context → Results and name entry: shows results
- Results and name entry → Score persistence: saves score
- Replay playback → Recorded sessions: replays sessions
- Original game data → Music and sound: provides BGM
- Player → Recorded sessions: records play
