# rune2-h/rpg architecture

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

- Interactive diagram: https://gitdiagram.com/rune2-h/rpg
- Repository: https://github.com/rune2-h/rpg

## Overview

This is a console text RPG. Players create or load a character, then use the game menu to explore, fight, manage equipment and supplies, shop, rest, view status, and save progress. Exploration includes region encounters and a final boss that unlocks an infinite Boss Rush mode. The graph follows only calls visible in excerpts and contracts in game.h; world.c and inventory.c excerpts omit portions, so unverified internal links are left out.

Main entry points: [`main.c`](https://github.com/rune2-h/rpg/blob/main/main.c) (Game menus), [`game.h`](https://github.com/rune2-h/rpg/blob/main/game.h) (Game data contracts), [`world.c`](https://github.com/rune2-h/rpg/blob/main/world.c) (World exploration), [`inventory.c`](https://github.com/rune2-h/rpg/blob/main/inventory.c) (Inventory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Game flow"]
  node_menu["Game menus<br/>[main.c]"]
  node_contracts["Game data contracts<br/>[game.h]"]
end

subgraph group_character["Character and save"]
  node_character_setup["Character setup<br/>[player.c]"]
  node_progression["Status and leveling<br/>[player.c]"]
  node_save_load["Save and load<br/>[saveload.c]"]
  node_save_file[("Save file")]
end

subgraph group_adventure["World and combat"]
  node_world["World exploration<br/>[world.c]"]
  node_encounters["Encounters and bosses<br/>[world.c]"]
  node_combat["Turn-based combat<br/>[combat.c]"]
  node_boss_rush["Infinite Boss Rush<br/>[world.c]"]
end

subgraph group_items["Items and economy"]
  node_inventory["Inventory<br/>[inventory.c]"]
  node_shop["Shop and gacha<br/>[inventory.c]"]
  node_inn["Village rest<br/>[world.c]"]
end

node_player(("Player"))

node_player -->|"plays"| node_menu
node_menu -->|"creates"| node_character_setup
node_menu -->|"loads or saves"| node_save_load
node_menu -->|"explores"| node_world
node_menu -->|"opens"| node_inventory
node_menu -->|"opens"| node_shop
node_menu -->|"views status"| node_progression
node_menu -->|"rests"| node_inn
node_menu -->|"uses"| node_contracts
node_character_setup -->|"initializes"| node_contracts
node_progression -->|"updates stats"| node_contracts
node_save_load -->|"reads or writes"| node_save_file
node_save_load -->|"serializes"| node_contracts
node_world -->|"spawns"| node_encounters
node_world -->|"starts fights"| node_combat
node_world -->|"offers mode"| node_boss_rush
node_combat -->|"uses potion"| node_inventory
node_combat -->|"checks level"| node_progression
node_inventory -->|"manages items"| node_contracts
node_shop -->|"changes contents"| node_inventory
node_inn -->|"updates player"| node_contracts

click node_menu "https://github.com/rune2-h/rpg/blob/main/main.c"
click node_contracts "https://github.com/rune2-h/rpg/blob/main/game.h"
click node_character_setup "https://github.com/rune2-h/rpg/blob/main/player.c"
click node_progression "https://github.com/rune2-h/rpg/blob/main/player.c"
click node_save_load "https://github.com/rune2-h/rpg/blob/main/saveload.c"
click node_world "https://github.com/rune2-h/rpg/blob/main/world.c"
click node_encounters "https://github.com/rune2-h/rpg/blob/main/world.c"
click node_combat "https://github.com/rune2-h/rpg/blob/main/combat.c"
click node_boss_rush "https://github.com/rune2-h/rpg/blob/main/world.c"
click node_inventory "https://github.com/rune2-h/rpg/blob/main/inventory.c"
click node_shop "https://github.com/rune2-h/rpg/blob/main/inventory.c"
click node_inn "https://github.com/rune2-h/rpg/blob/main/world.c"

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_menu,node_contracts toneBlue
class node_character_setup,node_progression,node_save_load,node_save_file toneAmber
class node_world,node_encounters,node_combat,node_boss_rush toneMint
class node_inventory,node_shop,node_inn toneRose
class node_player toneIndigo
```

## Components

### Game flow

- [Game menus](https://github.com/rune2-h/rpg/blob/main/main.c): `main.c`
- [Game data contracts](https://github.com/rune2-h/rpg/blob/main/game.h): `game.h`

### Character and save

- [Character setup](https://github.com/rune2-h/rpg/blob/main/player.c): `player.c`
- [Status and leveling](https://github.com/rune2-h/rpg/blob/main/player.c): `player.c`
- [Save and load](https://github.com/rune2-h/rpg/blob/main/saveload.c): `saveload.c`
- **Save file**

### World and combat

- [World exploration](https://github.com/rune2-h/rpg/blob/main/world.c): `world.c`
- [Encounters and bosses](https://github.com/rune2-h/rpg/blob/main/world.c): `world.c`
- [Turn-based combat](https://github.com/rune2-h/rpg/blob/main/combat.c): `combat.c`
- [Infinite Boss Rush](https://github.com/rune2-h/rpg/blob/main/world.c): `world.c`

### Items and economy

- [Inventory](https://github.com/rune2-h/rpg/blob/main/inventory.c): `inventory.c`
- [Shop and gacha](https://github.com/rune2-h/rpg/blob/main/inventory.c): `inventory.c`
- [Village rest](https://github.com/rune2-h/rpg/blob/main/world.c): `world.c`

### Other components

- **Player**

## Connections

- Player → Game menus: plays (evidence: `main.c`)
- Game menus → Character setup: creates (evidence: `main.c`)
- Game menus → Save and load: loads or saves (evidence: `main.c`)
- Game menus → World exploration: explores (evidence: `main.c`)
- Game menus → Inventory: opens (evidence: `main.c`)
- Game menus → Shop and gacha: opens (evidence: `main.c`)
- Game menus → Status and leveling: views status (evidence: `main.c`)
- Game menus → Village rest: rests (evidence: `main.c`)
- Game menus → Game data contracts: uses (evidence: `main.c`)
- Character setup → Game data contracts: initializes (evidence: `player.c`)
- Status and leveling → Game data contracts: updates stats (evidence: `player.c`)
- Save and load → Save file: reads or writes (evidence: `saveload.c`)
- Save and load → Game data contracts: serializes (evidence: `saveload.c`)
- World exploration → Encounters and bosses: spawns (evidence: `world.c`)
- World exploration → Turn-based combat: starts fights (evidence: `world.c`)
- World exploration → Infinite Boss Rush: offers mode (evidence: `world.c`)
- Turn-based combat → Inventory: uses potion (evidence: `combat.c`)
- Turn-based combat → Status and leveling: checks level (evidence: `combat.c`)
- Inventory → Game data contracts: manages items (evidence: `inventory.c`)
- Shop and gacha → Inventory: changes contents (evidence: `inventory.c`)
- Village rest → Game data contracts: updates player (evidence: `world.c`)
