# n1s01/shitty-td architecture

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

- Interactive diagram: https://gitdiagram.com/n1s01/shitty-td
- Repository: https://github.com/n1s01/shitty-td

## Overview

1. **What this repo is**
   - A Python-based 2D game project, very likely a tower-defense game (`shitty-td`), with a clear split between game logic, scene/state management, and assets.

2. **Entry point**
   - `main.py` is the application bootstrap. It likely initializes configuration, creates the game engine, and starts the main loop.

3. **Top-level orchestration**
   - `core/game_engine.py` is the central runtime coordinator.
   - It likely owns the main update/render loop and switches between high-level scenes such as menu and gameplay.

4. **Scene/state layer**
   - `scenes/menu_scene.py` and `scenes/game_scene.py` represent the major application states.
   - The menu scene handles startup/navigation, while the game scene contains active gameplay.
   - This is the main boundary for user flow: input and progression move from menu into gameplay through the engine.

5. **Game domain logic**
   - `core/models.py` holds the primary gameplay entities and state objects.
   - This is where units, towers, enemies, projectiles, or similar domain objects would be defined and updated.

6. **Map and spatial rules**
   - `core/grid.py` is the board/map subsystem.
   - It likely manages tile occupancy, buildable cells, paths, and placement constraints, which are central for tower-defense mechanics.

7. **Route/AI support**
   - `core/pathfinding.py` contains path computation for moving entities.
   - This is the key algorithmic layer that supports enemy movement around towers and map obstacles.

8. **Configuration layer**
   - `settings.py` and `config.py` separate tunable runtime values from code.
   - These files likely define screen size, timing, gameplay constants, asset paths, and other global parameters.

9. **Presentation and assets**
   - `assets/` contains the external content used by the game: `sprites`, `sounds`, and `fonts`.
   - `view/` is present as a separate presentation-related folder, suggesting rendering/UI helpers or future expansion, though it is currently empty in the tree.

10. **How data flows through the system**
   - Input enters through the active scene.
   - The scene updates game state using core domain objects, grid logic, and pathfinding.
   - The engine advances the loop and delegates rendering back through the scene/presentation layer.
   - Assets are loaded from `assets/` to visualize state and play effects.

11. **Architectural boundaries**
   - `core/` is the rules/algorithm layer.
   - `scenes/` is the state/navigation layer.
   - `assets/` is the content layer.
   - `main.py` and `settings.py`/`config.py` are the startup and configuration boundary.

12. **Tooling / repo ops**
   - `.github/workflows/ci.yml` indicates automated CI is configured, likely for validation on pushes/PRs.
   - The repo is otherwise lightweight, with no evidence in the tree of a separate backend, database, or web service.

