# zakari-a/pac-man architecture

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

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

## Overview

Pac-Man is a pygame game: the player selects a screen, plays through generated maze levels, and can submit scores to a persistent high-score list. The main loop in `src/game.py` coordinates configuration, level setup, entity updates, screens, and rendering. The README documents ghost pathfinding, scoring, collision, and multiple game states; those gameplay details are grouped where the available source supports them. Some runtime wiring is inferred only from the README because the relevant source excerpts are partial.

Main entry points: [`src/game.py`](https://github.com/zakari-a/pac-man/blob/main/src/game.py) (Game loop), [`pac-man.py`](https://github.com/zakari-a/pac-man/blob/main/pac-man.py) (Game entry), [`src/game_view/ui.py`](https://github.com/zakari-a/pac-man/blob/main/src/game_view/ui.py) (Game screens), [`src/maze/maze_adapter.py`](https://github.com/zakari-a/pac-man/blob/main/src/maze/maze_adapter.py) (Maze adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Startup and Config"]
  node_launcher["Game entry<br/>[pac-man.py]"]
  node_config["Config loader<br/>[config.py]"]
end

subgraph group_flow["Game Flow"]
  node_game["Game loop<br/>[game.py]"]
  node_screens["Game screens<br/>[ui.py]"]
  node_banners["Result banners<br/>[banners.py]"]
end

subgraph group_world["Maze and Entities"]
  node_maze["Maze adapter<br/>[maze_adapter.py]"]
  node_generator["Maze generator"]
  node_entities["Pac-Man and ghosts<br/>[entities.py]"]
end

subgraph group_presentation["Display and Assets"]
  node_renderer["Game renderer<br/>[renderer.py]"]
  node_assets["Asset manager<br/>[assetmanager.py]"]
end

subgraph group_persistence["Scores"]
  node_highscores[("High-score file")]
end

node_player(("Player"))

node_player -->|"starts game"| node_launcher
node_launcher -->|"loads config"| node_config
node_launcher -->|"starts loop"| node_game
node_game -->|"generates levels"| node_maze
node_maze -->|"requests maze"| node_generator
node_game -->|"creates and updates"| node_entities
node_game -->|"loads assets"| node_assets
node_game -->|"draws frame"| node_renderer
node_game -->|"dispatches screens"| node_screens
node_game -->|"shows results"| node_banners
node_screens -->|"reads and writes"| node_highscores
node_player -->|"navigates"| node_screens

click node_launcher "https://github.com/zakari-a/pac-man/blob/main/pac-man.py"
click node_config "https://github.com/zakari-a/pac-man/blob/main/src/config/config.py"
click node_game "https://github.com/zakari-a/pac-man/blob/main/src/game.py"
click node_screens "https://github.com/zakari-a/pac-man/blob/main/src/game_view/ui.py"
click node_banners "https://github.com/zakari-a/pac-man/blob/main/src/game_view/banners.py"
click node_maze "https://github.com/zakari-a/pac-man/blob/main/src/maze/maze_adapter.py"
click node_generator "https://github.com/zakari-a/pac-man/blob/main/libs/mazegenerator-00001-py3-none-any.whl"
click node_entities "https://github.com/zakari-a/pac-man/blob/main/src/entities/entities.py"
click node_renderer "https://github.com/zakari-a/pac-man/blob/main/src/renderer/renderer.py"
click node_assets "https://github.com/zakari-a/pac-man/blob/main/src/assets_manager/assetmanager.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_launcher,node_config toneBlue
class node_game,node_screens,node_banners toneAmber
class node_maze,node_generator,node_entities toneMint
class node_renderer,node_assets toneRose
class node_highscores,node_player toneIndigo
```

## Components

### Startup and Config

- [Game entry](https://github.com/zakari-a/pac-man/blob/main/pac-man.py): `pac-man.py`
- [Config loader](https://github.com/zakari-a/pac-man/blob/main/src/config/config.py): `src/config/config.py`

### Game Flow

- [Game loop](https://github.com/zakari-a/pac-man/blob/main/src/game.py): `src/game.py`
- [Game screens](https://github.com/zakari-a/pac-man/blob/main/src/game_view/ui.py): `src/game_view/ui.py`
- [Result banners](https://github.com/zakari-a/pac-man/blob/main/src/game_view/banners.py): `src/game_view/banners.py`

### Maze and Entities

- [Maze adapter](https://github.com/zakari-a/pac-man/blob/main/src/maze/maze_adapter.py): `src/maze/maze_adapter.py`
- [Maze generator](https://github.com/zakari-a/pac-man/blob/main/libs/mazegenerator-00001-py3-none-any.whl): `libs/mazegenerator-00001-py3-none-any.whl`
- [Pac-Man and ghosts](https://github.com/zakari-a/pac-man/blob/main/src/entities/entities.py): `src/entities/entities.py`

### Display and Assets

- [Game renderer](https://github.com/zakari-a/pac-man/blob/main/src/renderer/renderer.py): `src/renderer/renderer.py`
- [Asset manager](https://github.com/zakari-a/pac-man/blob/main/src/assets_manager/assetmanager.py): `src/assets_manager/assetmanager.py`

### Scores

- **High-score file**

### Other components

- **Player**

## Connections

- Player → Game entry: starts game
- Game entry → Config loader: loads config
- Game entry → Game loop: starts loop
- Game loop → Maze adapter: generates levels
- Maze adapter → Maze generator: requests maze
- Game loop → Pac-Man and ghosts: creates and updates
- Game loop → Asset manager: loads assets
- Game loop → Game renderer: draws frame
- Game loop → Game screens: dispatches screens
- Game loop → Result banners: shows results
- Game screens → High-score file: reads and writes
- Player → Game screens: navigates
