# 45ngc/angular-chess architecture

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

- Interactive diagram: https://gitdiagram.com/45ngc/angular-chess
- Repository: https://github.com/45ngc/angular-chess

## Overview

Angular Chess is a browser chess application with local, Stockfish-powered AI, and online play. The user configures a game on the home screen, enters the game view, and plays through a mode-specific service backed by shared chess rules; online moves and room state are mediated by a Spring Boot backend. The graph preserves documented rules, clock, history, sound, and board UX capabilities. Some UI and service internals were not excerpted, so those relationships are included only where the README or source index supports them.

Main entry points: [`src/app/core/rules/game-state.ts`](https://github.com/45ngc/angular-chess/blob/main/src/app/core/rules/game-state.ts) (Game state), [`src/app/ui/game/game.component.ts`](https://github.com/45ngc/angular-chess/blob/main/src/app/ui/game/game.component.ts) (Game view), [`src/app/services/local-game.service.ts`](https://github.com/45ngc/angular-chess/blob/main/src/app/services/local-game.service.ts) (Local game), [`src/app/services/ai-game.service.ts`](https://github.com/45ngc/angular-chess/blob/main/src/app/services/ai-game.service.ts) (AI game)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and setup"]
  node_home["Home setup<br/>[home.component.ts]"]
  node_localsettings["Local settings"]
  node_aisettings["AI settings"]
  node_onlinesettings["Online settings"]
  node_lobby["Room lobby"]
end

subgraph group_gameplay["Game orchestration"]
  node_localgame["Local game"]
  node_aigame["AI game<br/>[ai-game.service.ts]"]
  node_onlinegame["Online game"]
  node_gamebase["Gameplay base<br/>[gameplay-base.ts]"]
  node_navigation["Move navigation<br/>[move-navigation.ts]"]
  node_clock["Local clock<br/>[local-clock.ts]"]
  node_stockfishservice["Stockfish service"]
end

subgraph group_rules["Chess engine"]
  node_board["Board model<br/>[board.ts]"]
  node_fen["FEN notation<br/>[fen.ts]"]
  node_legalmoves["Legal moves"]
  node_attacks["Attack detection"]
  node_gamestate["Game state<br/>[game-state.ts]"]
  node_simulation["Move simulation<br/>[move-simulator.ts]"]
  node_drawrules["Draw rules<br/>[draw-rules.ts]"]
  node_history["Move history<br/>[move-history.ts]"]
end

subgraph group_experience["Gameplay experience"]
  node_gameview["Game view<br/>[game.component.ts]"]
  node_sound["Sound feedback<br/>[sound.service.ts]"]
  node_controls["Game controls"]
  node_clockui["Clock display<br/>[clock.component.ts]"]
end

subgraph group_online["Online integration"]
  node_roomservice["Room transport"]
end

node_player(("Player"))
node_stockfish{{"Stockfish worker"}}
node_backend{{"Chess backend"}}

node_player -->|"configures"| node_home
node_home -->|"opens"| node_localsettings
node_home -->|"opens"| node_aisettings
node_home -->|"opens"| node_onlinesettings
node_home -->|"opens"| node_lobby
node_player -->|"plays"| node_gameview
node_gameview -->|"uses"| node_localgame
node_gameview -->|"uses"| node_aigame
node_gameview -.->|"uses"| node_onlinegame
node_localgame -->|"extends"| node_gamebase
node_aigame -->|"extends"| node_gamebase
node_onlinegame -->|"subscribes"| node_roomservice
node_onlinegame -->|"rebuilds from"| node_history
node_localgame -->|"updates"| node_clock
node_localgame -->|"inherits"| node_navigation
node_aigame -->|"uses"| node_navigation
node_aigame -->|"requests moves"| node_stockfishservice
node_stockfishservice -->|"queries"| node_stockfish
node_localgame -->|"updates"| node_gamestate
node_aigame -->|"updates"| node_gamestate
node_gamestate -->|"simulates"| node_simulation
node_gamestate -->|"checks moves"| node_legalmoves
node_gamestate -->|"checks draws"| node_drawrules
node_gamestate -->|"checks check"| node_attacks
node_legalmoves -->|"checks safety"| node_attacks
node_legalmoves -->|"tests moves"| node_simulation
node_gamestate -->|"holds"| node_board
node_gamestate -->|"keys positions"| node_fen
node_gameview -->|"renders"| node_controls
node_gameview -->|"renders"| node_clockui
node_gameview -->|"uses"| node_sound
node_localgame -->|"plays cues"| node_sound
node_aigame -->|"plays cues"| node_sound
node_onlinegame -->|"plays cues"| node_sound
node_lobby -->|"manages rooms"| node_roomservice
node_roomservice -->|"REST and STOMP"| node_backend
node_roomservice -->|"synchronizes snapshots"| node_backend

click node_home "https://github.com/45ngc/angular-chess/blob/main/src/app/ui/home/home.component.ts"
click node_localsettings "https://github.com/45ngc/angular-chess/blob/main/src/app/ui/home/local-game-settings-dialog/local-game-settings-dialog.component.ts"
click node_aisettings "https://github.com/45ngc/angular-chess/blob/main/src/app/ui/home/ai-mode-settings-dialog/ai-mode-settings-dialog.component.ts"
click node_onlinesettings "https://github.com/45ngc/angular-chess/blob/main/src/app/ui/home/online-game-settings-dialog/online-game-settings-dialog.component.ts"
click node_lobby "https://github.com/45ngc/angular-chess/blob/main/src/app/ui/home/online-lobby-dialog/online-lobby-dialog.component.ts"
click node_gameview "https://github.com/45ngc/angular-chess/blob/main/src/app/ui/game/game.component.ts"
click node_localgame "https://github.com/45ngc/angular-chess/blob/main/src/app/services/local-game.service.ts"
click node_aigame "https://github.com/45ngc/angular-chess/blob/main/src/app/services/ai-game.service.ts"
click node_onlinegame "https://github.com/45ngc/angular-chess/blob/main/src/app/services/online-game.service.ts"
click node_gamebase "https://github.com/45ngc/angular-chess/blob/main/src/app/services/shared/gameplay-base.ts"
click node_navigation "https://github.com/45ngc/angular-chess/blob/main/src/app/services/shared/move-navigation.ts"
click node_board "https://github.com/45ngc/angular-chess/blob/main/src/app/core/board/board.ts"
click node_fen "https://github.com/45ngc/angular-chess/blob/main/src/app/core/board/fen.ts"
click node_legalmoves "https://github.com/45ngc/angular-chess/blob/main/src/app/core/rules/legal-move-finder.ts"
click node_attacks "https://github.com/45ngc/angular-chess/blob/main/src/app/core/rules/attacked-squares.ts"
click node_gamestate "https://github.com/45ngc/angular-chess/blob/main/src/app/core/rules/game-state.ts"
click node_simulation "https://github.com/45ngc/angular-chess/blob/main/src/app/core/rules/move-simulator.ts"
click node_drawrules "https://github.com/45ngc/angular-chess/blob/main/src/app/core/rules/draw-rules.ts"
click node_history "https://github.com/45ngc/angular-chess/blob/main/src/app/core/rules/move-history.ts"
click node_clock "https://github.com/45ngc/angular-chess/blob/main/src/app/core/time/local-clock.ts"
click node_stockfishservice "https://github.com/45ngc/angular-chess/blob/main/src/app/services/stockfish.service.ts"
click node_sound "https://github.com/45ngc/angular-chess/blob/main/src/app/services/sound.service.ts"
click node_controls "https://github.com/45ngc/angular-chess/blob/main/src/app/ui/game/pause-overlay/pause-overlay.component.ts"
click node_clockui "https://github.com/45ngc/angular-chess/blob/main/src/app/ui/game/clock/clock.component.ts"
click node_roomservice "https://github.com/45ngc/angular-chess/blob/main/src/app/services/online-room.service.ts"

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_home,node_localsettings,node_aisettings,node_onlinesettings,node_lobby toneBlue
class node_localgame,node_aigame,node_onlinegame,node_gamebase,node_navigation,node_clock,node_stockfishservice toneAmber
class node_board,node_fen,node_legalmoves,node_attacks,node_gamestate,node_simulation,node_drawrules,node_history toneMint
class node_gameview,node_sound,node_controls,node_clockui,node_stockfish toneRose
class node_roomservice,node_player,node_backend toneIndigo
```

## Components

### Entry and setup

- [Home setup](https://github.com/45ngc/angular-chess/blob/main/src/app/ui/home/home.component.ts): `src/app/ui/home/home.component.ts`
- [Local settings](https://github.com/45ngc/angular-chess/blob/main/src/app/ui/home/local-game-settings-dialog/local-game-settings-dialog.component.ts): `src/app/ui/home/local-game-settings-dialog/local-game-settings-dialog.component.ts`
- [AI settings](https://github.com/45ngc/angular-chess/blob/main/src/app/ui/home/ai-mode-settings-dialog/ai-mode-settings-dialog.component.ts): `src/app/ui/home/ai-mode-settings-dialog/ai-mode-settings-dialog.component.ts`
- [Online settings](https://github.com/45ngc/angular-chess/blob/main/src/app/ui/home/online-game-settings-dialog/online-game-settings-dialog.component.ts): `src/app/ui/home/online-game-settings-dialog/online-game-settings-dialog.component.ts`
- [Room lobby](https://github.com/45ngc/angular-chess/blob/main/src/app/ui/home/online-lobby-dialog/online-lobby-dialog.component.ts): `src/app/ui/home/online-lobby-dialog/online-lobby-dialog.component.ts`

### Game orchestration

- [Local game](https://github.com/45ngc/angular-chess/blob/main/src/app/services/local-game.service.ts): `src/app/services/local-game.service.ts`
- [AI game](https://github.com/45ngc/angular-chess/blob/main/src/app/services/ai-game.service.ts): `src/app/services/ai-game.service.ts`
- [Online game](https://github.com/45ngc/angular-chess/blob/main/src/app/services/online-game.service.ts): `src/app/services/online-game.service.ts`
- [Gameplay base](https://github.com/45ngc/angular-chess/blob/main/src/app/services/shared/gameplay-base.ts): `src/app/services/shared/gameplay-base.ts`
- [Move navigation](https://github.com/45ngc/angular-chess/blob/main/src/app/services/shared/move-navigation.ts): `src/app/services/shared/move-navigation.ts`
- [Local clock](https://github.com/45ngc/angular-chess/blob/main/src/app/core/time/local-clock.ts): `src/app/core/time/local-clock.ts`
- [Stockfish service](https://github.com/45ngc/angular-chess/blob/main/src/app/services/stockfish.service.ts): `src/app/services/stockfish.service.ts`

### Chess engine

- [Board model](https://github.com/45ngc/angular-chess/blob/main/src/app/core/board/board.ts): `src/app/core/board/board.ts`
- [FEN notation](https://github.com/45ngc/angular-chess/blob/main/src/app/core/board/fen.ts): `src/app/core/board/fen.ts`
- [Legal moves](https://github.com/45ngc/angular-chess/blob/main/src/app/core/rules/legal-move-finder.ts): `src/app/core/rules/legal-move-finder.ts`
- [Attack detection](https://github.com/45ngc/angular-chess/blob/main/src/app/core/rules/attacked-squares.ts): `src/app/core/rules/attacked-squares.ts`
- [Game state](https://github.com/45ngc/angular-chess/blob/main/src/app/core/rules/game-state.ts): `src/app/core/rules/game-state.ts`
- [Move simulation](https://github.com/45ngc/angular-chess/blob/main/src/app/core/rules/move-simulator.ts): `src/app/core/rules/move-simulator.ts`
- [Draw rules](https://github.com/45ngc/angular-chess/blob/main/src/app/core/rules/draw-rules.ts): `src/app/core/rules/draw-rules.ts`
- [Move history](https://github.com/45ngc/angular-chess/blob/main/src/app/core/rules/move-history.ts): `src/app/core/rules/move-history.ts`

### Gameplay experience

- [Game view](https://github.com/45ngc/angular-chess/blob/main/src/app/ui/game/game.component.ts): `src/app/ui/game/game.component.ts`
- [Sound feedback](https://github.com/45ngc/angular-chess/blob/main/src/app/services/sound.service.ts): `src/app/services/sound.service.ts`
- [Game controls](https://github.com/45ngc/angular-chess/blob/main/src/app/ui/game/pause-overlay/pause-overlay.component.ts): `src/app/ui/game/pause-overlay/pause-overlay.component.ts`
- [Clock display](https://github.com/45ngc/angular-chess/blob/main/src/app/ui/game/clock/clock.component.ts): `src/app/ui/game/clock/clock.component.ts`

### Online integration

- [Room transport](https://github.com/45ngc/angular-chess/blob/main/src/app/services/online-room.service.ts): `src/app/services/online-room.service.ts`

### Other components

- **Player**
- **Stockfish worker**
- **Chess backend**

## Connections

- Player → Home setup: configures
- Home setup → Local settings: opens (evidence: `src/app/ui/home/home.component.ts`)
- Home setup → AI settings: opens (evidence: `src/app/ui/home/home.component.ts`)
- Home setup → Online settings: opens (evidence: `src/app/ui/home/home.component.ts`)
- Home setup → Room lobby: opens (evidence: `src/app/ui/home/home.component.ts`)
- Player → Game view: plays
- Game view → Local game: uses (evidence: `src/app/ui/game/game.component.ts`)
- Game view → AI game: uses (evidence: `src/app/ui/game/game.component.ts`)
- Game view → Online game: uses (evidence: `src/app/ui/game/game.component.ts`)
- Local game → Gameplay base: extends (evidence: `src/app/services/local-game.service.ts`)
- AI game → Gameplay base: extends (evidence: `src/app/services/ai-game.service.ts`)
- Online game → Room transport: subscribes (evidence: `src/app/services/online-game.service.ts`)
- Online game → Move history: rebuilds from (evidence: `src/app/services/online-game.service.ts`)
- Local game → Local clock: updates (evidence: `src/app/services/local-game.service.ts`)
- Local game → Move navigation: inherits (evidence: `src/app/services/local-game.service.ts`)
- AI game → Move navigation: uses (evidence: `src/app/services/ai-game.service.ts`)
- AI game → Stockfish service: requests moves (evidence: `src/app/services/ai-game.service.ts`)
- Stockfish service → Stockfish worker: queries (evidence: `README.md`)
- Local game → Game state: updates (evidence: `src/app/services/local-game.service.ts`)
- AI game → Game state: updates (evidence: `src/app/services/ai-game.service.ts`)
- Game state → Move simulation: simulates (evidence: `src/app/core/rules/game-state.ts`)
- Game state → Legal moves: checks moves (evidence: `src/app/core/rules/game-state.ts`)
- Game state → Draw rules: checks draws (evidence: `src/app/core/rules/game-state.ts`)
- Game state → Attack detection: checks check (evidence: `src/app/core/rules/game-state.ts`)
- Legal moves → Attack detection: checks safety (evidence: `src/app/core/rules/legal-move-finder.ts`)
- Legal moves → Move simulation: tests moves (evidence: `src/app/core/rules/legal-move-finder.ts`)
- Game state → Board model: holds (evidence: `src/app/core/rules/game-state.ts`)
- Game state → FEN notation: keys positions (evidence: `src/app/core/rules/game-state.ts`)
- Game view → Game controls: renders (evidence: `src/app/ui/game/game.component.ts`)
- Game view → Clock display: renders (evidence: `src/app/ui/game/game.component.ts`)
- Game view → Sound feedback: uses (evidence: `src/app/ui/game/game.component.ts`)
- Local game → Sound feedback: plays cues (evidence: `src/app/services/local-game.service.ts`)
- AI game → Sound feedback: plays cues (evidence: `src/app/services/ai-game.service.ts`)
- Online game → Sound feedback: plays cues (evidence: `src/app/services/online-game.service.ts`)
- Room lobby → Room transport: manages rooms (evidence: `src/app/ui/home/online-lobby-dialog/online-lobby-dialog.component.ts`)
- Room transport → Chess backend: REST and STOMP (evidence: `src/app/services/online-room.service.ts`)
- Room transport → Chess backend: synchronizes snapshots (evidence: `README.md`)
