# gabriellui1/chess architecture

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

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

## Overview

This is a terminal chess game. The main workflow is command input, state-aware parsing, controller dispatch, move selection, board updates and rule evaluation, followed by text output and score updates. Setup, undo and PGN display are distinct game capabilities; computer opponents provide four difficulty levels. The board also owns move history and exposes observer updates. The README is only a brief TODO list, so it does not document architecture; relationships below are limited to the supplied source excerpts and index references.

Main entry points: [`GameController.cpp`](https://github.com/gabriellui1/chess/blob/main/GameController.cpp) (Game controller), [`Computer.cpp`](https://github.com/gabriellui1/chess/blob/main/Computer.cpp) (Computer base), [`PieceFactory.cpp`](https://github.com/gabriellui1/chess/blob/main/PieceFactory.cpp) (Piece factory), [`Board.cpp`](https://github.com/gabriellui1/chess/blob/main/Board.cpp) (Board and history)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Game control"]
  node_main["Program entry<br/>[main.cpp]"]
  node_controller["Game controller<br/>[GameController.cpp]"]
  node_parser["Command parser<br/>[CommandParser.cpp]"]
  node_helper["Chess utilities<br/>[Helper.cpp]"]
  node_score["Scoreboard<br/>[ScoreBoard.cpp]"]
end

subgraph group_chess["Chess domain"]
  node_board["Board and history<br/>[Board.cpp]"]
  node_rules["Move rules<br/>[Rules.cpp]"]
  node_piece["Piece behavior<br/>[Piece.cpp]"]
  node_pawn["Pawn behavior<br/>[Pawn.cpp]"]
  node_pieces["Other pieces<br/>[Pieces.cpp]"]
  node_factory["Piece factory<br/>[PieceFactory.cpp]"]
end

subgraph group_players["Players"]
  node_player["Human player<br/>[Player.cpp]"]
  node_computer["Computer base<br/>[Computer.cpp]"]
  node_level1["Computer level 1<br/>[Level1.cpp]"]
  node_level2["Computer level 2<br/>[Level2.cpp]"]
  node_level3["Computer level 3<br/>[Level3.cpp]"]
  node_level4["Computer level 4<br/>[Level4.cpp]"]
end

subgraph group_interface["Terminal interface"]
  node_view["Text view<br/>[TextView.cpp]"]
end

node_user(("Terminal user"))

node_main -->|"runs"| node_controller
node_user -->|"enters commands"| node_controller
node_controller -->|"parses input"| node_parser
node_controller -->|"shows output"| node_view
node_controller -->|"updates board"| node_board
node_controller -->|"checks position"| node_rules
node_controller -->|"selects human"| node_player
node_controller -->|"creates opponent"| node_level1
node_controller -->|"creates opponent"| node_level2
node_controller -->|"creates opponent"| node_level3
node_controller -->|"creates opponent"| node_level4
node_controller -->|"creates setup piece"| node_factory
node_controller -->|"records result"| node_score
node_controller -->|"formats messages"| node_helper
node_board -->|"notifies observer"| node_view
node_factory -->|"creates pawn"| node_pawn
node_factory -->|"creates pieces"| node_pieces
node_level1 -->|"specializes"| node_computer
node_level2 -->|"specializes"| node_computer
node_level3 -->|"specializes"| node_computer
node_level4 -->|"specializes"| node_computer
node_computer -->|"uses rules"| node_rules
node_pawn -->|"inherits behavior"| node_piece
node_pieces -->|"inherits behavior"| node_piece

click node_main "https://github.com/gabriellui1/chess/blob/main/main.cpp"
click node_controller "https://github.com/gabriellui1/chess/blob/main/GameController.cpp"
click node_parser "https://github.com/gabriellui1/chess/blob/main/CommandParser.cpp"
click node_helper "https://github.com/gabriellui1/chess/blob/main/Helper.cpp"
click node_board "https://github.com/gabriellui1/chess/blob/main/Board.cpp"
click node_rules "https://github.com/gabriellui1/chess/blob/main/Rules.cpp"
click node_piece "https://github.com/gabriellui1/chess/blob/main/Piece.cpp"
click node_pawn "https://github.com/gabriellui1/chess/blob/main/Pawn.cpp"
click node_pieces "https://github.com/gabriellui1/chess/blob/main/Pieces.cpp"
click node_factory "https://github.com/gabriellui1/chess/blob/main/PieceFactory.cpp"
click node_player "https://github.com/gabriellui1/chess/blob/main/Player.cpp"
click node_computer "https://github.com/gabriellui1/chess/blob/main/Computer.cpp"
click node_level1 "https://github.com/gabriellui1/chess/blob/main/Level1.cpp"
click node_level2 "https://github.com/gabriellui1/chess/blob/main/Level2.cpp"
click node_level3 "https://github.com/gabriellui1/chess/blob/main/Level3.cpp"
click node_level4 "https://github.com/gabriellui1/chess/blob/main/Level4.cpp"
click node_score "https://github.com/gabriellui1/chess/blob/main/ScoreBoard.cpp"
click node_view "https://github.com/gabriellui1/chess/blob/main/TextView.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_main,node_controller,node_parser,node_helper,node_score,node_user toneBlue
class node_board,node_rules,node_piece,node_pawn,node_pieces,node_factory toneAmber
class node_player,node_computer,node_level1,node_level2,node_level3,node_level4 toneMint
class node_view toneRose
```

## Components

### Game control

- [Program entry](https://github.com/gabriellui1/chess/blob/main/main.cpp): `main.cpp`
- [Game controller](https://github.com/gabriellui1/chess/blob/main/GameController.cpp): `GameController.cpp`
- [Command parser](https://github.com/gabriellui1/chess/blob/main/CommandParser.cpp): `CommandParser.cpp`
- [Chess utilities](https://github.com/gabriellui1/chess/blob/main/Helper.cpp): `Helper.cpp`
- [Scoreboard](https://github.com/gabriellui1/chess/blob/main/ScoreBoard.cpp): `ScoreBoard.cpp`

### Chess domain

- [Board and history](https://github.com/gabriellui1/chess/blob/main/Board.cpp): `Board.cpp`
- [Move rules](https://github.com/gabriellui1/chess/blob/main/Rules.cpp): `Rules.cpp`
- [Piece behavior](https://github.com/gabriellui1/chess/blob/main/Piece.cpp): `Piece.cpp`
- [Pawn behavior](https://github.com/gabriellui1/chess/blob/main/Pawn.cpp): `Pawn.cpp`
- [Other pieces](https://github.com/gabriellui1/chess/blob/main/Pieces.cpp): `Pieces.cpp`
- [Piece factory](https://github.com/gabriellui1/chess/blob/main/PieceFactory.cpp): `PieceFactory.cpp`

### Players

- [Human player](https://github.com/gabriellui1/chess/blob/main/Player.cpp): `Player.cpp`
- [Computer base](https://github.com/gabriellui1/chess/blob/main/Computer.cpp): `Computer.cpp`
- [Computer level 1](https://github.com/gabriellui1/chess/blob/main/Level1.cpp): `Level1.cpp`
- [Computer level 2](https://github.com/gabriellui1/chess/blob/main/Level2.cpp): `Level2.cpp`
- [Computer level 3](https://github.com/gabriellui1/chess/blob/main/Level3.cpp): `Level3.cpp`
- [Computer level 4](https://github.com/gabriellui1/chess/blob/main/Level4.cpp): `Level4.cpp`

### Terminal interface

- [Text view](https://github.com/gabriellui1/chess/blob/main/TextView.cpp): `TextView.cpp`

### Other components

- **Terminal user**

## Connections

- Program entry → Game controller: runs (evidence: `main.cpp`)
- Terminal user → Game controller: enters commands (evidence: `GameController.cpp`)
- Game controller → Command parser: parses input (evidence: `GameController.cpp`)
- Game controller → Text view: shows output (evidence: `GameController.cpp`)
- Game controller → Board and history: updates board (evidence: `GameController.cpp`)
- Game controller → Move rules: checks position (evidence: `GameController.cpp`)
- Game controller → Human player: selects human (evidence: `GameController.cpp`)
- Game controller → Computer level 1: creates opponent (evidence: `GameController.cpp`)
- Game controller → Computer level 2: creates opponent (evidence: `GameController.cpp`)
- Game controller → Computer level 3: creates opponent (evidence: `GameController.cpp`)
- Game controller → Computer level 4: creates opponent (evidence: `GameController.cpp`)
- Game controller → Piece factory: creates setup piece (evidence: `GameController.cpp`)
- Game controller → Scoreboard: records result (evidence: `GameController.cpp`)
- Game controller → Chess utilities: formats messages (evidence: `GameController.cpp`)
- Board and history → Text view: notifies observer (evidence: `Board.cpp`)
- Piece factory → Pawn behavior: creates pawn (evidence: `PieceFactory.cpp`)
- Piece factory → Other pieces: creates pieces (evidence: `PieceFactory.cpp`)
- Computer level 1 → Computer base: specializes
- Computer level 2 → Computer base: specializes
- Computer level 3 → Computer base: specializes
- Computer level 4 → Computer base: specializes
- Computer base → Move rules: uses rules
- Pawn behavior → Piece behavior: inherits behavior
- Other pieces → Piece behavior: inherits behavior
