# slavik-mmmbech/seaborn architecture

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

- Interactive diagram: https://gitdiagram.com/slavik-mmmbech/seaborn
- Repository: https://github.com/slavik-mmmbech/seaborn

## Overview

1. **Project shape**
   - Seaborn is a small Python game project, likely a procedural dungeon/exploration game based on the module names and tests.
   - The architecture is split into clean subsystems: game/core runtime, procedural generation, entities, AI, spatial indexing, lighting, and loot.

2. **Entry point and runtime boundary**
   - `main.py` is the top-level entry point.
   - `core/game.py` appears to own the main game loop and runtime coordination.
   - `core/world.py` likely holds the active world state: map, entities, generated content, and per-tick updates.

3. **Core gameplay model**
   - The `core` package is the central boundary where “simulation state” lives.
   - It likely orchestrates updates from AI, movement/collision, lighting refresh, and item interactions.
   - `config.py` is the shared configuration layer for tuning game parameters such as sizes, counts, or gameplay constants.

4. **Procedural generation subsystem**
   - The `generation` package is a dedicated dungeon-building pipeline.
   - `generation/bsp_tree.py` suggests a BSP-based partitioning step.
   - `generation/room_generator.py` and `generation/corridor_generator.py` indicate separate phases for creating rooms and connecting them.
   - `generation/dungeon.py` probably composes those pieces into a complete map generation flow.

5. **Spatial representation and queries**
   - `spatial/quadtree.py` provides a spatial indexing structure for fast neighborhood lookups.
   - This is likely used for entity proximity, collision candidates, visibility checks, or lighting-related queries.
   - The presence of a quadtree suggests the project separates broad-phase spatial queries from core world logic.

6. **Entities and in-world actors**
   - `entities/player.py`, `entities/npc.py`, and `entities/items.py` define the game’s interactable objects.
   - The `entities` layer is likely the domain model for actors and pickups, while `core/world.py` manages their placement and lifecycle.
   - This boundary keeps object behavior close to the entity type while leaving world orchestration in `core`.

7. **AI subsystem**
   - `ai/behavior_tree.py` and `ai/markov_chain.py` show two decision-making approaches in the project.
   - Behavior trees are typically used for deterministic or rule-based NPC behavior.
   - Markov chains likely provide probabilistic or pattern-based generation/behavior support.
   - The AI layer probably consumes world state and emits actions for `entities/npc.py`.

8. **Lighting and visibility**
   - `lighting/lightmap_raycasting.py` suggests a raycasting-based light or visibility system.
   - This subsystem likely computes what tiles or entities are visible/illuminated from a source position.
   - It probably depends on world geometry from generation and may use spatial acceleration for performance.

9. **Loot and rewards**
   - `loot/loot_bag.py` and `loot/weighted_binary.py` form a loot-generation subsystem.
   - `weighted_binary.py` likely implements weighted selection, used to control drop probabilities.
   - `loot_bag.py` likely packages loot tables or drop logic and feeds spawned items into `entities/items.py`.

10. **Cross-subsystem data flow**
   - A likely runtime flow is: `main.py` starts the game, `core/game.py` initializes `core/world.py`, the world is populated through `generation/dungeon.py`, then entities, AI, lighting, and loot systems operate on that generated state.
   - The core world is the shared hub; generation creates the map, entities act within it, AI decides actions, lighting recomputes visibility, and spatial structures support efficient queries.

11. **Testing strategy**
   - The `tests` package covers both unit-style and integration-level behavior.
   - There are focused tests for generation components (`test_bsp_tree`, `test_room_generator`, `test_corridor_generator`), AI (`test_markov_chain`), spatial indexing (`test_quadtree`), and a broader `test_dungeon_integration`.
   - This suggests the project values deterministic generation and composable subsystems.

12. **Architectural boundaries to show in a diagram**
   - Treat `core` as the central orchestrator.
   - Treat `generation`, `ai`, `lighting`, `loot`, and `spatial` as service-like subsystems feeding into or reading from the world.
   - Treat `entities` as the runtime object layer that exists inside the world and is manipulated by the other systems.

