# holynova/mafa-survivor-game architecture

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

- Interactive diagram: https://gitdiagram.com/holynova/mafa-survivor-game
- Repository: https://github.com/holynova/mafa-survivor-game

## Overview

Mafa Survivor is a browser-based, single-player roguelite survivor game. The player configures a character and chapter, fights escalating monster waves, builds skills and equipment, and finishes a run whose results contribute to persistent progression. The graph separates the UI, simulation and rules, rendering and assets, and saved progression. The README documents the game’s classes, skills, waves, and bosses; unsampled implementation details are represented only where documented, and edges are limited to visible references or documented behavior.

Main entry points: [`src/renderer.ts`](https://github.com/holynova/mafa-survivor-game/blob/main/src/renderer.ts) (Game Renderer), [`src/App.tsx`](https://github.com/holynova/mafa-survivor-game/blob/main/src/App.tsx) (Game UI), [`src/assetLoader.ts`](https://github.com/holynova/mafa-survivor-game/blob/main/src/assetLoader.ts) (Asset Preloading), [`src/game.ts`](https://github.com/holynova/mafa-survivor-game/blob/main/src/game.ts) (Run Simulation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_play["Game Play"]
  node_entry["Browser Entry<br/>[main.tsx]"]
  node_game_ui["Game UI<br/>[App.tsx]"]
  node_run_setup["Run Setup<br/>[App.tsx]"]
  node_run_play["Run Controls<br/>[App.tsx]"]
  node_build_choices["Build Choices<br/>[App.tsx]"]
end

subgraph group_simulation["Simulation"]
  node_simulation["Run Simulation<br/>[game.ts]"]
  node_combat["Combat and Waves<br/>[game.ts]"]
  node_game_rules["Game Rules<br/>[rules.ts]"]
  node_game_content["Classes and Content<br/>[content.ts]"]
end

subgraph group_presentation["Presentation and Assets"]
  node_game_renderer["Game Renderer<br/>[renderer.ts]"]
  node_asset_preload["Asset Preloading<br/>[assetLoader.ts]"]
  node_audio["Sound System<br/>[audio.ts]"]
  node_asset_cache[("Asset Cache<br/>[cache.ts]")]
  node_game_assets["Mir Game Assets"]
end

subgraph group_progression["Progression"]
  node_profile["Profile Progression<br/>[save.ts]"]
  node_run_history[("Run History<br/>[save.ts]")]
end

node_player(("Player"))

node_entry -->|"renders"| node_game_ui
node_entry -->|"boots"| node_simulation
node_entry -->|"preloads"| node_asset_preload
node_entry -->|"boots"| node_game_renderer
node_player -.->|"configures and plays"| node_game_ui
node_game_ui -->|"uses"| node_simulation
node_game_ui -->|"loads and unlocks"| node_profile
node_game_ui -->|"saves results"| node_run_history
node_simulation -->|"reads definitions"| node_game_content
node_simulation -->|"uses calculations"| node_game_rules
node_game_renderer -->|"renders state"| node_simulation
node_game_renderer -->|"reads equipment"| node_game_content
node_game_renderer -->|"plays sounds"| node_audio
node_game_renderer -->|"receives manifest"| node_asset_preload
node_asset_preload -->|"prepares audio"| node_audio
node_asset_preload -->|"fetches assets"| node_asset_cache
node_audio -->|"fetches audio"| node_asset_cache
node_asset_preload -->|"loads manifests and atlases"| node_game_assets
node_profile -->|"reads talents"| node_game_content
node_run_history -->|"grants progression"| node_profile

click node_entry "https://github.com/holynova/mafa-survivor-game/blob/main/src/main.tsx"
click node_game_ui "https://github.com/holynova/mafa-survivor-game/blob/main/src/App.tsx"
click node_run_setup "https://github.com/holynova/mafa-survivor-game/blob/main/src/App.tsx"
click node_run_play "https://github.com/holynova/mafa-survivor-game/blob/main/src/App.tsx"
click node_build_choices "https://github.com/holynova/mafa-survivor-game/blob/main/src/App.tsx"
click node_simulation "https://github.com/holynova/mafa-survivor-game/blob/main/src/game.ts"
click node_combat "https://github.com/holynova/mafa-survivor-game/blob/main/src/game.ts"
click node_game_rules "https://github.com/holynova/mafa-survivor-game/blob/main/src/rules.ts"
click node_game_content "https://github.com/holynova/mafa-survivor-game/blob/main/src/content.ts"
click node_game_renderer "https://github.com/holynova/mafa-survivor-game/blob/main/src/renderer.ts"
click node_asset_preload "https://github.com/holynova/mafa-survivor-game/blob/main/src/assetLoader.ts"
click node_audio "https://github.com/holynova/mafa-survivor-game/blob/main/src/audio.ts"
click node_asset_cache "https://github.com/holynova/mafa-survivor-game/blob/main/src/cache.ts"
click node_profile "https://github.com/holynova/mafa-survivor-game/blob/main/src/save.ts"
click node_run_history "https://github.com/holynova/mafa-survivor-game/blob/main/src/save.ts"
click node_game_assets "https://github.com/holynova/mafa-survivor-game/tree/main/public/assets/mir"

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_entry,node_game_ui,node_run_setup,node_run_play,node_build_choices toneBlue
class node_simulation,node_combat,node_game_rules,node_game_content toneAmber
class node_game_renderer,node_asset_preload,node_audio,node_asset_cache,node_game_assets toneMint
class node_profile,node_run_history toneRose
class node_player toneIndigo
```

## Components

### Game Play

- [Browser Entry](https://github.com/holynova/mafa-survivor-game/blob/main/src/main.tsx): `src/main.tsx`
- [Game UI](https://github.com/holynova/mafa-survivor-game/blob/main/src/App.tsx): `src/App.tsx`
- [Run Setup](https://github.com/holynova/mafa-survivor-game/blob/main/src/App.tsx): `src/App.tsx`
- [Run Controls](https://github.com/holynova/mafa-survivor-game/blob/main/src/App.tsx): `src/App.tsx`
- [Build Choices](https://github.com/holynova/mafa-survivor-game/blob/main/src/App.tsx): `src/App.tsx`

### Simulation

- [Run Simulation](https://github.com/holynova/mafa-survivor-game/blob/main/src/game.ts): `src/game.ts`
- [Combat and Waves](https://github.com/holynova/mafa-survivor-game/blob/main/src/game.ts): `src/game.ts`
- [Game Rules](https://github.com/holynova/mafa-survivor-game/blob/main/src/rules.ts): `src/rules.ts`
- [Classes and Content](https://github.com/holynova/mafa-survivor-game/blob/main/src/content.ts): `src/content.ts`

### Presentation and Assets

- [Game Renderer](https://github.com/holynova/mafa-survivor-game/blob/main/src/renderer.ts): `src/renderer.ts`
- [Asset Preloading](https://github.com/holynova/mafa-survivor-game/blob/main/src/assetLoader.ts): `src/assetLoader.ts`
- [Sound System](https://github.com/holynova/mafa-survivor-game/blob/main/src/audio.ts): `src/audio.ts`
- [Asset Cache](https://github.com/holynova/mafa-survivor-game/blob/main/src/cache.ts): `src/cache.ts`
- [Mir Game Assets](https://github.com/holynova/mafa-survivor-game/tree/main/public/assets/mir): `public/assets/mir`

### Progression

- [Profile Progression](https://github.com/holynova/mafa-survivor-game/blob/main/src/save.ts): `src/save.ts`
- [Run History](https://github.com/holynova/mafa-survivor-game/blob/main/src/save.ts): `src/save.ts`

### Other components

- **Player**

## Connections

- Browser Entry → Game UI: renders (evidence: `src/main.tsx`)
- Browser Entry → Run Simulation: boots (evidence: `src/main.tsx`)
- Browser Entry → Asset Preloading: preloads (evidence: `src/main.tsx`)
- Browser Entry → Game Renderer: boots (evidence: `src/main.tsx`)
- Player → Game UI: configures and plays (evidence: `README.md`)
- Game UI → Run Simulation: uses (evidence: `src/App.tsx`)
- Game UI → Profile Progression: loads and unlocks (evidence: `src/App.tsx`)
- Game UI → Run History: saves results (evidence: `src/App.tsx`)
- Run Simulation → Classes and Content: reads definitions (evidence: `src/game.ts`)
- Run Simulation → Game Rules: uses calculations (evidence: `src/game.ts`)
- Game Renderer → Run Simulation: renders state (evidence: `src/renderer.ts`)
- Game Renderer → Classes and Content: reads equipment (evidence: `src/renderer.ts`)
- Game Renderer → Sound System: plays sounds (evidence: `src/renderer.ts`)
- Game Renderer → Asset Preloading: receives manifest (evidence: `src/renderer.ts`)
- Asset Preloading → Sound System: prepares audio (evidence: `src/assetLoader.ts`)
- Asset Preloading → Asset Cache: fetches assets (evidence: `src/assetLoader.ts`)
- Sound System → Asset Cache: fetches audio (evidence: `src/audio.ts`)
- Asset Preloading → Mir Game Assets: loads manifests and atlases (evidence: `src/assetLoader.ts`)
- Profile Progression → Classes and Content: reads talents (evidence: `src/save.ts`)
- Run History → Profile Progression: grants progression (evidence: `src/save.ts`)
