# danielycouturier/java-chess architecture

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

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

## Overview

This Java desktop chess game takes player clicks through a Swing view into a controller, which selects pieces, checks legal moves, updates the board, and asks the view to show highlights and move animations. The model covers piece-specific movement, simulated-move safety checks, check, checkmate, stalemate, castling, en passant, and pawn promotion. The README documents the entry point and replay loop, while sampled code confirms the main game, controller, board, and panel interactions. Some peripheral wiring is omitted because its source was not sampled.

Main entry points: [`ChessBoard.java`](https://github.com/danielycouturier/java-chess/blob/main/ChessBoard.java) (Board state), [`ChessPiece.java`](https://github.com/danielycouturier/java-chess/blob/main/ChessPiece.java) (Piece base), [`GamePanel.java`](https://github.com/danielycouturier/java-chess/blob/main/GamePanel.java) (Game panel), [`Game.java`](https://github.com/danielycouturier/java-chess/blob/main/Game.java) (Game loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game runtime"]
  node_entry["Entry point<br/>[EntryPoint.java]"]
  node_game["Game loop<br/>[Game.java]"]
end

subgraph group_control["Player control"]
  node_controller["Logic controller"]
end

subgraph group_rules["Chess rules"]
  node_board["Board state<br/>[ChessBoard.java]"]
  node_piece["Piece base<br/>[ChessPiece.java]"]
  node_pawn["Pawn rules<br/>[Pawn.java]"]
  node_king["King rules<br/>[King.java]"]
  node_knight["Knight rules<br/>[Knight.java]"]
  node_bishop["Bishop rules<br/>[Bishop.java]"]
  node_rook["Rook rules<br/>[Rook.java]"]
  node_queen["Queen rules<br/>[Queen.java]"]
end

subgraph group_view["Swing interface"]
  node_frame["Game window<br/>[GameFrame.java]"]
  node_panel["Game panel<br/>[GamePanel.java]"]
  node_mouse["Mouse handler<br/>[MouseHandler.java]"]
end

node_player(("Player"))

node_player -->|"clicks"| node_panel
node_entry -->|"starts loop"| node_game
node_game -->|"dispatches input"| node_controller
node_game -->|"updates and repaints"| node_panel
node_game -->|"creates window"| node_frame
node_panel -->|"reads clicks"| node_mouse
node_panel -->|"renders pieces"| node_board
node_controller -->|"checks and updates"| node_board
node_controller -->|"moves and highlights"| node_panel
node_board -->|"checks moves"| node_piece
node_board -->|"creates pieces"| node_pawn
node_board -->|"creates pieces"| node_king
node_board -->|"creates pieces"| node_knight
node_board -->|"creates pieces"| node_bishop
node_board -->|"creates pieces"| node_rook
node_board -->|"creates pieces"| node_queen
node_pawn -->|"extends"| node_piece
node_king -->|"extends"| node_piece
node_knight -->|"extends"| node_piece
node_bishop -->|"extends"| node_piece
node_rook -->|"extends"| node_piece
node_queen -->|"extends"| node_piece

click node_entry "https://github.com/danielycouturier/java-chess/blob/main/EntryPoint.java"
click node_game "https://github.com/danielycouturier/java-chess/blob/main/Game.java"
click node_frame "https://github.com/danielycouturier/java-chess/blob/main/GameFrame.java"
click node_controller "https://github.com/danielycouturier/java-chess/blob/main/LogicController.java"
click node_board "https://github.com/danielycouturier/java-chess/blob/main/ChessBoard.java"
click node_piece "https://github.com/danielycouturier/java-chess/blob/main/ChessPiece.java"
click node_pawn "https://github.com/danielycouturier/java-chess/blob/main/Pawn.java"
click node_king "https://github.com/danielycouturier/java-chess/blob/main/King.java"
click node_knight "https://github.com/danielycouturier/java-chess/blob/main/Knight.java"
click node_bishop "https://github.com/danielycouturier/java-chess/blob/main/Bishop.java"
click node_rook "https://github.com/danielycouturier/java-chess/blob/main/Rook.java"
click node_queen "https://github.com/danielycouturier/java-chess/blob/main/Queen.java"
click node_panel "https://github.com/danielycouturier/java-chess/blob/main/GamePanel.java"
click node_mouse "https://github.com/danielycouturier/java-chess/blob/main/MouseHandler.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_entry,node_game toneBlue
class node_controller toneAmber
class node_board,node_piece,node_pawn,node_king,node_knight,node_bishop,node_rook,node_queen toneMint
class node_frame,node_panel,node_mouse toneRose
class node_player toneIndigo
```

## Components

### Game runtime

- [Entry point](https://github.com/danielycouturier/java-chess/blob/main/EntryPoint.java): `EntryPoint.java`
- [Game loop](https://github.com/danielycouturier/java-chess/blob/main/Game.java): `Game.java`

### Player control

- [Logic controller](https://github.com/danielycouturier/java-chess/blob/main/LogicController.java): `LogicController.java`

### Chess rules

- [Board state](https://github.com/danielycouturier/java-chess/blob/main/ChessBoard.java): `ChessBoard.java`
- [Piece base](https://github.com/danielycouturier/java-chess/blob/main/ChessPiece.java): `ChessPiece.java`
- [Pawn rules](https://github.com/danielycouturier/java-chess/blob/main/Pawn.java): `Pawn.java`
- [King rules](https://github.com/danielycouturier/java-chess/blob/main/King.java): `King.java`
- [Knight rules](https://github.com/danielycouturier/java-chess/blob/main/Knight.java): `Knight.java`
- [Bishop rules](https://github.com/danielycouturier/java-chess/blob/main/Bishop.java): `Bishop.java`
- [Rook rules](https://github.com/danielycouturier/java-chess/blob/main/Rook.java): `Rook.java`
- [Queen rules](https://github.com/danielycouturier/java-chess/blob/main/Queen.java): `Queen.java`

### Swing interface

- [Game window](https://github.com/danielycouturier/java-chess/blob/main/GameFrame.java): `GameFrame.java`
- [Game panel](https://github.com/danielycouturier/java-chess/blob/main/GamePanel.java): `GamePanel.java`
- [Mouse handler](https://github.com/danielycouturier/java-chess/blob/main/MouseHandler.java): `MouseHandler.java`

### Other components

- **Player**

## Connections

- Player → Game panel: clicks
- Entry point → Game loop: starts loop
- Game loop → Logic controller: dispatches input
- Game loop → Game panel: updates and repaints
- Game loop → Game window: creates window
- Game panel → Mouse handler: reads clicks
- Game panel → Board state: renders pieces
- Logic controller → Board state: checks and updates
- Logic controller → Game panel: moves and highlights
- Board state → Piece base: checks moves
- Board state → Pawn rules: creates pieces
- Board state → King rules: creates pieces
- Board state → Knight rules: creates pieces
- Board state → Bishop rules: creates pieces
- Board state → Rook rules: creates pieces
- Board state → Queen rules: creates pieces
- Pawn rules → Piece base: extends
- King rules → Piece base: extends
- Knight rules → Piece base: extends
- Bishop rules → Piece base: extends
- Rook rules → Piece base: extends
- Queen rules → Piece base: extends