Main entry points: [`core/world.py`](https://github.com/slavik-mmmbech/seaborn/blob/main/core/world.py) (World), [`generation/dungeon.py`](https://github.com/slavik-mmmbech/seaborn/blob/main/generation/dungeon.py) (Dungeon), [`core/game.py`](https://github.com/slavik-mmmbech/seaborn/blob/main/core/game.py) (Game), [`entities/npc.py`](https://github.com/slavik-mmmbech/seaborn/blob/main/entities/npc.py) (NPC)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_main_py(("main<br/>entrypoint<br/>[main.py]"))
  node_core_game["Game<br/>loop<br/>[game.py]"]
  node_core_world[("World<br/>simulation state<br/>[world.py]")]
end

subgraph group_generation["Generation"]
  node_gen_dungeon["Dungeon<br/>pipeline<br/>[dungeon.py]"]
  node_gen_bsp["BSP tree<br/>partitioning<br/>[bsp_tree.py]"]
  node_gen_rooms["Rooms<br/>room generator<br/>[room_generator.py]"]
  node_gen_corridors["Corridors<br/>connector"]
end

subgraph group_entities["Entities"]
  node_ent_player(("Player<br/>actor<br/>[player.py]"))
  node_ent_npc(("NPC<br/>actor<br/>[npc.py]"))
  node_ent_items{{"Items<br/>pickup<br/>[items.py]"}}
end

subgraph group_ai["AI"]
  node_ai_bt["Behavior tree<br/>decision model<br/>[behavior_tree.py]"]
  node_ai_markov["Markov chain<br/>stochastic model<br/>[markov_chain.py]"]
end

subgraph group_worldsvc["World services"]
  node_spatial_qt["Quadtree<br/>spatial index<br/>[quadtree.py]"]
  node_light_ray["Light raycasting<br/>visibility"]
  node_loot_bag["Loot bag<br/>drop system<br/>[loot_bag.py]"]
  node_loot_weighted["Weighted binary<br/>weighted selection<br/>[weighted_binary.py]"]
end

node_config_py["Config<br/>settings<br/>[config.py]"]

node_main_py -->|"starts"| node_core_game
node_core_game -->|"owns"| node_core_world
node_core_game -->|"reads"| node_config_py
node_core_world -->|"generates"| node_gen_dungeon
node_gen_dungeon -->|"partitions"| node_gen_bsp
node_gen_dungeon -->|"places"| node_gen_rooms
node_gen_dungeon -->|"connects"| node_gen_corridors
node_core_world -->|"contains"| node_ent_player
node_core_world -->|"contains"| node_ent_npc
node_core_world -->|"contains"| node_ent_items
node_ent_npc -->|"uses"| node_ai_bt
node_ent_npc -->|"uses"| node_ai_markov
node_core_world -->|"indexes"| node_spatial_qt
node_core_world -->|"updates"| node_light_ray
node_core_world -->|"spawns"| node_loot_bag
node_loot_bag -->|"selects"| node_loot_weighted
node_loot_bag -->|"creates"| node_ent_items
node_light_ray -.->|"queries"| node_spatial_qt
node_gen_rooms -->|"reads"| node_config_py
node_gen_corridors -->|"reads"| node_config_py

click node_main_py "https://github.com/slavik-mmmbech/seaborn/blob/main/main.py"
click node_core_game "https://github.com/slavik-mmmbech/seaborn/blob/main/core/game.py"
click node_core_world "https://github.com/slavik-mmmbech/seaborn/blob/main/core/world.py"
click node_config_py "https://github.com/slavik-mmmbech/seaborn/blob/main/config.py"
click node_gen_dungeon "https://github.com/slavik-mmmbech/seaborn/blob/main/generation/dungeon.py"
click node_gen_bsp "https://github.com/slavik-mmmbech/seaborn/blob/main/generation/bsp_tree.py"
click node_gen_rooms "https://github.com/slavik-mmmbech/seaborn/blob/main/generation/room_generator.py"
click node_gen_corridors "https://github.com/slavik-mmmbech/seaborn/blob/main/generation/corridor_generator.py"
click node_ent_player "https://github.com/slavik-mmmbech/seaborn/blob/main/entities/player.py"
click node_ent_npc "https://github.com/slavik-mmmbech/seaborn/blob/main/entities/npc.py"
click node_ent_items "https://github.com/slavik-mmmbech/seaborn/blob/main/entities/items.py"
click node_ai_bt "https://github.com/slavik-mmmbech/seaborn/blob/main/ai/behavior_tree.py"
click node_ai_markov "https://github.com/slavik-mmmbech/seaborn/blob/main/ai/markov_chain.py"
click node_spatial_qt "https://github.com/slavik-mmmbech/seaborn/blob/main/spatial/quadtree.py"
click node_light_ray "https://github.com/slavik-mmmbech/seaborn/blob/main/lighting/lightmap_raycasting.py"
click node_loot_bag "https://github.com/slavik-mmmbech/seaborn/blob/main/loot/loot_bag.py"
click node_loot_weighted "https://github.com/slavik-mmmbech/seaborn/blob/main/loot/weighted_binary.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_py,node_core_game,node_core_world toneBlue
class node_gen_dungeon,node_gen_bsp,node_gen_rooms,node_gen_corridors toneAmber
class node_ent_player,node_ent_npc,node_ent_items toneMint
class node_ai_bt,node_ai_markov toneRose
class node_spatial_qt,node_light_ray,node_loot_bag,node_loot_weighted toneIndigo
class node_config_py toneNeutral
```

## Components

### Runtime

Application entry and game/world coordination

- [main](https://github.com/slavik-mmmbech/seaborn/blob/main/main.py): entrypoint · Starts the game application · `main.py`
- [Game](https://github.com/slavik-mmmbech/seaborn/blob/main/core/game.py): loop · Owns startup and the main loop · `core/game.py`
- [World](https://github.com/slavik-mmmbech/seaborn/blob/main/core/world.py): simulation state · Holds map, entities, and tick-level state · `core/world.py`

### Generation

Procedural dungeon-building pipeline

- [Dungeon](https://github.com/slavik-mmmbech/seaborn/blob/main/generation/dungeon.py): pipeline · Composes procedural dungeon generation · `generation/dungeon.py`
- [BSP tree](https://github.com/slavik-mmmbech/seaborn/blob/main/generation/bsp_tree.py): partitioning · Splits space into regions for rooms · `generation/bsp_tree.py`
- [Rooms](https://github.com/slavik-mmmbech/seaborn/blob/main/generation/room_generator.py): room generator · Creates room layouts · `generation/room_generator.py`
- [Corridors](https://github.com/slavik-mmmbech/seaborn/blob/main/generation/corridor_generator.py): connector · Links rooms into traversable paths · `generation/corridor_generator.py`

### Entities

In-world actors and pickups

- [Player](https://github.com/slavik-mmmbech/seaborn/blob/main/entities/player.py): actor · Controlled player entity · `entities/player.py`
- [NPC](https://github.com/slavik-mmmbech/seaborn/blob/main/entities/npc.py): actor · Non-player creature or character · `entities/npc.py`
- [Items](https://github.com/slavik-mmmbech/seaborn/blob/main/entities/items.py): pickup · Collectable items and inventory objects · `entities/items.py`

### AI

Decision systems for NPC behavior

- [Behavior tree](https://github.com/slavik-mmmbech/seaborn/blob/main/ai/behavior_tree.py): decision model · Rule-based NPC decision logic · `ai/behavior_tree.py`
- [Markov chain](https://github.com/slavik-mmmbech/seaborn/blob/main/ai/markov_chain.py): stochastic model · Probabilistic behavior or generation model · `ai/markov_chain.py`

### World services

Supporting systems for queries, lighting, and loot

- [Quadtree](https://github.com/slavik-mmmbech/seaborn/blob/main/spatial/quadtree.py): spatial index · Accelerates proximity and neighborhood queries · `spatial/quadtree.py`
- [Light raycasting](https://github.com/slavik-mmmbech/seaborn/blob/main/lighting/lightmap_raycasting.py): visibility · Computes lighting and visibility from rays · `lighting/lightmap_raycasting.py`
- [Loot bag](https://github.com/slavik-mmmbech/seaborn/blob/main/loot/loot_bag.py): drop system · Packages loot tables and drops · `loot/loot_bag.py`
- [Weighted binary](https://github.com/slavik-mmmbech/seaborn/blob/main/loot/weighted_binary.py): weighted selection · Chooses outcomes by probability weights · `loot/weighted_binary.py`

### Other components

- [Config](https://github.com/slavik-mmmbech/seaborn/blob/main/config.py): settings · Shared gameplay and generation constants · `config.py`

## Connections

- main → Game: starts · Bootstraps the game runtime
- Game → World: owns · Creates and advances world state
- Game → Config: reads · Uses shared configuration
- World → Dungeon: generates · Builds the initial dungeon map
- Dungeon → BSP tree: partitions · Derives region structure
- Dungeon → Rooms: places · Creates room geometry
- Dungeon → Corridors: connects · Links generated rooms
- World → Player: contains · Tracks the player in the world
- World → NPC: contains · Tracks NPCs in the world
- World → Items: contains · Tracks loose items and pickups
- NPC → Behavior tree: uses · NPC behavior is driven by decisions
- NPC → Markov chain: uses · NPCs may use probabilistic behavior
- World → Quadtree: indexes · Supports fast spatial lookups
- World → Light raycasting: updates · Recomputes visibility from world geometry
- World → Loot bag: spawns · Generates reward drops
- Loot bag → Weighted binary: selects · Chooses weighted outcomes
- Loot bag → Items: creates · Produces item entities as loot
- Light raycasting → Quadtree: queries · May use spatial acceleration for ray or neighborhood checks
- Rooms → Config: reads · Uses generation tuning constants
- Corridors → Config: reads · Uses generation tuning constants
