# deepakvalmani/chess-main architecture

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

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

## Overview

This is an interactive C++/SFML chess game. A player chooses a mode, selects a piece, and attempts a move; the game validates it, updates the board, and reports check or game end. In AI mode the board supplies a random legal reply. The graph separates the interface, board/game rules, and piece movement. Several piece implementations are indexed but not excerpted, so their rule interactions are not asserted beyond documented polymorphism.

Main entry points: [`include/src/board.cpp`](https://github.com/deepakvalmani/chess-main/blob/master/include/src/board.cpp) (Board and game rules), [`include/piece.h`](https://github.com/deepakvalmani/chess-main/blob/master/include/piece.h) (Piece base), [`include/src/main.cpp`](https://github.com/deepakvalmani/chess-main/blob/master/include/src/main.cpp) (Game loop and UI), [`include/src/pawn.cpp`](https://github.com/deepakvalmani/chess-main/blob/master/include/src/pawn.cpp) (Pawn rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Game interface"]
  node_app["Game loop and UI<br/>[main.cpp]"]
end

subgraph group_rules["Board and rules"]
  node_board["Board and game rules<br/>[board.cpp]"]
end

subgraph group_pieces["Piece movement"]
  node_piecebase["Piece base<br/>[piece.h]"]
  node_pawn["Pawn rules<br/>[pawn.cpp]"]
  node_rook["Rook rules<br/>[rook.cpp]"]
  node_bishop["Bishop rules<br/>[bishop.cpp]"]
  node_knight["Knight rules<br/>[knight.cpp]"]
  node_queen["Queen rules<br/>[queen.cpp]"]
  node_king["King rules<br/>[king.cpp]"]
end

node_player(("Player"))
node_sfml["SFML"]

node_player -->|"plays through"| node_app
node_app -->|"controls"| node_board
node_board -->|"creates pieces"| node_pawn
node_board -->|"creates pieces"| node_rook
node_board -->|"creates pieces"| node_bishop
node_board -->|"creates pieces"| node_knight
node_board -->|"creates pieces"| node_queen
node_board -->|"creates pieces"| node_king
node_pawn -->|"reads board"| node_board
node_rook -->|"reads board"| node_board
node_app -->|"renders interface"| node_sfml
node_board -->|"renders board"| node_sfml
node_pawn -->|"inherits"| node_piecebase
node_rook -->|"inherits"| node_piecebase
node_bishop -->|"inherits"| node_piecebase
node_knight -->|"inherits"| node_piecebase
node_queen -->|"inherits"| node_piecebase
node_king -->|"inherits"| node_piecebase
node_board -.->|"requests moves"| node_bishop
node_board -.->|"requests moves"| node_knight
node_board -.->|"requests moves"| node_queen
node_board -.->|"requests moves"| node_king

click node_app "https://github.com/deepakvalmani/chess-main/blob/master/include/src/main.cpp"
click node_board "https://github.com/deepakvalmani/chess-main/blob/master/include/src/board.cpp"
click node_piecebase "https://github.com/deepakvalmani/chess-main/blob/master/include/piece.h"
click node_pawn "https://github.com/deepakvalmani/chess-main/blob/master/include/src/pawn.cpp"
click node_rook "https://github.com/deepakvalmani/chess-main/blob/master/include/src/rook.cpp"
click node_bishop "https://github.com/deepakvalmani/chess-main/blob/master/include/src/bishop.cpp"
click node_knight "https://github.com/deepakvalmani/chess-main/blob/master/include/src/knight.cpp"
click node_queen "https://github.com/deepakvalmani/chess-main/blob/master/include/src/queen.cpp"
click node_king "https://github.com/deepakvalmani/chess-main/blob/master/include/src/king.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_app toneBlue
class node_board toneAmber
class node_piecebase,node_pawn,node_rook,node_bishop,node_knight,node_queen,node_king toneMint
class node_player,node_sfml toneIndigo
```

## Components

### Game interface

- [Game loop and UI](https://github.com/deepakvalmani/chess-main/blob/master/include/src/main.cpp): `include/src/main.cpp`

### Board and rules

- [Board and game rules](https://github.com/deepakvalmani/chess-main/blob/master/include/src/board.cpp): `include/src/board.cpp`

### Piece movement

- [Piece base](https://github.com/deepakvalmani/chess-main/blob/master/include/piece.h): `include/piece.h`
- [Pawn rules](https://github.com/deepakvalmani/chess-main/blob/master/include/src/pawn.cpp): `include/src/pawn.cpp`
- [Rook rules](https://github.com/deepakvalmani/chess-main/blob/master/include/src/rook.cpp): `include/src/rook.cpp`
- [Bishop rules](https://github.com/deepakvalmani/chess-main/blob/master/include/src/bishop.cpp): `include/src/bishop.cpp`
- [Knight rules](https://github.com/deepakvalmani/chess-main/blob/master/include/src/knight.cpp): `include/src/knight.cpp`
- [Queen rules](https://github.com/deepakvalmani/chess-main/blob/master/include/src/queen.cpp): `include/src/queen.cpp`
- [King rules](https://github.com/deepakvalmani/chess-main/blob/master/include/src/king.cpp): `include/src/king.cpp`

### Other components

- **Player**
- **SFML**

## Connections

- Player → Game loop and UI: plays through (evidence: `README.md`)
- Game loop and UI → Board and game rules: controls (evidence: `include/src/main.cpp`)
- Board and game rules → Pawn rules: creates pieces (evidence: `include/src/board.cpp`)
- Board and game rules → Rook rules: creates pieces (evidence: `include/src/board.cpp`)
- Board and game rules → Bishop rules: creates pieces (evidence: `include/src/board.cpp`)
- Board and game rules → Knight rules: creates pieces (evidence: `include/src/board.cpp`)
- Board and game rules → Queen rules: creates pieces (evidence: `include/src/board.cpp`)
- Board and game rules → King rules: creates pieces (evidence: `include/src/board.cpp`)
- Pawn rules → Board and game rules: reads board (evidence: `include/src/pawn.cpp`)
- Rook rules → Board and game rules: reads board (evidence: `include/src/rook.cpp`)
- Game loop and UI → SFML: renders interface (evidence: `README.md`)
- Board and game rules → SFML: renders board (evidence: `README.md`)
- Pawn rules → Piece base: inherits (evidence: `README.md`)
- Rook rules → Piece base: inherits (evidence: `README.md`)
- Bishop rules → Piece base: inherits (evidence: `README.md`)
- Knight rules → Piece base: inherits (evidence: `README.md`)
- Queen rules → Piece base: inherits (evidence: `README.md`)
- King rules → Piece base: inherits (evidence: `README.md`)
- Board and game rules → Bishop rules: requests moves
- Board and game rules → Knight rules: requests moves
- Board and game rules → Queen rules: requests moves
- Board and game rules → King rules: requests moves
