# prmayekar/chess architecture

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

- Interactive diagram: https://gitdiagram.com/prmayekar/chess
- Repository: https://github.com/prmayekar/chess

## Overview

This is a Raylib desktop chess game: users choose pass-and-play or a side against Stockfish, play through move selection and validation, handle promotion and game-ending states, and receive a result; games are logged in UCI notation. The graph distinguishes the menu, game orchestration, chess rules and rendering, and engine integration. Core behavior is supported by excerpts and README statements; unsampled implementation details are not inferred.

Main entry points: [`src/game.cpp`](https://github.com/prmayekar/chess/blob/master/src/game.cpp) (Game Flow), [`src/mainMenu.cpp`](https://github.com/prmayekar/chess/blob/master/src/mainMenu.cpp) (Mode Menu), [`src/board.cpp`](https://github.com/prmayekar/chess/blob/master/src/board.cpp) (Board Rules), [`src/main.cpp`](https://github.com/prmayekar/chess/blob/master/src/main.cpp) (Application Entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User Interface"]
  node_entry["Application Entry<br/>[main.cpp]"]
  node_menu["Mode Menu<br/>[mainMenu.cpp]"]
  node_renderer["Raylib"]
end

subgraph group_gameplay["Chess Gameplay"]
  node_game["Game Flow<br/>[game.cpp]"]
  node_board["Board Rules<br/>[board.cpp]"]
  node_piece["Chess Pieces<br/>[piece.cpp]"]
  node_tile["Board Tiles<br/>[tile.cpp]"]
  node_state["Game States<br/>[utils.h]"]
  node_log["UCI Game Log<br/>[game.cpp]"]
end

subgraph group_engine["Engine Integration"]
  node_stockfish["Stockfish IPC<br/>[stockfish.cpp]"]
  node_engine_process["Stockfish Engine"]
end

subgraph group_runtime["Shared Runtime"]
  node_resources["Resource Lookup<br/>[resource_dir.h]"]
end

node_player(("Player"))

node_player -->|"starts"| node_entry
node_entry -->|"displays"| node_menu
node_player -->|"selects mode"| node_menu
node_menu -->|"starts mode"| node_game
node_game -->|"updates and checks"| node_board
node_board -->|"uses"| node_piece
node_board -->|"uses"| node_tile
node_game -->|"tracks states"| node_state
node_game -->|"requests moves"| node_stockfish
node_stockfish -->|"exchanges UCI"| node_engine_process
node_game -->|"writes moves"| node_log
node_menu -->|"draws interface"| node_renderer
node_game -->|"draws game"| node_renderer
node_game -.->|"uses resource lookup"| node_resources

click node_entry "https://github.com/prmayekar/chess/blob/master/src/main.cpp"
click node_menu "https://github.com/prmayekar/chess/blob/master/src/mainMenu.cpp"
click node_game "https://github.com/prmayekar/chess/blob/master/src/game.cpp"
click node_board "https://github.com/prmayekar/chess/blob/master/src/board.cpp"
click node_piece "https://github.com/prmayekar/chess/blob/master/src/piece.cpp"
click node_tile "https://github.com/prmayekar/chess/blob/master/src/tile.cpp"
click node_state "https://github.com/prmayekar/chess/blob/master/src/utils.h"
click node_log "https://github.com/prmayekar/chess/blob/master/src/game.cpp"
click node_stockfish "https://github.com/prmayekar/chess/blob/master/src/stockfish.cpp"
click node_resources "https://github.com/prmayekar/chess/blob/master/include/resource_dir.h"

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_entry,node_menu,node_renderer toneBlue
class node_game,node_board,node_piece,node_tile,node_state,node_log toneAmber
class node_stockfish,node_engine_process toneMint
class node_resources toneRose
class node_player toneIndigo
```

## Components

### User Interface

- [Application Entry](https://github.com/prmayekar/chess/blob/master/src/main.cpp): `src/main.cpp`
- [Mode Menu](https://github.com/prmayekar/chess/blob/master/src/mainMenu.cpp): `src/mainMenu.cpp`
- **Raylib**

### Chess Gameplay

- [Game Flow](https://github.com/prmayekar/chess/blob/master/src/game.cpp): `src/game.cpp`
- [Board Rules](https://github.com/prmayekar/chess/blob/master/src/board.cpp): `src/board.cpp`
- [Chess Pieces](https://github.com/prmayekar/chess/blob/master/src/piece.cpp): `src/piece.cpp`
- [Board Tiles](https://github.com/prmayekar/chess/blob/master/src/tile.cpp): `src/tile.cpp`
- [Game States](https://github.com/prmayekar/chess/blob/master/src/utils.h): `src/utils.h`
- [UCI Game Log](https://github.com/prmayekar/chess/blob/master/src/game.cpp): `src/game.cpp`

### Engine Integration

- [Stockfish IPC](https://github.com/prmayekar/chess/blob/master/src/stockfish.cpp): `src/stockfish.cpp`
- **Stockfish Engine**

### Shared Runtime

- [Resource Lookup](https://github.com/prmayekar/chess/blob/master/include/resource_dir.h): `include/resource_dir.h`

### Other components

- **Player**

## Connections

- Player → Application Entry: starts (evidence: `src/main.cpp`)
- Application Entry → Mode Menu: displays (evidence: `src/main.cpp`)
- Player → Mode Menu: selects mode (evidence: `src/mainMenu.cpp`)
- Mode Menu → Game Flow: starts mode (evidence: `src/mainMenu.cpp`)
- Game Flow → Board Rules: updates and checks (evidence: `src/game.cpp`)
- Board Rules → Chess Pieces: uses
- Board Rules → Board Tiles: uses
- Game Flow → Game States: tracks states (evidence: `src/game.cpp`)
- Game Flow → Stockfish IPC: requests moves (evidence: `src/game.cpp`)
- Stockfish IPC → Stockfish Engine: exchanges UCI (evidence: `README.md`)
- Game Flow → UCI Game Log: writes moves (evidence: `README.md`)
- Mode Menu → Raylib: draws interface (evidence: `src/mainMenu.cpp`)
- Game Flow → Raylib: draws game (evidence: `README.md`)
- Game Flow → Resource Lookup: uses resource lookup (evidence: `src/game.cpp`)