Main entry points: [`scenes/game_scene.py`](https://github.com/n1s01/shitty-td/blob/main/scenes/game_scene.py) (Game), [`assets`](https://github.com/n1s01/shitty-td/tree/main/assets) (Assets), [`main.py`](https://github.com/n1s01/shitty-td/blob/main/main.py) (Main), [`core/game_engine.py`](https://github.com/n1s01/shitty-td/blob/main/core/game_engine.py) (Engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_main_py(("Main<br/>entrypoint<br/>[main.py]"))
  node_game_engine["Engine<br/>loop coordinator<br/>[game_engine.py]"]
  node_settings["Settings<br/>tuning config<br/>[settings.py]"]
  node_config["Config<br/>[config.py]"]
end

subgraph group_gameplay["Gameplay"]
  node_menu_scene["Menu<br/>scene<br/>[menu_scene.py]"]
  node_game_scene["Game<br/>scene<br/>[game_scene.py]"]
  node_models{{"Models<br/>domain state<br/>[models.py]"}}
  node_grid["Grid<br/>map rules<br/>[grid.py]"]
  node_pathfinding["Pathfinding<br/>route logic<br/>[pathfinding.py]"]
  node_view["View<br/>presentation"]
end

subgraph group_content["Content"]
  node_assets_root[("Assets<br/>content root")]
  node_sprites["Sprites<br/>visual assets"]
  node_sounds["Sounds<br/>audio assets"]
  node_fonts["Fonts<br/>type assets"]
end

subgraph group_ops["Ops"]
  node_ci["CI<br/>workflow<br/>[ci.yml]"]
end

node_main_py -->|"loads"| node_settings
node_main_py -->|"uses"| node_config
node_main_py -->|"starts"| node_game_engine
node_game_engine -->|"hosts"| node_menu_scene
node_game_engine -->|"switches to"| node_game_scene
node_menu_scene -->|"requests start"| node_game_engine
node_game_scene -->|"updates"| node_models
node_game_scene -->|"queries"| node_grid
node_game_scene -->|"routes"| node_pathfinding
node_game_scene -->|"renders with"| node_assets_root
node_grid -->|"feeds"| node_pathfinding
node_models -->|"occupies"| node_grid
node_assets_root -->|"contains"| node_sprites
node_assets_root -->|"contains"| node_sounds
node_assets_root -->|"contains"| node_fonts
node_ci -.->|"checks"| node_main_py
node_view -.->|"supports"| node_game_scene

click node_main_py "https://github.com/n1s01/shitty-td/blob/main/main.py"
click node_game_engine "https://github.com/n1s01/shitty-td/blob/main/core/game_engine.py"
click node_settings "https://github.com/n1s01/shitty-td/blob/main/settings.py"
click node_config "https://github.com/n1s01/shitty-td/blob/main/config.py"
click node_menu_scene "https://github.com/n1s01/shitty-td/blob/main/scenes/menu_scene.py"
click node_game_scene "https://github.com/n1s01/shitty-td/blob/main/scenes/game_scene.py"
click node_models "https://github.com/n1s01/shitty-td/blob/main/core/models.py"
click node_grid "https://github.com/n1s01/shitty-td/blob/main/core/grid.py"
click node_pathfinding "https://github.com/n1s01/shitty-td/blob/main/core/pathfinding.py"
click node_assets_root "https://github.com/n1s01/shitty-td/tree/main/assets"
click node_sprites "https://github.com/n1s01/shitty-td/tree/main/assets/sprites"
click node_sounds "https://github.com/n1s01/shitty-td/tree/main/assets/sounds"
click node_fonts "https://github.com/n1s01/shitty-td/tree/main/assets/fonts"
click node_ci "https://github.com/n1s01/shitty-td/blob/main/.github/workflows/ci.yml"
click node_view "https://github.com/n1s01/shitty-td/tree/main/view"

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_game_engine,node_settings,node_config toneBlue
class node_menu_scene,node_game_scene,node_models,node_grid,node_pathfinding,node_view toneAmber
class node_assets_root,node_sprites,node_sounds,node_fonts toneMint
class node_ci toneRose
```

## Components

### Runtime

Application bootstrap and main game loop.

- [Main](https://github.com/n1s01/shitty-td/blob/main/main.py): entrypoint · Bootstraps the app and starts the game. · `main.py`
- [Engine](https://github.com/n1s01/shitty-td/blob/main/core/game_engine.py): loop coordinator · Owns the main update/render loop and scene switching. · `core/game_engine.py`
- [Settings](https://github.com/n1s01/shitty-td/blob/main/settings.py): tuning config · Global runtime and gameplay constants. · `settings.py`
- [Config](https://github.com/n1s01/shitty-td/blob/main/config.py): app config · Additional startup or environment configuration. · `config.py`

### Gameplay

Scenes and core simulation systems.

- [Menu](https://github.com/n1s01/shitty-td/blob/main/scenes/menu_scene.py): scene · Startup and navigation state. · `scenes/menu_scene.py`
- [Game](https://github.com/n1s01/shitty-td/blob/main/scenes/game_scene.py): scene · Active gameplay state. · `scenes/game_scene.py`
- [Models](https://github.com/n1s01/shitty-td/blob/main/core/models.py): domain state · Primary gameplay entities and state objects. · `core/models.py`
- [Grid](https://github.com/n1s01/shitty-td/blob/main/core/grid.py): map rules · Tile occupancy, placement, and path constraints. · `core/grid.py`
- [Pathfinding](https://github.com/n1s01/shitty-td/blob/main/core/pathfinding.py): route logic · Computes movement paths around obstacles. · `core/pathfinding.py`
- [View](https://github.com/n1s01/shitty-td/tree/main/view): presentation · Separate rendering/UI area; currently minimal in the tree. · `view`

### Content

Static assets used by the game.

- [Assets](https://github.com/n1s01/shitty-td/tree/main/assets): content root · Game art, audio, and font resources. · `assets`
- [Sprites](https://github.com/n1s01/shitty-td/tree/main/assets/sprites): visual assets · Image resources for entities and UI. · `assets/sprites`
- [Sounds](https://github.com/n1s01/shitty-td/tree/main/assets/sounds): audio assets · Sound effects and music resources. · `assets/sounds`
- [Fonts](https://github.com/n1s01/shitty-td/tree/main/assets/fonts): type assets · Font resources used for text rendering. · `assets/fonts`

### Ops

Repository automation and checks.

- [CI](https://github.com/n1s01/shitty-td/blob/main/.github/workflows/ci.yml): workflow · Automated checks on pushes and pull requests. · `.github/workflows/ci.yml`

## Connections

- Main → Settings: loads · Reads runtime parameters before startup.
- Main → Config: uses · Applies app configuration during bootstrap.
- Main → Engine: starts · Creates and runs the engine.
- Engine → Menu: hosts · Begins in the menu state and can switch scenes.
- Engine → Game: switches to · Delegates active play to the gameplay scene.
- Menu → Engine: requests start · Initiates transition into gameplay.
- Game → Models: updates · Advances core entities and combat state.
- Game → Grid: queries · Checks placement and map constraints.
- Game → Pathfinding: routes · Computes movement for moving units.
- Game → Assets: renders with · Uses content resources for visuals and effects.
- Grid → Pathfinding: feeds · Map layout informs route computation.
- Models → Grid: occupies · Entities interact with the board layout.
- Assets → Sprites: contains · Sprite image resources.
- Assets → Sounds: contains · Audio resources.
- Assets → Fonts: contains · Font resources.
- CI → Main: checks · Validates the repository on CI.
- View → Game: supports · Presentation helpers likely used by gameplay rendering.
