# psalant726/pac-go architecture

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

- Interactive diagram: https://gitdiagram.com/psalant726/pac-go
- Repository: https://github.com/psalant726/pac-go

## Overview

- Configuration → Game Engine (game settings)
- Input/Output → Game Engine (player commands)
- Game Engine → Input/Output (render updates)
- Game Engine ↔ Game Entities (state updates)

- Initialization flow
- Event handling paths

##### Important Details

- Player lives
- Pill duration
- Frame rate
- Scoring system

- config.json/config_noemoji.json
- maze01.txt

##### Technical Specifications

- Go source files (ghost.go, player.go, maze.go, etc.)
- Configuration files (JSON)
- Resource files (maze definitions)
- User input/output channels

##### Architecture Notes

Annotations showing:
- Terminal-based UI architecture
- Game state management
- Entity interaction system
- Collision detection system
- Score tracking mechanism

- The event-driven nature of the game
- The separation between game logic and rendering
- The configuration system's flexibility
- The entity management system
- The maze rendering and collision detection systems

Keep the abstraction level focused on the main architectural components while showing enough detail to understand the game's operation. Use a clean, organized layout with clear separation between different subsystems.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        L1[Game Components]:::component
        L2[(Data Storage)]:::storage
        L3[/Input Output/]:::io
        L4{{Core Engine}}:::core
        L5([Configuration]):::config
    end

    subgraph "Input/Output Layer"
        IO[/Terminal Interface/]:::io
        KH[/Keyboard Handler/]:::io
        SR[/Screen Renderer/]:::io
    end

    subgraph "Configuration System"
        CM([Config Manager]):::config
        CF[(Config Files)]:::storage
        MF[(Maze Files)]:::storage
    end

    subgraph "Core Engine"
        GE{{Game Engine}}:::core
        GL{{Game Loop}}:::core
        ST{{State Manager}}:::core
    end

    subgraph "Game Entities"
        PM[Player Manager]:::component
        GM[Ghost Manager]:::component
        MM[Maze Manager]:::component
        CD[Collision Detector]:::component
        SM[Score Manager]:::component
    end

    %% Relationships
    IO --> KH
    KH --> GE
    GE --> SR
    SR --> IO

    CM --> CF
    CM --> MF
    CM --> GE

    GE --> GL
    GL --> ST
    ST --> PM
    ST --> GM
    ST --> MM
    ST --> CD
    ST --> SM

    CD --> PM
    CD --> GM
    CD --> MM

    %% Styling
    classDef core fill:#f9f,stroke:#333,stroke-width:2px
    classDef component fill:#bbf,stroke:#333,stroke-width:1px
    classDef storage fill:#dfd,stroke:#333,stroke-width:1px
    classDef io fill:#fdd,stroke:#333,stroke-width:1px
    classDef config fill:#ddf,stroke:#333,stroke-width:1px

    %% Click Events
    click GE "https://github.com/PSalant726/Pac-Go/blob/master/main.go"
    click CM "https://github.com/PSalant726/Pac-Go/blob/master/config.go"
    click CF "https://github.com/PSalant726/Pac-Go/blob/master/lib/config.json"
    click MF "https://github.com/PSalant726/Pac-Go/blob/master/lib/maze01.txt"
    click PM "https://github.com/PSalant726/Pac-Go/blob/master/player.go"
    click GM "https://github.com/PSalant726/Pac-Go/blob/master/ghost.go"
    click MM "https://github.com/PSalant726/Pac-Go/blob/master/maze.go"
    click IO "https://github.com/PSalant726/Pac-Go/blob/master/utils.go"

    %% Notes
    subgraph "Configuration Options"
        CO1[Player Lives]
        CO2[Pill Duration]
        CO3[Frame Rate]
        CO4[Scoring System]
    end
```
