# iain-crowe/rougelike architecture

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

- Interactive diagram: https://gitdiagram.com/iain-crowe/rougelike
- Repository: https://github.com/iain-crowe/rougelike

## Overview

This is a terminal-style Python roguelike, launched through `main.py`. The core loop turns player input into actions, runs enemy turns, updates visibility, and renders the resulting dungeon state. Its domain stages include procedural floor generation, entity and item creation, exploration and combat, inventory and consumable effects, and character progression. The graph also shows the engine and rendering layer. Some links rely on the SOURCE INDEX or README rather than inspected implementations; those evidence limits are reflected in the citations.

Main entry points: [`util/actions.py`](https://github.com/iain-crowe/rougelike/blob/main/util/actions.py) (Player actions), [`entity/entity.py`](https://github.com/iain-crowe/rougelike/blob/main/entity/entity.py) (Actors and items), [`util/engine.py`](https://github.com/iain-crowe/rougelike/blob/main/util/engine.py) (Game engine), [`map/game_map.py`](https://github.com/iain-crowe/rougelike/blob/main/map/game_map.py) (Dungeon map)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game runtime"]
  node_main["Game launch<br/>[main.py]"]
  node_setup["Game setup<br/>[setup_game.py]"]
  node_input["Input handlers<br/>[input_handlers.py]"]
  node_engine["Game engine<br/>[engine.py]"]
end

subgraph group_world["Dungeon world"]
  node_procgen["Floor generation<br/>[procgen.py]"]
  node_gamemap["Dungeon map<br/>[game_map.py]"]
  node_tiles["Tile definitions<br/>[tile_types.py]"]
end

subgraph group_gameplay["Gameplay systems"]
  node_factories["Entity factories"]
  node_entities["Actors and items<br/>[entity.py]"]
  node_ai["Enemy AI<br/>[ai.py]"]
  node_actions["Player actions<br/>[actions.py]"]
  node_fighter["Combat and health<br/>[fighter.py]"]
  node_inventory["Inventory<br/>[inventory.py]"]
  node_consumable["Consumables<br/>[consumable.py]"]
  node_level["Character progression<br/>[level.py]"]
end

subgraph group_presentation["Interface and rendering"]
  node_messages["Message log<br/>[message_log.py]"]
  node_render["Rendering helpers"]
  node_colors["Color definitions<br/>[color.py]"]
end

node_player(("Player"))

node_player -->|"starts game"| node_main
node_main -->|"initializes"| node_setup
node_setup -->|"uses entities"| node_factories
node_setup -->|"sets up map"| node_gamemap
node_setup -->|"starts handler"| node_input
node_input -->|"dispatches actions"| node_actions
node_input -->|"runs turns"| node_engine
node_engine -->|"runs enemy turns"| node_ai
node_ai -->|"performs actions"| node_actions
node_actions -->|"checks map"| node_gamemap
node_actions -->|"targets entities"| node_entities
node_actions -->|"activates item"| node_consumable
node_actions -->|"moves items"| node_inventory
node_actions -->|"uses combat stats"| node_fighter
node_actions -->|"generates floor"| node_engine
node_engine -->|"updates visibility"| node_gamemap
node_engine -->|"renders log"| node_messages
node_engine -->|"renders status"| node_render
node_gamemap -->|"requests generation"| node_procgen
node_procgen -->|"creates floor"| node_gamemap
node_procgen -->|"uses tiles"| node_tiles
node_procgen -->|"places entities"| node_factories
node_gamemap -->|"renders tiles"| node_tiles
node_factories -->|"builds actors"| node_entities
node_entities -->|"owns component"| node_fighter
node_entities -->|"owns component"| node_inventory
node_entities -->|"owns component"| node_level
node_entities -->|"owns component"| node_consumable
node_entities -->|"uses AI"| node_ai
node_messages -->|"uses colors"| node_colors
node_render -->|"uses colors"| node_colors

click node_main "https://github.com/iain-crowe/rougelike/blob/main/main.py"
click node_setup "https://github.com/iain-crowe/rougelike/blob/main/util/setup_game.py"
click node_input "https://github.com/iain-crowe/rougelike/blob/main/util/input_handlers.py"
click node_engine "https://github.com/iain-crowe/rougelike/blob/main/util/engine.py"
click node_procgen "https://github.com/iain-crowe/rougelike/blob/main/map/procgen.py"
click node_gamemap "https://github.com/iain-crowe/rougelike/blob/main/map/game_map.py"
click node_tiles "https://github.com/iain-crowe/rougelike/blob/main/map/tile_types.py"
click node_factories "https://github.com/iain-crowe/rougelike/blob/main/entity/entity_factories.py"
click node_entities "https://github.com/iain-crowe/rougelike/blob/main/entity/entity.py"
click node_ai "https://github.com/iain-crowe/rougelike/blob/main/components/ai.py"
click node_actions "https://github.com/iain-crowe/rougelike/blob/main/util/actions.py"
click node_fighter "https://github.com/iain-crowe/rougelike/blob/main/components/fighter.py"
click node_inventory "https://github.com/iain-crowe/rougelike/blob/main/components/inventory.py"
click node_consumable "https://github.com/iain-crowe/rougelike/blob/main/components/consumable.py"
click node_level "https://github.com/iain-crowe/rougelike/blob/main/components/level.py"
click node_messages "https://github.com/iain-crowe/rougelike/blob/main/util/message_log.py"
click node_render "https://github.com/iain-crowe/rougelike/blob/main/util/render/render_functions.py"
click node_colors "https://github.com/iain-crowe/rougelike/blob/main/util/render/color.py"

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_main,node_setup,node_input,node_engine toneBlue
class node_procgen,node_gamemap,node_tiles toneAmber
class node_factories,node_entities,node_ai,node_actions,node_fighter,node_inventory,node_consumable,node_level toneMint
class node_messages,node_render,node_colors toneRose
class node_player toneIndigo
```

## Components

### Game runtime

- [Game launch](https://github.com/iain-crowe/rougelike/blob/main/main.py): `main.py`
- [Game setup](https://github.com/iain-crowe/rougelike/blob/main/util/setup_game.py): `util/setup_game.py`
- [Input handlers](https://github.com/iain-crowe/rougelike/blob/main/util/input_handlers.py): `util/input_handlers.py`
- [Game engine](https://github.com/iain-crowe/rougelike/blob/main/util/engine.py): `util/engine.py`

### Dungeon world

- [Floor generation](https://github.com/iain-crowe/rougelike/blob/main/map/procgen.py): `map/procgen.py`
- [Dungeon map](https://github.com/iain-crowe/rougelike/blob/main/map/game_map.py): `map/game_map.py`
- [Tile definitions](https://github.com/iain-crowe/rougelike/blob/main/map/tile_types.py): `map/tile_types.py`

### Gameplay systems

- [Entity factories](https://github.com/iain-crowe/rougelike/blob/main/entity/entity_factories.py): `entity/entity_factories.py`
- [Actors and items](https://github.com/iain-crowe/rougelike/blob/main/entity/entity.py): `entity/entity.py`
- [Enemy AI](https://github.com/iain-crowe/rougelike/blob/main/components/ai.py): `components/ai.py`
- [Player actions](https://github.com/iain-crowe/rougelike/blob/main/util/actions.py): `util/actions.py`
- [Combat and health](https://github.com/iain-crowe/rougelike/blob/main/components/fighter.py): `components/fighter.py`
- [Inventory](https://github.com/iain-crowe/rougelike/blob/main/components/inventory.py): `components/inventory.py`
- [Consumables](https://github.com/iain-crowe/rougelike/blob/main/components/consumable.py): `components/consumable.py`
- [Character progression](https://github.com/iain-crowe/rougelike/blob/main/components/level.py): `components/level.py`

### Interface and rendering

- [Message log](https://github.com/iain-crowe/rougelike/blob/main/util/message_log.py): `util/message_log.py`
- [Rendering helpers](https://github.com/iain-crowe/rougelike/blob/main/util/render/render_functions.py): `util/render/render_functions.py`
- [Color definitions](https://github.com/iain-crowe/rougelike/blob/main/util/render/color.py): `util/render/color.py`

### Other components

- **Player**

## Connections

- Player → Game launch: starts game (evidence: `README.md`)
- Game launch → Game setup: initializes (evidence: `main.py`)
- Game setup → Entity factories: uses entities (evidence: `util/setup_game.py`)
- Game setup → Dungeon map: sets up map (evidence: `util/setup_game.py`)
- Game setup → Input handlers: starts handler (evidence: `util/setup_game.py`)
- Input handlers → Player actions: dispatches actions (evidence: `util/input_handlers.py`)
- Input handlers → Game engine: runs turns (evidence: `util/input_handlers.py`)
- Game engine → Enemy AI: runs enemy turns (evidence: `util/engine.py`)
- Enemy AI → Player actions: performs actions (evidence: `components/ai.py`)
- Player actions → Dungeon map: checks map (evidence: `util/actions.py`)
- Player actions → Actors and items: targets entities (evidence: `util/actions.py`)
- Player actions → Consumables: activates item (evidence: `util/actions.py`)
- Player actions → Inventory: moves items (evidence: `util/actions.py`)
- Player actions → Combat and health: uses combat stats (evidence: `util/actions.py`)
- Player actions → Game engine: generates floor (evidence: `util/actions.py`)
- Game engine → Dungeon map: updates visibility (evidence: `util/engine.py`)
- Game engine → Message log: renders log (evidence: `util/engine.py`)
- Game engine → Rendering helpers: renders status (evidence: `util/engine.py`)
- Dungeon map → Floor generation: requests generation (evidence: `map/game_map.py`)
- Floor generation → Dungeon map: creates floor (evidence: `map/procgen.py`)
- Floor generation → Tile definitions: uses tiles (evidence: `map/procgen.py`)
- Floor generation → Entity factories: places entities (evidence: `map/procgen.py`)
- Dungeon map → Tile definitions: renders tiles (evidence: `map/game_map.py`)
- Entity factories → Actors and items: builds actors (evidence: `entity/entity_factories.py`)
- Actors and items → Combat and health: owns component (evidence: `entity/entity.py`)
- Actors and items → Inventory: owns component (evidence: `entity/entity.py`)
- Actors and items → Character progression: owns component (evidence: `entity/entity.py`)
- Actors and items → Consumables: owns component (evidence: `entity/entity.py`)
- Actors and items → Enemy AI: uses AI (evidence: `entity/entity.py`)
- Message log → Color definitions: uses colors (evidence: `util/message_log.py`)
- Rendering helpers → Color definitions: uses colors (evidence: `util/render/render_functions.py`)
