# reevew/chessgame architecture

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

- Interactive diagram: https://gitdiagram.com/reevew/chessgame
- Repository: https://github.com/reevew/chessgame

## Overview

ChessGame is a local, graphical chess application. The user workflow is to launch the game, drag a piece, see legal destinations, and drop it; Game coordinates board updates and turn changes, while Board calculates legal moves and special chess rules. The README also documents promotion, castling, en passant, and terminal win reporting. The graph reflects only relationships visible in the excerpts or README; unshown event dispatch and some rendering details are omitted.

Main entry points: [`Game.cpp`](https://github.com/reevew/chessgame/blob/main/Game.cpp) (Game controller), [`Board.cpp`](https://github.com/reevew/chessgame/blob/main/Board.cpp) (Legal moves), [`main.cpp`](https://github.com/reevew/chessgame/blob/main/main.cpp) (Game startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Game interface"]
  node_entry["Game startup<br/>[main.cpp]"]
  node_game["Game controller<br/>[Game.cpp]"]
  node_assets["Piece graphics<br/>[Game.cpp]"]
  node_terminal["Win reporting<br/>[Game.cpp]"]
end

subgraph group_rules["Chess rules"]
  node_board["Board state<br/>[Board.cpp]"]
  node_moves["Legal moves<br/>[Board.cpp]"]
  node_attacks["Check and attacks<br/>[Board.cpp]"]
  node_special["Special moves<br/>[Board.cpp]"]
end

node_player(("Player"))

node_player -->|"starts game"| node_entry
node_entry -->|"runs"| node_game
node_game -->|"loads sprites"| node_assets
node_game -->|"initializes moves"| node_board
node_player -->|"drags pieces"| node_game
node_game -->|"requests moves"| node_moves
node_moves -->|"reads position"| node_board
node_moves -->|"checks attacks"| node_attacks
node_moves -->|"handles rules"| node_special
node_game -->|"updates position"| node_board
node_game -->|"handles promotion"| node_special
node_game -->|"moves castle rook"| node_special
node_game -->|"removes en passant"| node_special
node_game -.->|"reports win"| node_terminal
node_game -->|"highlights moves"| node_player

click node_entry "https://github.com/reevew/chessgame/blob/main/main.cpp"
click node_game "https://github.com/reevew/chessgame/blob/main/Game.cpp"
click node_assets "https://github.com/reevew/chessgame/blob/main/Game.cpp"
click node_board "https://github.com/reevew/chessgame/blob/main/Board.cpp"
click node_moves "https://github.com/reevew/chessgame/blob/main/Board.cpp"
click node_attacks "https://github.com/reevew/chessgame/blob/main/Board.cpp"
click node_special "https://github.com/reevew/chessgame/blob/main/Board.cpp"
click node_terminal "https://github.com/reevew/chessgame/blob/main/Game.cpp"

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_game,node_assets,node_terminal toneBlue
class node_board,node_moves,node_attacks,node_special toneAmber
class node_player toneIndigo
```

## Components

### Game interface

- [Game startup](https://github.com/reevew/chessgame/blob/main/main.cpp): `main.cpp`
- [Game controller](https://github.com/reevew/chessgame/blob/main/Game.cpp): `Game.cpp`
- [Piece graphics](https://github.com/reevew/chessgame/blob/main/Game.cpp): `Game.cpp`
- [Win reporting](https://github.com/reevew/chessgame/blob/main/Game.cpp): `Game.cpp`

### Chess rules

- [Board state](https://github.com/reevew/chessgame/blob/main/Board.cpp): `Board.cpp`
- [Legal moves](https://github.com/reevew/chessgame/blob/main/Board.cpp): `Board.cpp`
- [Check and attacks](https://github.com/reevew/chessgame/blob/main/Board.cpp): `Board.cpp`
- [Special moves](https://github.com/reevew/chessgame/blob/main/Board.cpp): `Board.cpp`

### Other components

- **Player**

## Connections

- Player → Game startup: starts game (evidence: `README.md`)
- Game startup → Game controller: runs (evidence: `main.cpp`)
- Game controller → Piece graphics: loads sprites (evidence: `Game.cpp`)
- Game controller → Board state: initializes moves (evidence: `Game.cpp`)
- Player → Game controller: drags pieces (evidence: `README.md`)
- Game controller → Legal moves: requests moves (evidence: `Game.cpp`)
- Legal moves → Board state: reads position (evidence: `Board.cpp`)
- Legal moves → Check and attacks: checks attacks (evidence: `Board.cpp`)
- Legal moves → Special moves: handles rules (evidence: `Board.cpp`)
- Game controller → Board state: updates position (evidence: `Game.cpp`)
- Game controller → Special moves: handles promotion (evidence: `Game.cpp`)
- Game controller → Special moves: moves castle rook (evidence: `Game.cpp`)
- Game controller → Special moves: removes en passant (evidence: `Game.cpp`)
- Game controller → Win reporting: reports win (evidence: `README.md`)
- Game controller → Player: highlights moves (evidence: `README.md`)
