# amir650/blackwidow-chess architecture

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

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

## Overview

BlackWidow-Chess is a desktop chess game. A player interacts with the Swing table, selects a move, and the chess engine validates it and produces the next board; the table can also request an AI move. Game records can be imported/exported or persisted, and the source tree includes networking classes. The README provides no detail beyond identifying the project as chess, so relationships outside the shown excerpts and source references are omitted or marked unverified.

Main entry points: [`src/com/chess/gui/Table.java`](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/gui/Table.java) (Game table), [`src/com/chess/engine/board/Board.java`](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/board/Board.java) (Board and turns), [`src/com/chess/pgn/PGNUtilities.java`](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/pgn/PGNUtilities.java) (PGN utilities), [`src/com/chess/engine/player/ai/StandardBoardEvaluator.java`](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/player/ai/StandardBoardEvaluator.java) (Board evaluation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Desktop interface"]
  node_table["Game table<br/>[Table.java]"]
  node_boardui["Board display<br/>[Table.java]"]
  node_historyui["History and captures"]
  node_setupui["Game setup<br/>[GameSetup.java]"]
  node_debugui["Debug panel<br/>[DebugPanel.java]"]
end

subgraph group_rules["Chess rules"]
  node_engine["Board and turns<br/>[Board.java]"]
  node_players["Legal move validation<br/>[Player.java]"]
  node_moves["Move execution<br/>[Move.java]"]
  node_transition["Move result"]
  node_pieces["Piece movement<br/>[Piece.java]"]
  node_coordinates["Board coordinates<br/>[BoardUtils.java]"]
  node_alliance["Side rules<br/>[Alliance.java]"]
end

subgraph group_ai["Move intelligence"]
  node_ai["AI search<br/>[BlackWidowAI.java]"]
  node_minimax["Minimax strategy<br/>[MiniMax.java]"]
  node_evaluation["Board evaluation"]
  node_safety["King safety"]
  node_pawnstructure["Pawn structure"]
end

subgraph group_records["Game records"]
  node_pgn["PGN utilities<br/>[PGNUtilities.java]"]
  node_fen["FEN conversion<br/>[FenUtilities.java]"]
  node_game["Game records<br/>[Game.java]"]
  node_persistence["SQL persistence"]
end

subgraph group_network["Network play"]
  node_client["Network client<br/>[Client.java]"]
  node_server["Network server<br/>[Server.java]"]
  node_networkentity["Network entity<br/>[NetworkEntity.java]"]
end

node_player(("Player"))
node_database[("SQL database")]

node_player -->|"plays through"| node_table
node_table -->|"draws board"| node_boardui
node_table -->|"refreshes history"| node_historyui
node_table -->|"refreshes debug"| node_debugui
node_table -->|"reads setup"| node_setupui
node_table -.->|"updates game"| node_engine
node_table -->|"requests move"| node_ai
node_table -->|"uses notation tools"| node_pgn
node_table -->|"queries opening move"| node_persistence
node_engine -->|"builds players"| node_players
node_engine -->|"stores pieces"| node_pieces
node_engine -->|"selects side"| node_alliance
node_engine -->|"uses board rules"| node_coordinates
node_players -->|"executes legal move"| node_moves
node_players -->|"returns move status"| node_transition
node_moves -->|"builds next board"| node_engine
node_pieces -->|"generates moves"| node_moves
node_ai -->|"uses strategy"| node_minimax
node_ai -->|"evaluates positions"| node_evaluation
node_minimax -->|"scores boards"| node_evaluation
node_evaluation -->|"analyzes king safety"| node_safety
node_evaluation -->|"analyzes pawn structure"| node_pawnstructure
node_pgn -->|"uses game records"| node_game
node_pgn -->|"converts positions"| node_fen
node_pgn -->|"uses persistence"| node_persistence
node_persistence -->|"reads and writes"| node_database
node_client -->|"uses entity"| node_networkentity
node_server -->|"uses entity"| node_networkentity
node_networkentity -->|"uses board state"| node_engine
node_networkentity -->|"uses moves"| node_moves

click node_table "https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/gui/Table.java"
click node_boardui "https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/gui/Table.java"
click node_historyui "https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/gui/GameHistoryPanel.java"
click node_setupui "https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/gui/GameSetup.java"
click node_debugui "https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/gui/DebugPanel.java"
click node_engine "https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/board/Board.java"
click node_players "https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/player/Player.java"
click node_moves "https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/board/Move.java"
click node_transition "https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/board/MoveTransition.java"
click node_pieces "https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/pieces/Piece.java"
click node_coordinates "https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/board/BoardUtils.java"
click node_alliance "https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/Alliance.java"
click node_ai "https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/player/ai/BlackWidowAI.java"
click node_minimax "https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/player/ai/MiniMax.java"
click node_evaluation "https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/player/ai/StandardBoardEvaluator.java"
click node_safety "https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/player/ai/KingSafetyAnalyzer.java"
click node_pawnstructure "https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/player/ai/PawnStructureAnalyzer.java"
click node_pgn "https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/pgn/PGNUtilities.java"
click node_fen "https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/pgn/FenUtilities.java"
click node_game "https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/pgn/Game.java"
click node_persistence "https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/pgn/MySqlGamePersistence.java"
click node_client "https://github.com/amir650/blackwidow-chess/blob/master/src/network/Client.java"
click node_server "https://github.com/amir650/blackwidow-chess/blob/master/src/network/Server.java"
click node_networkentity "https://github.com/amir650/blackwidow-chess/blob/master/src/network/NetworkEntity.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_table,node_boardui,node_historyui,node_setupui,node_debugui toneBlue
class node_engine,node_players,node_moves,node_transition,node_pieces,node_coordinates,node_alliance,node_database toneAmber
class node_ai,node_minimax,node_evaluation,node_safety,node_pawnstructure toneMint
class node_pgn,node_fen,node_game,node_persistence toneRose
class node_client,node_server,node_networkentity,node_player toneIndigo
```

## Components

### Desktop interface

- [Game table](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/gui/Table.java): `src/com/chess/gui/Table.java`
- [Board display](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/gui/Table.java): `src/com/chess/gui/Table.java`
- [History and captures](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/gui/GameHistoryPanel.java): `src/com/chess/gui/GameHistoryPanel.java`
- [Game setup](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/gui/GameSetup.java): `src/com/chess/gui/GameSetup.java`
- [Debug panel](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/gui/DebugPanel.java): `src/com/chess/gui/DebugPanel.java`

### Chess rules

- [Board and turns](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/board/Board.java): `src/com/chess/engine/board/Board.java`
- [Legal move validation](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/player/Player.java): `src/com/chess/engine/player/Player.java`
- [Move execution](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/board/Move.java): `src/com/chess/engine/board/Move.java`
- [Move result](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/board/MoveTransition.java): `src/com/chess/engine/board/MoveTransition.java`
- [Piece movement](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/pieces/Piece.java): `src/com/chess/engine/pieces/Piece.java`
- [Board coordinates](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/board/BoardUtils.java): `src/com/chess/engine/board/BoardUtils.java`
- [Side rules](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/Alliance.java): `src/com/chess/engine/Alliance.java`

### Move intelligence

- [AI search](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/player/ai/BlackWidowAI.java): `src/com/chess/engine/player/ai/BlackWidowAI.java`
- [Minimax strategy](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/player/ai/MiniMax.java): `src/com/chess/engine/player/ai/MiniMax.java`
- [Board evaluation](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/player/ai/StandardBoardEvaluator.java): `src/com/chess/engine/player/ai/StandardBoardEvaluator.java`
- [King safety](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/player/ai/KingSafetyAnalyzer.java): `src/com/chess/engine/player/ai/KingSafetyAnalyzer.java`
- [Pawn structure](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/engine/player/ai/PawnStructureAnalyzer.java): `src/com/chess/engine/player/ai/PawnStructureAnalyzer.java`

### Game records

- [PGN utilities](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/pgn/PGNUtilities.java): `src/com/chess/pgn/PGNUtilities.java`
- [FEN conversion](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/pgn/FenUtilities.java): `src/com/chess/pgn/FenUtilities.java`
- [Game records](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/pgn/Game.java): `src/com/chess/pgn/Game.java`
- [SQL persistence](https://github.com/amir650/blackwidow-chess/blob/master/src/com/chess/pgn/MySqlGamePersistence.java): `src/com/chess/pgn/MySqlGamePersistence.java`

### Network play

- [Network client](https://github.com/amir650/blackwidow-chess/blob/master/src/network/Client.java): `src/network/Client.java`
- [Network server](https://github.com/amir650/blackwidow-chess/blob/master/src/network/Server.java): `src/network/Server.java`
- [Network entity](https://github.com/amir650/blackwidow-chess/blob/master/src/network/NetworkEntity.java): `src/network/NetworkEntity.java`

### Other components

- **Player**
- **SQL database**

## Connections

- Player → Game table: plays through
- Game table → Board display: draws board (evidence: `src/com/chess/gui/Table.java`)
- Game table → History and captures: refreshes history (evidence: `src/com/chess/gui/Table.java`)
- Game table → Debug panel: refreshes debug (evidence: `src/com/chess/gui/Table.java`)
- Game table → Game setup: reads setup (evidence: `src/com/chess/gui/Table.java`)
- Game table → Board and turns: updates game (evidence: `src/com/chess/gui/Table.java`)
- Game table → AI search: requests move (evidence: `src/com/chess/gui/Table.java`)
- Game table → PGN utilities: uses notation tools (evidence: `src/com/chess/gui/Table.java`)
- Game table → SQL persistence: queries opening move (evidence: `src/com/chess/gui/Table.java`)
- Board and turns → Legal move validation: builds players (evidence: `src/com/chess/engine/board/Board.java`)
- Board and turns → Piece movement: stores pieces (evidence: `src/com/chess/engine/board/Board.java`)
- Board and turns → Side rules: selects side (evidence: `src/com/chess/engine/board/Board.java`)
- Board and turns → Board coordinates: uses board rules (evidence: `src/com/chess/engine/board/Board.java`)
- Legal move validation → Move execution: executes legal move (evidence: `src/com/chess/engine/player/Player.java`)
- Legal move validation → Move result: returns move status (evidence: `src/com/chess/engine/player/Player.java`)
- Move execution → Board and turns: builds next board (evidence: `src/com/chess/engine/board/Move.java`)
- Piece movement → Move execution: generates moves (evidence: `src/com/chess/engine/pieces/Piece.java`)
- AI search → Minimax strategy: uses strategy (evidence: `src/com/chess/engine/player/ai/BlackWidowAI.java`)
- AI search → Board evaluation: evaluates positions (evidence: `src/com/chess/engine/player/ai/BlackWidowAI.java`)
- Minimax strategy → Board evaluation: scores boards (evidence: `src/com/chess/engine/player/ai/MiniMax.java`)
- Board evaluation → King safety: analyzes king safety (evidence: `src/com/chess/engine/player/ai/StandardBoardEvaluator.java`)
- Board evaluation → Pawn structure: analyzes pawn structure (evidence: `src/com/chess/engine/player/ai/StandardBoardEvaluator.java`)
- PGN utilities → Game records: uses game records (evidence: `src/com/chess/pgn/PGNUtilities.java`)
- PGN utilities → FEN conversion: converts positions (evidence: `src/com/chess/pgn/PGNUtilities.java`)
- PGN utilities → SQL persistence: uses persistence (evidence: `src/com/chess/pgn/PGNUtilities.java`)
- SQL persistence → SQL database: reads and writes (evidence: `src/com/chess/pgn/MySqlGamePersistence.java`)
- Network client → Network entity: uses entity (evidence: `src/network/Client.java`)
- Network server → Network entity: uses entity (evidence: `src/network/Server.java`)
- Network entity → Board and turns: uses board state (evidence: `src/network/NetworkEntity.java`)
- Network entity → Move execution: uses moves (evidence: `src/network/NetworkEntity.java`)
