# bradhillier/pixel-chess architecture

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

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

## Overview

Pixel-Chess is a chess game organized around an MVC boundary: the frontend handles user interaction and presentation, while a controller mediates access to the chessboard and its rules. The principal flow is user input in the playing state, controller processing, board and piece rule evaluation, then refreshed board state for display. The main executable runs the menu/playing/help/credits state loop. The tree also contains a separate SDL_TEST frontend; its state implementation is distinct from the main game path. Some state implementations and piece-specific rules were not excerpted, so their internal links are omitted.

Main entry points: [`src/chessboard.cpp`](https://github.com/bradhillier/pixel-chess/blob/main/src/chessboard.cpp) (Chessboard state), [`src/sdl_chess_game.cpp`](https://github.com/bradhillier/pixel-chess/blob/main/src/sdl_chess_game.cpp) (Game loop), [`src/playing.cpp`](https://github.com/bradhillier/pixel-chess/blob/main/src/playing.cpp) (Playing view), [`FrontEnd/SDL_TEST/GameState.cpp`](https://github.com/bradhillier/pixel-chess/blob/main/FrontEnd/SDL_TEST/GameState.cpp) (SDL test states)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_application["Game application"]
  node_main["Game entry<br/>[main.cpp]"]
  node_game_loop["Game loop<br/>[sdl_chess_game.cpp]"]
  node_state_base["State lifecycle<br/>[state.cpp]"]
  node_test_main["SDL test entry<br/>[main.cpp]"]
  node_test_machine["Test state machine"]
end

subgraph group_presentation["Presentation states"]
  node_menu["Main menu<br/>[main_menu.cpp]"]
  node_playing["Playing view<br/>[playing.cpp]"]
  node_help["Help view<br/>[help.cpp]"]
  node_credits["Credits view<br/>[credits.cpp]"]
  node_effects["Visual effects<br/>[effects.cpp]"]
  node_test_states["SDL test states<br/>[GameState.cpp]"]
end

subgraph group_gameplay["Chess gameplay"]
  node_controller["Game controller"]
  node_board["Chessboard state<br/>[chessboard.cpp]"]
end

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

node_player(("Player"))

node_main -->|"runs loop"| node_game_loop
node_game_loop -->|"manages states"| node_menu
node_game_loop -->|"manages states"| node_playing
node_game_loop -->|"manages states"| node_help
node_game_loop -->|"manages states"| node_credits
node_playing -->|"handles input"| node_controller
node_controller -->|"processes moves"| node_board
node_board -->|"queries movement"| node_piece_base
node_board -->|"creates pieces"| node_pawn
node_board -->|"creates pieces"| node_rook
node_board -->|"creates pieces"| node_knight
node_board -->|"creates pieces"| node_bishop
node_board -->|"creates pieces"| node_queen
node_board -->|"creates pieces"| node_king
node_player -->|"plays game"| node_playing
node_test_main -->|"updates state"| node_test_states
node_test_states -->|"uses controller"| node_controller
node_test_machine -->|"manages states"| node_test_states

click node_main "https://github.com/bradhillier/pixel-chess/blob/main/src/main.cpp"
click node_game_loop "https://github.com/bradhillier/pixel-chess/blob/main/src/sdl_chess_game.cpp"
click node_state_base "https://github.com/bradhillier/pixel-chess/blob/main/src/state.cpp"
click node_menu "https://github.com/bradhillier/pixel-chess/blob/main/src/main_menu.cpp"
click node_playing "https://github.com/bradhillier/pixel-chess/blob/main/src/playing.cpp"
click node_help "https://github.com/bradhillier/pixel-chess/blob/main/src/help.cpp"
click node_credits "https://github.com/bradhillier/pixel-chess/blob/main/src/credits.cpp"
click node_effects "https://github.com/bradhillier/pixel-chess/blob/main/src/effects.cpp"
click node_controller "https://github.com/bradhillier/pixel-chess/blob/main/src/chess_controller.cpp"
click node_board "https://github.com/bradhillier/pixel-chess/blob/main/src/chessboard.cpp"
click node_piece_base "https://github.com/bradhillier/pixel-chess/blob/main/src/piece.cpp"
click node_pawn "https://github.com/bradhillier/pixel-chess/blob/main/src/pawn.cpp"
click node_rook "https://github.com/bradhillier/pixel-chess/blob/main/src/rook.cpp"
click node_knight "https://github.com/bradhillier/pixel-chess/blob/main/src/knight.cpp"
click node_bishop "https://github.com/bradhillier/pixel-chess/blob/main/src/bishop.cpp"
click node_queen "https://github.com/bradhillier/pixel-chess/blob/main/src/queen.cpp"
click node_king "https://github.com/bradhillier/pixel-chess/blob/main/src/king.cpp"
click node_test_main "https://github.com/bradhillier/pixel-chess/blob/main/FrontEnd/SDL_TEST/main.cpp"
click node_test_states "https://github.com/bradhillier/pixel-chess/blob/main/FrontEnd/SDL_TEST/GameState.cpp"
click node_test_machine "https://github.com/bradhillier/pixel-chess/blob/main/FrontEnd/SDL_TEST/GameStateMachine/GameStateMachine.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_game_loop,node_state_base,node_test_main,node_test_machine toneBlue
class node_menu,node_playing,node_help,node_credits,node_effects,node_test_states toneAmber
class node_controller,node_board toneMint
class node_piece_base,node_pawn,node_rook,node_knight,node_bishop,node_queen,node_king toneRose
class node_player toneIndigo
```

## Components

### Game application

- [Game entry](https://github.com/bradhillier/pixel-chess/blob/main/src/main.cpp): `src/main.cpp`
- [Game loop](https://github.com/bradhillier/pixel-chess/blob/main/src/sdl_chess_game.cpp): `src/sdl_chess_game.cpp`
- [State lifecycle](https://github.com/bradhillier/pixel-chess/blob/main/src/state.cpp): `src/state.cpp`
- [SDL test entry](https://github.com/bradhillier/pixel-chess/blob/main/FrontEnd/SDL_TEST/main.cpp): `FrontEnd/SDL_TEST/main.cpp`
- [Test state machine](https://github.com/bradhillier/pixel-chess/blob/main/FrontEnd/SDL_TEST/GameStateMachine/GameStateMachine.cpp): `FrontEnd/SDL_TEST/GameStateMachine/GameStateMachine.cpp`

### Presentation states

- [Main menu](https://github.com/bradhillier/pixel-chess/blob/main/src/main_menu.cpp): `src/main_menu.cpp`
- [Playing view](https://github.com/bradhillier/pixel-chess/blob/main/src/playing.cpp): `src/playing.cpp`
- [Help view](https://github.com/bradhillier/pixel-chess/blob/main/src/help.cpp): `src/help.cpp`
- [Credits view](https://github.com/bradhillier/pixel-chess/blob/main/src/credits.cpp): `src/credits.cpp`
- [Visual effects](https://github.com/bradhillier/pixel-chess/blob/main/src/effects.cpp): `src/effects.cpp`
- [SDL test states](https://github.com/bradhillier/pixel-chess/blob/main/FrontEnd/SDL_TEST/GameState.cpp): `FrontEnd/SDL_TEST/GameState.cpp`

### Chess gameplay

- [Game controller](https://github.com/bradhillier/pixel-chess/blob/main/src/chess_controller.cpp): `src/chess_controller.cpp`
- [Chessboard state](https://github.com/bradhillier/pixel-chess/blob/main/src/chessboard.cpp): `src/chessboard.cpp`

### Piece rules

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

### Other components

- **Player**

## Connections

- Game entry → Game loop: runs loop (evidence: `src/main.cpp`)
- Game loop → Main menu: manages states (evidence: `src/sdl_chess_game.cpp`)
- Game loop → Playing view: manages states (evidence: `src/sdl_chess_game.cpp`)
- Game loop → Help view: manages states
- Game loop → Credits view: manages states
- Playing view → Game controller: handles input
- Game controller → Chessboard state: processes moves (evidence: `src/chess_controller.cpp`)
- Chessboard state → Piece movement base: queries movement (evidence: `src/chessboard.cpp`)
- Chessboard state → Pawn rules: creates pieces (evidence: `src/chessboard.cpp`)
- Chessboard state → Rook rules: creates pieces (evidence: `src/chessboard.cpp`)
- Chessboard state → Knight rules: creates pieces (evidence: `src/chessboard.cpp`)
- Chessboard state → Bishop rules: creates pieces (evidence: `src/chessboard.cpp`)
- Chessboard state → Queen rules: creates pieces (evidence: `src/chessboard.cpp`)
- Chessboard state → King rules: creates pieces (evidence: `src/chessboard.cpp`)
- Player → Playing view: plays game (evidence: `README.md`)
- SDL test entry → SDL test states: updates state (evidence: `FrontEnd/SDL_TEST/main.cpp`)
- SDL test states → Game controller: uses controller
- Test state machine → SDL test states: manages states
