# moinul924/chess_project architecture

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

- Interactive diagram: https://gitdiagram.com/moinul924/chess_project
- Repository: https://github.com/moinul924/chess_project

## Overview

This is a Spring Boot chess web app with a Java chess engine, human and engine play, matchmaking, and account features. A player interacts with the browser client, which communicates with game and account endpoints; the game controller coordinates sessions, moves, matchmaking, and recorded results. The engine handles legal positions and move selection, including the README-documented opening book, minimax search, and alpha-beta pruning. The README also documents FEN setup, undo, and board flipping. Some browser-to-server wiring and unsampled subsystems are not directly visible in the excerpts.

Main entry points: [`src/main/java/com/chess/GameController.java`](https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/GameController.java) (Game endpoints), [`src/main/java/com/chess/Board.java`](https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/Board.java) (Board state and rules), [`src/main/resources/static/js/gameController.js`](https://github.com/moinul924/chess_project/blob/main/src/main/resources/static/js/gameController.js) (Game UI controller), [`src/main/java/com/chess/account/AccountService.java`](https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/account/AccountService.java) (Account and settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser client"]
  node_webgame["Game UI controller<br/>[gameController.js]"]
  node_render["Board rendering<br/>[boardRender.js]"]
  node_drag["Move input<br/>[drag.js]"]
  node_webapi["Game API client<br/>[api.js]"]
  node_auth["Authentication UI<br/>[auth.js]"]
  node_accountapi["Account API client<br/>[accountApi.js]"]
end

subgraph group_game["Game runtime"]
  node_controller["Game endpoints"]
  node_session["Game session<br/>[GameSession.java]"]
  node_queue["Matchmaking queue"]
end

subgraph group_chess["Chess rules and engine"]
  node_board["Board state and rules<br/>[Board.java]"]
  node_pieces["Piece move rules"]
  node_moves["Move execution<br/>[Move.java]"]
  node_engine["Engine search and evaluation<br/>[Engine.java]"]
  node_fen["FEN setup<br/>[FEN.java]"]
end

subgraph group_accounts["Accounts and records"]
  node_accountcontroller["Account endpoints"]
  node_accountservice["Account and settings"]
  node_recordservice["Game records"]
end

subgraph group_persistence["Persistence"]
  node_accountrepo[("Account storage")]
  node_profilerepo[("Profile storage")]
  node_settingsrepo[("Settings storage")]
  node_recordrepo[("Record storage")]
end

node_player(("Player"))

node_player -.->|"plays through"| node_webgame
node_webgame -->|"renders with"| node_render
node_webgame -->|"uses input"| node_drag
node_webgame -->|"calls"| node_webapi
node_webgame -.->|"sends game requests"| node_controller
node_auth -->|"uses"| node_accountapi
node_accountapi -.->|"sends account requests"| node_accountcontroller
node_controller -->|"uses"| node_session
node_controller -->|"dispatches matchmaking"| node_queue
node_controller -->|"manages moves"| node_board
node_controller -->|"uses accounts"| node_accountservice
node_controller -->|"records results"| node_recordservice
node_session -->|"maintains position"| node_board
node_session -->|"requests engine moves"| node_engine
node_board -->|"requests legal moves"| node_pieces
node_pieces -->|"creates moves"| node_moves
node_moves -->|"updates position"| node_board
node_engine -->|"searches positions"| node_board
node_fen -->|"initializes position"| node_board
node_accountcontroller -->|"delegates account actions"| node_accountservice
node_accountservice -->|"reads and writes"| node_accountrepo
node_accountservice -->|"writes profiles"| node_profilerepo
node_accountservice -->|"reads and writes settings"| node_settingsrepo
node_recordservice -->|"persists records"| node_recordrepo

click node_webgame "https://github.com/moinul924/chess_project/blob/main/src/main/resources/static/js/gameController.js"
click node_render "https://github.com/moinul924/chess_project/blob/main/src/main/resources/static/js/boardRender.js"
click node_drag "https://github.com/moinul924/chess_project/blob/main/src/main/resources/static/js/drag.js"
click node_webapi "https://github.com/moinul924/chess_project/blob/main/src/main/resources/static/js/api.js"
click node_auth "https://github.com/moinul924/chess_project/blob/main/src/main/resources/static/js/auth.js"
click node_accountapi "https://github.com/moinul924/chess_project/blob/main/src/main/resources/static/js/accountApi.js"
click node_controller "https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/GameController.java"
click node_session "https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/GameSession.java"
click node_queue "https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/MatchmakingQueue.java"
click node_board "https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/Board.java"
click node_pieces "https://github.com/moinul924/chess_project/tree/main/src/main/java/com/chess/chessPiece"
click node_moves "https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/chessMove/Move.java"
click node_engine "https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/Engine.java"
click node_fen "https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/FEN.java"
click node_accountcontroller "https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/account/AccountController.java"
click node_accountservice "https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/account/AccountService.java"
click node_recordservice "https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/account/GameRecordService.java"
click node_accountrepo "https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/account/AccountRepository.java"
click node_profilerepo "https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/account/PlayerProfileRepository.java"
click node_settingsrepo "https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/account/UserSettingsRepository.java"
click node_recordrepo "https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/account/GameRecordRepository.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_webgame,node_render,node_drag,node_webapi,node_auth,node_accountapi toneBlue
class node_controller,node_session,node_queue toneAmber
class node_board,node_pieces,node_moves,node_engine,node_fen toneMint
class node_accountcontroller,node_accountservice,node_recordservice toneRose
class node_accountrepo,node_profilerepo,node_settingsrepo,node_recordrepo,node_player toneIndigo
```

## Components

### Browser client

- [Game UI controller](https://github.com/moinul924/chess_project/blob/main/src/main/resources/static/js/gameController.js): `src/main/resources/static/js/gameController.js`
- [Board rendering](https://github.com/moinul924/chess_project/blob/main/src/main/resources/static/js/boardRender.js): `src/main/resources/static/js/boardRender.js`
- [Move input](https://github.com/moinul924/chess_project/blob/main/src/main/resources/static/js/drag.js): `src/main/resources/static/js/drag.js`
- [Game API client](https://github.com/moinul924/chess_project/blob/main/src/main/resources/static/js/api.js): `src/main/resources/static/js/api.js`
- [Authentication UI](https://github.com/moinul924/chess_project/blob/main/src/main/resources/static/js/auth.js): `src/main/resources/static/js/auth.js`
- [Account API client](https://github.com/moinul924/chess_project/blob/main/src/main/resources/static/js/accountApi.js): `src/main/resources/static/js/accountApi.js`

### Game runtime

- [Game endpoints](https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/GameController.java): `src/main/java/com/chess/GameController.java`
- [Game session](https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/GameSession.java): `src/main/java/com/chess/GameSession.java`
- [Matchmaking queue](https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/MatchmakingQueue.java): `src/main/java/com/chess/MatchmakingQueue.java`

### Chess rules and engine

- [Board state and rules](https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/Board.java): `src/main/java/com/chess/Board.java`
- [Piece move rules](https://github.com/moinul924/chess_project/tree/main/src/main/java/com/chess/chessPiece): `src/main/java/com/chess/chessPiece`
- [Move execution](https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/chessMove/Move.java): `src/main/java/com/chess/chessMove/Move.java`
- [Engine search and evaluation](https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/Engine.java): `src/main/java/com/chess/Engine.java`
- [FEN setup](https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/FEN.java): `src/main/java/com/chess/FEN.java`

### Accounts and records

- [Account endpoints](https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/account/AccountController.java): `src/main/java/com/chess/account/AccountController.java`
- [Account and settings](https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/account/AccountService.java): `src/main/java/com/chess/account/AccountService.java`
- [Game records](https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/account/GameRecordService.java): `src/main/java/com/chess/account/GameRecordService.java`

### Persistence

- [Account storage](https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/account/AccountRepository.java): `src/main/java/com/chess/account/AccountRepository.java`
- [Profile storage](https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/account/PlayerProfileRepository.java): `src/main/java/com/chess/account/PlayerProfileRepository.java`
- [Settings storage](https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/account/UserSettingsRepository.java): `src/main/java/com/chess/account/UserSettingsRepository.java`
- [Record storage](https://github.com/moinul924/chess_project/blob/main/src/main/java/com/chess/account/GameRecordRepository.java): `src/main/java/com/chess/account/GameRecordRepository.java`

### Other components

- **Player**

## Connections

- Player → Game UI controller: plays through
- Game UI controller → Board rendering: renders with (evidence: `src/main/resources/static/js/gameController.js`)
- Game UI controller → Move input: uses input (evidence: `src/main/resources/static/js/gameController.js`)
- Game UI controller → Game API client: calls (evidence: `src/main/resources/static/js/gameController.js`)
- Game UI controller → Game endpoints: sends game requests
- Authentication UI → Account API client: uses (evidence: `src/main/resources/static/js/auth.js`)
- Account API client → Account endpoints: sends account requests
- Game endpoints → Game session: uses (evidence: `src/main/java/com/chess/GameController.java`)
- Game endpoints → Matchmaking queue: dispatches matchmaking (evidence: `src/main/java/com/chess/GameController.java`)
- Game endpoints → Board state and rules: manages moves (evidence: `src/main/java/com/chess/GameController.java`)
- Game endpoints → Account and settings: uses accounts (evidence: `src/main/java/com/chess/GameController.java`)
- Game endpoints → Game records: records results (evidence: `src/main/java/com/chess/GameController.java`)
- Game session → Board state and rules: maintains position (evidence: `src/main/java/com/chess/GameSession.java`)
- Game session → Engine search and evaluation: requests engine moves (evidence: `src/main/java/com/chess/GameSession.java`)
- Board state and rules → Piece move rules: requests legal moves (evidence: `src/main/java/com/chess/Board.java`)
- Piece move rules → Move execution: creates moves (evidence: `src/main/java/com/chess/chessPiece/Pawn.java`)
- Move execution → Board state and rules: updates position (evidence: `src/main/java/com/chess/chessMove/Move.java`)
- Engine search and evaluation → Board state and rules: searches positions (evidence: `src/main/java/com/chess/Engine.java`)
- FEN setup → Board state and rules: initializes position (evidence: `src/main/java/com/chess/Board.java`)
- Account endpoints → Account and settings: delegates account actions (evidence: `src/main/java/com/chess/account/AccountController.java`)
- Account and settings → Account storage: reads and writes (evidence: `src/main/java/com/chess/account/AccountService.java`)
- Account and settings → Profile storage: writes profiles (evidence: `src/main/java/com/chess/account/AccountService.java`)
- Account and settings → Settings storage: reads and writes settings (evidence: `src/main/java/com/chess/account/AccountService.java`)
- Game records → Record storage: persists records (evidence: `src/main/java/com/chess/account/GameRecordService.java`)
