# jack-schultz/pastries-vs-pests architecture

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

- Interactive diagram: https://gitdiagram.com/jack-schultz/pastries-vs-pests
- Repository: https://github.com/jack-schultz/pastries-vs-pests

## Overview

This is a Tkinter lane-defense game: the player chooses a level, places or moves defensive goods on garden tiles using cards, earns flour, and fights successive pest waves until victory or defeat. The runtime is organized around a window/state stack, a gameplay state that handles input, and a World that coordinates the board and level progression. Entity combat is supported by shared living, damage, armour, and projectile layers. Several domain modules are represented from the source index; their internal call details were not sampled, so those relationships are kept sparse.

Main entry points: [`app/world.py`](https://github.com/jack-schultz/pastries-vs-pests/blob/main/app/world.py) (World Coordinator), [`app/states/game_state.py`](https://github.com/jack-schultz/pastries-vs-pests/blob/main/app/states/game_state.py) (Gameplay State), [`app/window.py`](https://github.com/jack-schultz/pastries-vs-pests/blob/main/app/window.py) (Game Window), [`entities/living/living.py`](https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/living/living.py) (Living Entities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game Runtime"]
  node_entry["Game Entry<br/>[main.py]"]
  node_window["Game Window<br/>[window.py]"]
  node_stack["State Stack<br/>[statestack.py]"]
  node_menu["Main Menu<br/>[mainmenu_state.py]"]
  node_levels_ui["Level Selection"]
  node_game["Gameplay State<br/>[game_state.py]"]
  node_pause["Pause State<br/>[pause_state.py]"]
  node_gameover["Game Over<br/>[gameover_state.py]"]
end

subgraph group_board["Board And Progression"]
  node_world["World Coordinator<br/>[world.py]"]
  node_leveldata["Level Definitions<br/>[level_collector.py]"]
  node_waves["Wave Manager<br/>[wave_manager.py]"]
  node_garden["Garden Board<br/>[garden.py]"]
  node_tiles["Board Tiles<br/>[tile.py]"]
  node_cards["Cards And Tools<br/>[card.py]"]
  node_cardholder["Card Inventory<br/>[cardholder.py]"]
end

subgraph group_combat["Combat Entities"]
  node_goods["Defensive Goods<br/>[base_good.py]"]
  node_pests["Pests<br/>[base_pest.py]"]
  node_pesttypes["Pest Variants<br/>[pest_type.py]"]
  node_projectiles["Projectiles<br/>[projectile.py]"]
end

subgraph group_mechanics["Combat Mechanics"]
  node_living["Living Entities<br/>[living.py]"]
  node_armour["Armour<br/>[base_armour.py]"]
  node_damage["Damage Model<br/>[damage.py]"]
  node_entity["Canvas Entities<br/>[entity.py]"]
  node_rectangle["Canvas Geometry<br/>[rectangle.py]"]
end

node_player(("Player"))

node_player -->|"uses"| node_window
node_entry -->|"starts"| node_window
node_window -->|"creates"| node_stack
node_window -->|"starts at"| node_menu
node_menu -->|"opens"| node_levels_ui
node_levels_ui -->|"loads levels"| node_leveldata
node_levels_ui -->|"starts level"| node_game
node_game -->|"creates and ticks"| node_world
node_game -->|"pushes on escape"| node_pause
node_game -->|"pushes on defeat"| node_gameover
node_game -->|"handles card input"| node_cards
node_game -->|"handles tile input"| node_tiles
node_world -->|"loads level data"| node_leveldata
node_world -->|"manages waves"| node_waves
node_world -->|"updates board"| node_garden
node_world -->|"owns inventory"| node_cardholder
node_world -->|"moves and tracks"| node_pests
node_world -->|"updates hits"| node_projectiles
node_garden -->|"comprises"| node_tiles
node_tiles -->|"holds"| node_goods
node_cardholder -->|"maintains"| node_cards
node_cardholder -->|"creates choices"| node_goods
node_waves -->|"selects pests"| node_pesttypes
node_pests -->|"extends"| node_living
node_goods -->|"extends"| node_living
node_living -->|"absorbs damage"| node_armour
node_pests -->|"attacks"| node_goods
node_projectiles -->|"produces hit damage"| node_damage
node_living -->|"takes damage"| node_damage
node_entity -->|"owns geometry"| node_rectangle

click node_entry "https://github.com/jack-schultz/pastries-vs-pests/blob/main/main.py"
click node_window "https://github.com/jack-schultz/pastries-vs-pests/blob/main/app/window.py"
click node_stack "https://github.com/jack-schultz/pastries-vs-pests/blob/main/app/states/statestack.py"
click node_menu "https://github.com/jack-schultz/pastries-vs-pests/blob/main/app/states/mainmenu_state.py"
click node_levels_ui "https://github.com/jack-schultz/pastries-vs-pests/blob/main/app/states/levelselect_state.py"
click node_game "https://github.com/jack-schultz/pastries-vs-pests/blob/main/app/states/game_state.py"
click node_pause "https://github.com/jack-schultz/pastries-vs-pests/blob/main/app/states/pause_state.py"
click node_gameover "https://github.com/jack-schultz/pastries-vs-pests/blob/main/app/states/gameover_state.py"
click node_world "https://github.com/jack-schultz/pastries-vs-pests/blob/main/app/world.py"
click node_leveldata "https://github.com/jack-schultz/pastries-vs-pests/blob/main/levels/level_collector.py"
click node_waves "https://github.com/jack-schultz/pastries-vs-pests/blob/main/levels/wave_manager.py"
click node_garden "https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/garden.py"
click node_tiles "https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/tile.py"
click node_cards "https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/card.py"
click node_cardholder "https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/cardholder.py"
click node_goods "https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/living/goods/base_good.py"
click node_pests "https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/living/pests/base_pest.py"
click node_pesttypes "https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/living/pests/pest_type.py"
click node_projectiles "https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/projectiles/projectile.py"
click node_living "https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/living/living.py"
click node_armour "https://github.com/jack-schultz/pastries-vs-pests/blob/main/armour/base_armour.py"
click node_damage "https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/damage.py"
click node_entity "https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/entity.py"
click node_rectangle "https://github.com/jack-schultz/pastries-vs-pests/blob/main/app/rectangle.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_entry,node_window,node_stack,node_menu,node_levels_ui,node_game,node_pause,node_gameover toneBlue
class node_world,node_leveldata,node_waves,node_garden,node_tiles,node_cards,node_cardholder toneAmber
class node_goods,node_pests,node_pesttypes,node_projectiles toneMint
class node_living,node_armour,node_damage,node_entity,node_rectangle toneRose
class node_player toneIndigo
```

## Components

### Game Runtime

- [Game Entry](https://github.com/jack-schultz/pastries-vs-pests/blob/main/main.py): `main.py`
- [Game Window](https://github.com/jack-schultz/pastries-vs-pests/blob/main/app/window.py): `app/window.py`
- [State Stack](https://github.com/jack-schultz/pastries-vs-pests/blob/main/app/states/statestack.py): `app/states/statestack.py`
- [Main Menu](https://github.com/jack-schultz/pastries-vs-pests/blob/main/app/states/mainmenu_state.py): `app/states/mainmenu_state.py`
- [Level Selection](https://github.com/jack-schultz/pastries-vs-pests/blob/main/app/states/levelselect_state.py): `app/states/levelselect_state.py`
- [Gameplay State](https://github.com/jack-schultz/pastries-vs-pests/blob/main/app/states/game_state.py): `app/states/game_state.py`
- [Pause State](https://github.com/jack-schultz/pastries-vs-pests/blob/main/app/states/pause_state.py): `app/states/pause_state.py`
- [Game Over](https://github.com/jack-schultz/pastries-vs-pests/blob/main/app/states/gameover_state.py): `app/states/gameover_state.py`

### Board And Progression

- [World Coordinator](https://github.com/jack-schultz/pastries-vs-pests/blob/main/app/world.py): `app/world.py`
- [Level Definitions](https://github.com/jack-schultz/pastries-vs-pests/blob/main/levels/level_collector.py): `levels/level_collector.py`
- [Wave Manager](https://github.com/jack-schultz/pastries-vs-pests/blob/main/levels/wave_manager.py): `levels/wave_manager.py`
- [Garden Board](https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/garden.py): `entities/garden.py`
- [Board Tiles](https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/tile.py): `entities/tile.py`
- [Cards And Tools](https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/card.py): `entities/card.py`
- [Card Inventory](https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/cardholder.py): `entities/cardholder.py`

### Combat Entities

- [Defensive Goods](https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/living/goods/base_good.py): `entities/living/goods/base_good.py`
- [Pests](https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/living/pests/base_pest.py): `entities/living/pests/base_pest.py`
- [Pest Variants](https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/living/pests/pest_type.py): `entities/living/pests/pest_type.py`
- [Projectiles](https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/projectiles/projectile.py): `entities/projectiles/projectile.py`

### Combat Mechanics

- [Living Entities](https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/living/living.py): `entities/living/living.py`
- [Armour](https://github.com/jack-schultz/pastries-vs-pests/blob/main/armour/base_armour.py): `armour/base_armour.py`
- [Damage Model](https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/damage.py): `entities/damage.py`
- [Canvas Entities](https://github.com/jack-schultz/pastries-vs-pests/blob/main/entities/entity.py): `entities/entity.py`
- [Canvas Geometry](https://github.com/jack-schultz/pastries-vs-pests/blob/main/app/rectangle.py): `app/rectangle.py`

### Other components

- **Player**

## Connections

- Player → Game Window: uses (evidence: `app/window.py`)
- Game Entry → Game Window: starts (evidence: `main.py`)
- Game Window → State Stack: creates (evidence: `app/window.py`)
- Game Window → Main Menu: starts at (evidence: `app/window.py`)
- Main Menu → Level Selection: opens (evidence: `app/states/mainmenu_state.py`)
- Level Selection → Level Definitions: loads levels (evidence: `app/states/levelselect_state.py`)
- Level Selection → Gameplay State: starts level (evidence: `app/states/levelselect_state.py`)
- Gameplay State → World Coordinator: creates and ticks (evidence: `app/states/game_state.py`)
- Gameplay State → Pause State: pushes on escape (evidence: `app/states/game_state.py`)
- Gameplay State → Game Over: pushes on defeat (evidence: `app/states/game_state.py`)
- Gameplay State → Cards And Tools: handles card input (evidence: `app/states/game_state.py`)
- Gameplay State → Board Tiles: handles tile input (evidence: `app/states/game_state.py`)
- World Coordinator → Level Definitions: loads level data (evidence: `app/world.py`)
- World Coordinator → Wave Manager: manages waves (evidence: `app/world.py`)
- World Coordinator → Garden Board: updates board (evidence: `app/world.py`)
- World Coordinator → Card Inventory: owns inventory (evidence: `app/world.py`)
- World Coordinator → Pests: moves and tracks (evidence: `app/world.py`)
- World Coordinator → Projectiles: updates hits (evidence: `app/world.py`)
- Garden Board → Board Tiles: comprises (evidence: `entities/garden.py`)
- Board Tiles → Defensive Goods: holds (evidence: `entities/tile.py`)
- Card Inventory → Cards And Tools: maintains (evidence: `entities/cardholder.py`)
- Card Inventory → Defensive Goods: creates choices (evidence: `entities/cardholder.py`)
- Wave Manager → Pest Variants: selects pests (evidence: `levels/wave_manager.py`)
- Pests → Living Entities: extends (evidence: `entities/living/pests/base_pest.py`)
- Defensive Goods → Living Entities: extends (evidence: `entities/living/goods/base_good.py`)
- Living Entities → Armour: absorbs damage (evidence: `entities/living/living.py`)
- Pests → Defensive Goods: attacks (evidence: `entities/living/pests/base_pest.py`)
- Projectiles → Damage Model: produces hit damage (evidence: `entities/projectiles/projectile.py`)
- Living Entities → Damage Model: takes damage (evidence: `entities/living/living.py`)
- Canvas Entities → Canvas Geometry: owns geometry (evidence: `entities/entity.py`)
