# xgepic/chessdatabase architecture

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

- Interactive diagram: https://gitdiagram.com/xgepic/chessdatabase
- Repository: https://github.com/xgepic/chessdatabase

## Overview

Chess Database is a local, single-player chess-game collection: the desktop shell hosts an ASP.NET Core backend and Angular UI, with the collection stored in SQLite. The main workflow is entering games on a board or importing PGN, storing and browsing games, then replaying, annotating and analysing them with Stockfish. Distinct branches support research, player statistics and training. The README documents several capabilities whose implementation excerpts were not sampled; those are represented at their supported directory paths. Source-level links are included only where the excerpts or index support them.

Main entry points: [`src/ChessDatabase.Api/Collection/CollectionDbContext.cs`](https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Collection/CollectionDbContext.cs) (SQLite Collection), [`src/ChessDatabase.Api/Analysis/GameAnalyzer.cs`](https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Analysis/GameAnalyzer.cs) (Game Assessment), [`ui/src/app/api/api.ts`](https://github.com/xgepic/chessdatabase/blob/main/ui/src/app/api/api.ts) (HTTP API Client), [`src/ChessDatabase.Api/Research/ResearchEndpoints.cs`](https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Research/ResearchEndpoints.cs) (Position Research)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Collection and Games"]
  node_store[("SQLite Collection")]
  node_games["Game Management<br/>[GameEndpoints.cs]"]
  node_movetree["Move Tree<br/>[MoveTree.cs]"]
  node_pgn["PGN Import Export<br/>[PgnImporter.cs]"]
  node_backup["Collection Backups"]
end

subgraph group_analysis["Analysis and Rules"]
  node_rules["Chess Rules<br/>[Position.cs]"]
  node_assessment["Game Assessment<br/>[GameAnalyzer.cs]"]
  node_queue["Analysis Queue"]
  node_enginehost["Engine Host<br/>[EngineHost.cs]"]
  node_uci["UCI Engine<br/>[UciEngine.cs]"]
  node_stockfish["Stockfish"]
end

subgraph group_research["Research and Training"]
  node_openings["Opening Classification"]
  node_research["Position Research"]
  node_lichess["Lichess Services<br/>[LichessFetch.cs]"]
  node_tablebase["Tablebase Lookup<br/>[TablebaseClient.cs]"]
  node_training["Repertoire and Training<br/>[Training]"]
end

subgraph group_people["Players and Statistics"]
  node_players["Players and Statistics<br/>[PlayerEndpoints.cs]"]
end

subgraph group_client["Desktop and UI"]
  node_desktop["Desktop Host<br/>[Program.cs]"]
  node_app["Backend App"]
  node_ui["Angular UI<br/>[app.routes.ts]"]
  node_api["HTTP API Client<br/>[api.ts]"]
  node_gameui["Game Review UI<br/>[game-review.ts]"]
end

node_owner(("Owner"))

node_owner -->|"opens app"| node_desktop
node_desktop -->|"hosts"| node_app
node_app -->|"serves UI"| node_ui
node_owner -->|"uses"| node_ui
node_ui -->|"requests data"| node_api
node_api -.->|"calls endpoints"| node_games
node_api -.->|"imports PGN"| node_pgn
node_gameui -->|"loads and edits"| node_api
node_games -.->|"reads and writes"| node_store
node_pgn -->|"stores games"| node_store
node_pgn -->|"parses moves"| node_rules
node_games -.->|"uses move tree"| node_movetree
node_gameui -.->|"replays variations"| node_movetree
node_assessment -->|"starts engine"| node_enginehost
node_assessment -->|"saves assessment"| node_store
node_assessment -->|"builds positions"| node_rules
node_queue -->|"runs analyses"| node_assessment
node_enginehost -->|"starts and configures"| node_uci
node_uci -->|"speaks UCI"| node_stockfish
node_gameui -.->|"requests and displays"| node_assessment
node_research -.->|"fetches masters"| node_lichess
node_research -.->|"looks up positions"| node_tablebase
node_research -.->|"queries collection"| node_store
node_training -.->|"uses games"| node_store
node_players -.->|"queries players"| node_store
node_backup -.->|"backs up collection"| node_store
node_openings -.->|"classifies game lines"| node_store

click node_desktop "https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Desktop/Program.cs"
click node_app "https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/ChessDatabaseApp.cs"
click node_ui "https://github.com/xgepic/chessdatabase/blob/main/ui/src/app/app.routes.ts"
click node_api "https://github.com/xgepic/chessdatabase/blob/main/ui/src/app/api/api.ts"
click node_gameui "https://github.com/xgepic/chessdatabase/blob/main/ui/src/app/review/game-review.ts"
click node_rules "https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Rules/Position.cs"
click node_store "https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Collection/CollectionDbContext.cs"
click node_games "https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Games/GameEndpoints.cs"
click node_movetree "https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Games/MoveTree.cs"
click node_pgn "https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Import/PgnImporter.cs"
click node_assessment "https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Analysis/GameAnalyzer.cs"
click node_queue "https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Analysis/GameAnalysisQueue.cs"
click node_enginehost "https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Engines/EngineHost.cs"
click node_uci "https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Engines/UciEngine.cs"
click node_openings "https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Openings/OpeningClassifier.cs"
click node_research "https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Research/ResearchEndpoints.cs"
click node_lichess "https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Research/LichessFetch.cs"
click node_tablebase "https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Research/TablebaseClient.cs"
click node_training "https://github.com/xgepic/chessdatabase/tree/main/src/ChessDatabase.Api/Training"
click node_players "https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Players/PlayerEndpoints.cs"
click node_backup "https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Backup/CollectionBackup.cs"

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_store,node_games,node_movetree,node_pgn,node_backup toneBlue
class node_rules,node_assessment,node_queue,node_enginehost,node_uci,node_stockfish toneAmber
class node_openings,node_research,node_lichess,node_tablebase,node_training toneMint
class node_players toneRose
class node_desktop,node_app,node_ui,node_api,node_gameui,node_owner toneIndigo
```

## Components

### Collection and Games

- [SQLite Collection](https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Collection/CollectionDbContext.cs): `src/ChessDatabase.Api/Collection/CollectionDbContext.cs`
- [Game Management](https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Games/GameEndpoints.cs): `src/ChessDatabase.Api/Games/GameEndpoints.cs`
- [Move Tree](https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Games/MoveTree.cs): `src/ChessDatabase.Api/Games/MoveTree.cs`
- [PGN Import Export](https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Import/PgnImporter.cs): `src/ChessDatabase.Api/Import/PgnImporter.cs`
- [Collection Backups](https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Backup/CollectionBackup.cs): `src/ChessDatabase.Api/Backup/CollectionBackup.cs`

### Analysis and Rules

- [Chess Rules](https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Rules/Position.cs): `src/ChessDatabase.Rules/Position.cs`
- [Game Assessment](https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Analysis/GameAnalyzer.cs): `src/ChessDatabase.Api/Analysis/GameAnalyzer.cs`
- [Analysis Queue](https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Analysis/GameAnalysisQueue.cs): `src/ChessDatabase.Api/Analysis/GameAnalysisQueue.cs`
- [Engine Host](https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Engines/EngineHost.cs): `src/ChessDatabase.Api/Engines/EngineHost.cs`
- [UCI Engine](https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Engines/UciEngine.cs): `src/ChessDatabase.Api/Engines/UciEngine.cs`
- **Stockfish**

### Research and Training

- [Opening Classification](https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Openings/OpeningClassifier.cs): `src/ChessDatabase.Api/Openings/OpeningClassifier.cs`
- [Position Research](https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Research/ResearchEndpoints.cs): `src/ChessDatabase.Api/Research/ResearchEndpoints.cs`
- [Lichess Services](https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Research/LichessFetch.cs): `src/ChessDatabase.Api/Research/LichessFetch.cs`
- [Tablebase Lookup](https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Research/TablebaseClient.cs): `src/ChessDatabase.Api/Research/TablebaseClient.cs`
- [Repertoire and Training](https://github.com/xgepic/chessdatabase/tree/main/src/ChessDatabase.Api/Training): `src/ChessDatabase.Api/Training`

### Players and Statistics

- [Players and Statistics](https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/Players/PlayerEndpoints.cs): `src/ChessDatabase.Api/Players/PlayerEndpoints.cs`

### Desktop and UI

- [Desktop Host](https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Desktop/Program.cs): `src/ChessDatabase.Desktop/Program.cs`
- [Backend App](https://github.com/xgepic/chessdatabase/blob/main/src/ChessDatabase.Api/ChessDatabaseApp.cs): `src/ChessDatabase.Api/ChessDatabaseApp.cs`
- [Angular UI](https://github.com/xgepic/chessdatabase/blob/main/ui/src/app/app.routes.ts): `ui/src/app/app.routes.ts`
- [HTTP API Client](https://github.com/xgepic/chessdatabase/blob/main/ui/src/app/api/api.ts): `ui/src/app/api/api.ts`
- [Game Review UI](https://github.com/xgepic/chessdatabase/blob/main/ui/src/app/review/game-review.ts): `ui/src/app/review/game-review.ts`

### Other components

- **Owner**

## Connections

- Owner → Desktop Host: opens app
- Desktop Host → Backend App: hosts (evidence: `src/ChessDatabase.Desktop/Program.cs`)
- Backend App → Angular UI: serves UI (evidence: `src/ChessDatabase.Api/ChessDatabaseApp.cs`)
- Owner → Angular UI: uses
- Angular UI → HTTP API Client: requests data (evidence: `ui/src/app/app.routes.ts`)
- HTTP API Client → Game Management: calls endpoints
- HTTP API Client → PGN Import Export: imports PGN
- Game Review UI → HTTP API Client: loads and edits (evidence: `ui/src/app/review/game-review.ts`)
- Game Management → SQLite Collection: reads and writes
- PGN Import Export → SQLite Collection: stores games (evidence: `src/ChessDatabase.Api/Import/PgnImporter.cs`)
- PGN Import Export → Chess Rules: parses moves (evidence: `src/ChessDatabase.Api/Import/PgnImporter.cs`)
- Game Management → Move Tree: uses move tree
- Game Review UI → Move Tree: replays variations
- Game Assessment → Engine Host: starts engine (evidence: `src/ChessDatabase.Api/Analysis/GameAnalyzer.cs`)
- Game Assessment → SQLite Collection: saves assessment (evidence: `src/ChessDatabase.Api/Analysis/GameAnalyzer.cs`)
- Game Assessment → Chess Rules: builds positions (evidence: `src/ChessDatabase.Api/Analysis/GameAnalyzer.cs`)
- Analysis Queue → Game Assessment: runs analyses (evidence: `src/ChessDatabase.Api/Analysis/GameAnalysisQueue.cs`)
- Engine Host → UCI Engine: starts and configures (evidence: `src/ChessDatabase.Api/Engines/EngineHost.cs`)
- UCI Engine → Stockfish: speaks UCI (evidence: `src/ChessDatabase.Api/Engines/UciEngine.cs`)
- Game Review UI → Game Assessment: requests and displays
- Position Research → Lichess Services: fetches masters
- Position Research → Tablebase Lookup: looks up positions
- Position Research → SQLite Collection: queries collection
- Repertoire and Training → SQLite Collection: uses games (evidence: `src/ChessDatabase.Api/Collection/CollectionDbContext.cs`)
- Players and Statistics → SQLite Collection: queries players
- Collection Backups → SQLite Collection: backs up collection
- Opening Classification → SQLite Collection: classifies game lines
