# lucas-js/chess-system architecture

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

- Interactive diagram: https://gitdiagram.com/lucas-js/chess-system
- Repository: https://github.com/lucas-js/chess-system

## Overview

This repository is a two-player, console-based chess game. A player enters a source square, sees legal destinations, enters a target, and the match validates and applies the move until checkmate; the UI then displays the result. The match coordinates turn rules, check/checkmate, captures, promotion, castling, and en passant over a board abstraction, while piece classes calculate movement. The README is empty, so capabilities are based on the sampled source; omitted ChessMatch sections limit certainty about some internal call details.

Main entry points: [`chess/ChessMatch.java`](https://github.com/lucas-js/chess-system/blob/master/chess/ChessMatch.java) (Match coordinator), [`application/Program.java`](https://github.com/lucas-js/chess-system/blob/master/application/Program.java) (Game loop), [`chess/ChessPiece.java`](https://github.com/lucas-js/chess-system/blob/master/chess/ChessPiece.java) (Chess piece base), [`boardgame/Board.java`](https://github.com/lucas-js/chess-system/blob/master/boardgame/Board.java) (Board state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["Console interface"]
  node_program["Game loop<br/>[Program.java]"]
  node_ui["Console UI<br/>[UI.java]"]
end

subgraph group_match["Chess rules"]
  node_matchlogic["Match coordinator<br/>[ChessMatch.java]"]
  node_chessposition["Chess coordinates<br/>[ChessPosition.java]"]
  node_color["Player colors<br/>[Color.java]"]
  node_exceptions["Game exceptions"]
end

subgraph group_board["Board and pieces"]
  node_boardstate["Board state<br/>[Board.java]"]
  node_basepiece["Piece abstraction<br/>[Piece.java]"]
  node_position["Grid coordinates<br/>[Position.java]"]
  node_chesspiece["Chess piece base<br/>[ChessPiece.java]"]
  node_movement["Piece movement"]
  node_boarderrors["Board errors"]
end

node_player(("Player"))

node_player -->|"enters moves"| node_program
node_program -->|"reads and displays"| node_ui
node_program -->|"requests moves"| node_matchlogic
node_ui -->|"parses squares"| node_chessposition
node_program -->|"submits moves"| node_matchlogic
node_matchlogic -->|"converts squares"| node_chessposition
node_matchlogic -->|"queries and updates"| node_boardstate
node_matchlogic -->|"checks chess state"| node_chesspiece
node_matchlogic -->|"initializes pieces"| node_movement
node_chesspiece -->|"extends"| node_basepiece
node_basepiece -->|"queries board"| node_boardstate
node_basepiece -->|"uses coordinates"| node_position
node_chesspiece -->|"stores color"| node_color
node_movement -->|"calculates moves from"| node_boardstate
node_movement -->|"specializes"| node_chesspiece
node_boardstate -->|"throws"| node_boarderrors
node_chessposition -->|"maps to grid"| node_position
node_matchlogic -->|"throws rule errors"| node_exceptions

click node_program "https://github.com/lucas-js/chess-system/blob/master/application/Program.java"
click node_ui "https://github.com/lucas-js/chess-system/blob/master/application/UI.java"
click node_matchlogic "https://github.com/lucas-js/chess-system/blob/master/chess/ChessMatch.java"
click node_chessposition "https://github.com/lucas-js/chess-system/blob/master/chess/ChessPosition.java"
click node_color "https://github.com/lucas-js/chess-system/blob/master/chess/Color.java"
click node_boardstate "https://github.com/lucas-js/chess-system/blob/master/boardgame/Board.java"
click node_basepiece "https://github.com/lucas-js/chess-system/blob/master/boardgame/Piece.java"
click node_position "https://github.com/lucas-js/chess-system/blob/master/boardgame/Position.java"
click node_chesspiece "https://github.com/lucas-js/chess-system/blob/master/chess/ChessPiece.java"
click node_movement "https://github.com/lucas-js/chess-system/tree/master/chess/pieces"
click node_exceptions "https://github.com/lucas-js/chess-system/blob/master/chess/ChessException.java"
click node_boarderrors "https://github.com/lucas-js/chess-system/blob/master/boardgame/BoardException.java"

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_program,node_ui toneBlue
class node_matchlogic,node_chessposition,node_color,node_exceptions toneAmber
class node_boardstate,node_basepiece,node_position,node_chesspiece,node_movement,node_boarderrors toneMint
class node_player toneIndigo
```

## Components

### Console interface

- [Game loop](https://github.com/lucas-js/chess-system/blob/master/application/Program.java): `application/Program.java`
- [Console UI](https://github.com/lucas-js/chess-system/blob/master/application/UI.java): `application/UI.java`

### Chess rules

- [Match coordinator](https://github.com/lucas-js/chess-system/blob/master/chess/ChessMatch.java): `chess/ChessMatch.java`
- [Chess coordinates](https://github.com/lucas-js/chess-system/blob/master/chess/ChessPosition.java): `chess/ChessPosition.java`
- [Player colors](https://github.com/lucas-js/chess-system/blob/master/chess/Color.java): `chess/Color.java`
- [Game exceptions](https://github.com/lucas-js/chess-system/blob/master/chess/ChessException.java): `chess/ChessException.java`

### Board and pieces

- [Board state](https://github.com/lucas-js/chess-system/blob/master/boardgame/Board.java): `boardgame/Board.java`
- [Piece abstraction](https://github.com/lucas-js/chess-system/blob/master/boardgame/Piece.java): `boardgame/Piece.java`
- [Grid coordinates](https://github.com/lucas-js/chess-system/blob/master/boardgame/Position.java): `boardgame/Position.java`
- [Chess piece base](https://github.com/lucas-js/chess-system/blob/master/chess/ChessPiece.java): `chess/ChessPiece.java`
- [Piece movement](https://github.com/lucas-js/chess-system/tree/master/chess/pieces): `chess/pieces`
- [Board errors](https://github.com/lucas-js/chess-system/blob/master/boardgame/BoardException.java): `boardgame/BoardException.java`

### Other components

- **Player**

## Connections

- Player → Game loop: enters moves
- Game loop → Console UI: reads and displays
- Game loop → Match coordinator: requests moves
- Console UI → Chess coordinates: parses squares
- Game loop → Match coordinator: submits moves
- Match coordinator → Chess coordinates: converts squares
- Match coordinator → Board state: queries and updates
- Match coordinator → Chess piece base: checks chess state
- Match coordinator → Piece movement: initializes pieces
- Chess piece base → Piece abstraction: extends
- Piece abstraction → Board state: queries board
- Piece abstraction → Grid coordinates: uses coordinates
- Chess piece base → Player colors: stores color
- Piece movement → Board state: calculates moves from
- Piece movement → Chess piece base: specializes
- Board state → Board errors: throws
- Chess coordinates → Grid coordinates: maps to grid
- Match coordinator → Game exceptions: throws rule errors
