# shayanshahrabi/pac-man architecture

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

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

## Overview

##### Main Components
- Game Engine/Main Controller – Represented by the pacman.cpp source code that implements all game logic including user input processing, game-loop control, and handling game state.
- Maze Generation Module – A clearly identifiable component since the README explains that the maze is generated using the DFS algorithm. This can be a module/function focused on creating the game’s maze based on user-specified dimensions.
- Ghost AI / Pathfinding Module – The README describes using BFS for ghost movement. Illustrate this as a separate logical component (or submodule) within the game engine that controls the behavior of the ghosts (like Blinky and the others with varied targeting strategies).
- Data Persistence Component – This portion handles file operations. Three files (scoreBoard.txt, maze.txt, and creature.txt) are used to store the leader board and checkpoint data. A module should be depicted that checks, reads, writes, and creates these files as needed.
- External Dependencies – Note the use of Windows-specific libraries and support for terminal environments that correctly display Unicode characters.

##### Architectural Patterns & Principles
- Even though it’s a relatively simple project, note the modular design: separate concerns for game logic, maze generation, AI, rendering, and persistence.
- Mention that the overall design is essentially a tightly-coupled, monolithic application with distinct responsibilities, which is common in smaller, educational projects.

##### Commentary on Technologies and Tools
- Technology: C++ is the primary language, and it leverages system-specific libraries (windows.h).
- Frameworks: No external frameworks are used; instead, console output and file I/O are handled directly within C++.
- Data Storage: Use of text files to persist game state and leader board data, which implies simple file system integration without databases.

## Diagram (Mermaid)

```mermaid
graph TD
    A["User Input (Terminal/Keyboard)"]:::input
    B["Game Engine/Main Controller"]:::engine
    C["Maze Generation Module (DFS)"]:::processing
    D["Ghost AI / Pathfinding Module (BFS)"]:::processing
    E["Graphics/Display Engine (ASCII/Unicode)"]:::processing
    subgraph "Data Persistence Component"
        F["ScoreBoard.txt"]:::peripheral
        G["maze.txt"]:::peripheral
        H["creature.txt"]:::peripheral
    end
    I["External Dependencies (Windows-specific)"]:::peripheral

    A -->|"triggers"| B
    B -->|"calls_DFS"| C
    B -->|"calls_BFS"| D
    B -->|"updates"| E
    B -->|"reads/writes"| F
    B -->|"reads/writes"| G
    B -->|"reads/writes"| H
    B -->|"uses"| I

    click B "https://github.com/shayanshahrabi/pac-man/blob/main/pacman.cpp"
    click C "https://github.com/shayanshahrabi/pac-man/blob/main/pacman.cpp"
    click D "https://github.com/shayanshahrabi/pac-man/blob/main/pacman.cpp"
    click E "https://github.com/shayanshahrabi/pac-man/blob/main/pacman.cpp"
    click I "https://github.com/shayanshahrabi/pac-man/blob/main/pacman.cpp"
    click F "https://github.com/shayanshahrabi/pac-man/blob/main/scoreBoard.txt"
    click G "https://github.com/shayanshahrabi/pac-man/blob/main/maze.txt"
    click H "https://github.com/shayanshahrabi/pac-man/blob/main/creature.txt"

    classDef input fill:#d2b4de,stroke:#333,stroke-width:2px;
    classDef engine fill:#98fb98,stroke:#333,stroke-width:2px;
    classDef processing fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef peripheral fill:#a0d8ef,stroke:#333,stroke-width:2px;
```
