# loragegronde/pac-man architecture

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

- Interactive diagram: https://gitdiagram.com/loragegronde/pac-man
- Repository: https://github.com/loragegronde/pac-man

## Overview

This is a pygame Pac-Man game: the player starts from a menu, enters a ten-level campaign, and reaches victory or game over, where a name can be submitted to persistent highscores. The runtime also supports instructions, pause, and gameplay cheats. The graph preserves the documented gameplay stages and major UI branches. Some scene and campaign connections are documented in the README or named in the source index; unsampled implementation details are not inferred beyond those references.

Main entry points: [`src/graphics.py`](https://github.com/loragegronde/pac-man/blob/main/src/graphics.py) (Window and routing), [`src/visual/game.py`](https://github.com/loragegronde/pac-man/blob/main/src/visual/game.py) (Level simulation), [`src/visual/level_handler.py`](https://github.com/loragegronde/pac-man/blob/main/src/visual/level_handler.py) (Level progression), [`src/highscores.py`](https://github.com/loragegronde/pac-man/blob/main/src/highscores.py) (Highscores)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_scenes["Scenes and UI"]
  node_graphics["Window and routing<br/>[graphics.py]"]
  node_menu["Main menu<br/>[menu.py]"]
  node_instructions["Instructions<br/>[instructions.py]"]
  node_pause["Pause overlay<br/>[pause.py]"]
  node_cheatmenu["Cheat menu<br/>[cheat_menu.py]"]
  node_victory["Victory screen<br/>[victory.py]"]
  node_gameover["Game-over screen<br/>[game_over.py]"]
  node_namebox["Name entry<br/>[name_box.py]"]
  node_highscores["Highscores<br/>[highscores.py]"]
end

subgraph group_campaign["Campaign flow"]
  node_levelhandler["Level progression<br/>[level_handler.py]"]
  node_hud["Game HUD<br/>[hud.py]"]
end

subgraph group_simulation["Level simulation"]
  node_gamemode["Level simulation<br/>[game.py]"]
  node_maze["Maze generation<br/>[maze.py]"]
  node_playerchar["Pac-Man movement<br/>[player.py]"]
  node_ghosts["Ghost handling<br/>[enemy_handler.py]"]
  node_enemy["Ghost behavior<br/>[enemy.py]"]
  node_pathfinding["BFS pathfinding<br/>[pathfinding.py]"]
  node_cheats["Cheat state<br/>[cheats.py]"]
end

subgraph group_support["Configuration and assets"]
  node_entry["Game entry<br/>[pac-man.py]"]
  node_config["Config parsing<br/>[parsing.py]"]
  node_assets["Sprites and fonts<br/>[assets.py]"]
end

node_player(("Player"))
node_configfile["Game config<br/>[config.json]"]
node_scoresfile[("Highscore JSON")]
node_mazegenerator["Maze generator library<br/>external dependency"]

node_player -->|"provides input"| node_graphics
node_entry -->|"parses settings"| node_config
node_configfile -->|"loads JSON"| node_config
node_entry -->|"starts game"| node_graphics
node_graphics -->|"routes gameplay"| node_levelhandler
node_graphics -->|"routes scenes"| node_menu
node_graphics -->|"routes scenes"| node_instructions
node_graphics -->|"routes scenes"| node_pause
node_graphics -->|"routes scenes"| node_cheatmenu
node_graphics -->|"routes scenes"| node_victory
node_graphics -->|"routes scenes"| node_gameover
node_graphics -->|"handles entry"| node_namebox
node_graphics -->|"updates scores"| node_highscores
node_menu -->|"shows scores"| node_highscores
node_highscores -->|"reads and writes"| node_scoresfile
node_namebox -->|"submits name"| node_highscores
node_levelhandler -->|"creates levels"| node_gamemode
node_levelhandler -->|"updates display"| node_hud
node_gamemode -->|"creates maze"| node_maze
node_gamemode -->|"moves player"| node_playerchar
node_gamemode -->|"updates ghosts"| node_ghosts
node_ghosts -->|"updates ghosts"| node_enemy
node_enemy -->|"finds routes"| node_pathfinding
node_enemy -->|"reads grid"| node_maze
node_ghosts -->|"uses maze"| node_maze
node_gamemode -->|"checks flags"| node_cheats
node_levelhandler -->|"checks flags"| node_cheats
node_cheatmenu -->|"edits settings"| node_cheats
node_cheatmenu -->|"edits campaign"| node_levelhandler
node_gamemode -->|"loads sprites"| node_assets
node_levelhandler -->|"uses assets"| node_assets
node_maze -->|"generates grid"| node_mazegenerator

click node_configfile "https://github.com/loragegronde/pac-man/blob/main/config.json"
click node_entry "https://github.com/loragegronde/pac-man/blob/main/pac-man.py"
click node_config "https://github.com/loragegronde/pac-man/blob/main/src/parsing.py"
click node_graphics "https://github.com/loragegronde/pac-man/blob/main/src/graphics.py"
click node_menu "https://github.com/loragegronde/pac-man/blob/main/src/menu.py"
click node_instructions "https://github.com/loragegronde/pac-man/blob/main/src/instructions.py"
click node_pause "https://github.com/loragegronde/pac-man/blob/main/src/pause.py"
click node_cheatmenu "https://github.com/loragegronde/pac-man/blob/main/src/cheat_menu.py"
click node_victory "https://github.com/loragegronde/pac-man/blob/main/src/victory.py"
click node_gameover "https://github.com/loragegronde/pac-man/blob/main/src/game_over.py"
click node_namebox "https://github.com/loragegronde/pac-man/blob/main/src/name_box.py"
click node_highscores "https://github.com/loragegronde/pac-man/blob/main/src/highscores.py"
click node_levelhandler "https://github.com/loragegronde/pac-man/blob/main/src/visual/level_handler.py"
click node_hud "https://github.com/loragegronde/pac-man/blob/main/src/visual/hud.py"
click node_gamemode "https://github.com/loragegronde/pac-man/blob/main/src/visual/game.py"
click node_maze "https://github.com/loragegronde/pac-man/blob/main/src/visual/maze.py"
click node_playerchar "https://github.com/loragegronde/pac-man/blob/main/src/visual/player.py"
click node_ghosts "https://github.com/loragegronde/pac-man/blob/main/src/visual/enemy_handler.py"
click node_enemy "https://github.com/loragegronde/pac-man/blob/main/src/visual/enemy.py"
click node_pathfinding "https://github.com/loragegronde/pac-man/blob/main/src/visual/pathfinding.py"
click node_cheats "https://github.com/loragegronde/pac-man/blob/main/src/cheats.py"
click node_assets "https://github.com/loragegronde/pac-man/blob/main/src/assets.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_graphics,node_menu,node_instructions,node_pause,node_cheatmenu,node_victory,node_gameover,node_namebox,node_highscores toneBlue
class node_levelhandler,node_hud,node_scoresfile toneAmber
class node_gamemode,node_maze,node_playerchar,node_ghosts,node_enemy,node_pathfinding,node_cheats toneMint
class node_entry,node_config,node_assets toneRose
class node_player,node_mazegenerator toneIndigo
class node_configfile toneTeal
```

## Components

### Scenes and UI

- [Window and routing](https://github.com/loragegronde/pac-man/blob/main/src/graphics.py): `src/graphics.py`
- [Main menu](https://github.com/loragegronde/pac-man/blob/main/src/menu.py): `src/menu.py`
- [Instructions](https://github.com/loragegronde/pac-man/blob/main/src/instructions.py): `src/instructions.py`
- [Pause overlay](https://github.com/loragegronde/pac-man/blob/main/src/pause.py): `src/pause.py`
- [Cheat menu](https://github.com/loragegronde/pac-man/blob/main/src/cheat_menu.py): `src/cheat_menu.py`
- [Victory screen](https://github.com/loragegronde/pac-man/blob/main/src/victory.py): `src/victory.py`
- [Game-over screen](https://github.com/loragegronde/pac-man/blob/main/src/game_over.py): `src/game_over.py`
- [Name entry](https://github.com/loragegronde/pac-man/blob/main/src/name_box.py): `src/name_box.py`
- [Highscores](https://github.com/loragegronde/pac-man/blob/main/src/highscores.py): `src/highscores.py`

### Campaign flow

- [Level progression](https://github.com/loragegronde/pac-man/blob/main/src/visual/level_handler.py): `src/visual/level_handler.py`
- [Game HUD](https://github.com/loragegronde/pac-man/blob/main/src/visual/hud.py): `src/visual/hud.py`

### Level simulation

- [Level simulation](https://github.com/loragegronde/pac-man/blob/main/src/visual/game.py): `src/visual/game.py`
- [Maze generation](https://github.com/loragegronde/pac-man/blob/main/src/visual/maze.py): `src/visual/maze.py`
- [Pac-Man movement](https://github.com/loragegronde/pac-man/blob/main/src/visual/player.py): `src/visual/player.py`
- [Ghost handling](https://github.com/loragegronde/pac-man/blob/main/src/visual/enemy_handler.py): `src/visual/enemy_handler.py`
- [Ghost behavior](https://github.com/loragegronde/pac-man/blob/main/src/visual/enemy.py): `src/visual/enemy.py`
- [BFS pathfinding](https://github.com/loragegronde/pac-man/blob/main/src/visual/pathfinding.py): `src/visual/pathfinding.py`
- [Cheat state](https://github.com/loragegronde/pac-man/blob/main/src/cheats.py): `src/cheats.py`

### Configuration and assets

- [Game entry](https://github.com/loragegronde/pac-man/blob/main/pac-man.py): `pac-man.py`
- [Config parsing](https://github.com/loragegronde/pac-man/blob/main/src/parsing.py): `src/parsing.py`
- [Sprites and fonts](https://github.com/loragegronde/pac-man/blob/main/src/assets.py): `src/assets.py`

### Other components

- **Player**
- [Game config](https://github.com/loragegronde/pac-man/blob/main/config.json): `config.json`
- **Highscore JSON**
- **Maze generator library**: external dependency

## Connections

- Player → Window and routing: provides input (evidence: `README.md`)
- Game entry → Config parsing: parses settings (evidence: `README.md`)
- Game config → Config parsing: loads JSON (evidence: `src/parsing.py`)
- Game entry → Window and routing: starts game (evidence: `README.md`)
- Window and routing → Level progression: routes gameplay (evidence: `src/graphics.py`)
- Window and routing → Main menu: routes scenes (evidence: `README.md`)
- Window and routing → Instructions: routes scenes (evidence: `README.md`)
- Window and routing → Pause overlay: routes scenes (evidence: `README.md`)
- Window and routing → Cheat menu: routes scenes (evidence: `README.md`)
- Window and routing → Victory screen: routes scenes (evidence: `src/graphics.py`)
- Window and routing → Game-over screen: routes scenes (evidence: `src/graphics.py`)
- Window and routing → Name entry: handles entry (evidence: `src/graphics.py`)
- Window and routing → Highscores: updates scores (evidence: `src/graphics.py`)
- Main menu → Highscores: shows scores (evidence: `src/menu.py`)
- Highscores → Highscore JSON: reads and writes (evidence: `README.md`)
- Name entry → Highscores: submits name (evidence: `src/graphics.py`)
- Level progression → Level simulation: creates levels (evidence: `src/visual/level_handler.py`)
- Level progression → Game HUD: updates display (evidence: `src/visual/level_handler.py`)
- Level simulation → Maze generation: creates maze (evidence: `src/visual/game.py`)
- Level simulation → Pac-Man movement: moves player (evidence: `src/visual/game.py`)
- Level simulation → Ghost handling: updates ghosts (evidence: `src/visual/game.py`)
- Ghost handling → Ghost behavior: updates ghosts (evidence: `src/visual/enemy_handler.py`)
- Ghost behavior → BFS pathfinding: finds routes (evidence: `src/visual/enemy.py`)
- Ghost behavior → Maze generation: reads grid (evidence: `src/visual/enemy.py`)
- Ghost handling → Maze generation: uses maze (evidence: `src/visual/enemy_handler.py`)
- Level simulation → Cheat state: checks flags (evidence: `src/visual/game.py`)
- Level progression → Cheat state: checks flags (evidence: `src/visual/level_handler.py`)
- Cheat menu → Cheat state: edits settings (evidence: `src/cheat_menu.py`)
- Cheat menu → Level progression: edits campaign (evidence: `src/cheat_menu.py`)
- Level simulation → Sprites and fonts: loads sprites (evidence: `src/visual/game.py`)
- Level progression → Sprites and fonts: uses assets (evidence: `src/visual/level_handler.py`)
- Maze generation → Maze generator library: generates grid (evidence: `src/visual/maze.py`)
