# yaswish/chess-advisor architecture

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

- Interactive diagram: https://gitdiagram.com/yaswish/chess-advisor
- Repository: https://github.com/yaswish/chess-advisor

## Overview

Chess Advisor is a private, browser-based chess analysis and play app. A player imports or sets up a position or game, navigates it on the board, and receives live engine analysis; they can then review a game, practise mistakes, or play Stockfish. The graph includes the documented opening, endgame, sharing, and personalization features. Some components are represented at their exact source path, but their internal connections are omitted where the supplied excerpts do not establish them.

Main entry points: [`src/App.tsx`](https://github.com/yaswish/chess-advisor/blob/main/src/App.tsx) (App shell), [`src/components/AnalysisView.tsx`](https://github.com/yaswish/chess-advisor/blob/main/src/components/AnalysisView.tsx) (Analysis board), [`src/controllers/review.ts`](https://github.com/yaswish/chess-advisor/blob/main/src/controllers/review.ts) (Game review), [`src/engine/stockfish.ts`](https://github.com/yaswish/chess-advisor/blob/main/src/engine/stockfish.ts) (Stockfish engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_app["App shell<br/>[App.tsx]"]
  node_analysis_ui["Analysis board<br/>[AnalysisView.tsx]"]
  node_board["Chess board<br/>[Board.tsx]"]
  node_engine_panel["Engine panel<br/>[EnginePanel.tsx]"]
  node_review_panel["Review panel<br/>[ReviewPanel.tsx]"]
  node_play_ui["Play view<br/>[PlayView.tsx]"]
  node_setup_ui["Position editor<br/>[SetupView.tsx]"]
  node_dialogs["Import and share<br/>[Dialogs.tsx]"]
  node_tools["Analysis tools<br/>[ToolTabs.tsx]"]
  node_sound["Move sounds<br/>[sound.ts]"]
end

subgraph group_workflow["Chess workflows"]
  node_live["Live analysis<br/>[liveAnalysis.ts]"]
  node_review["Game review<br/>[review.ts]"]
  node_play["Play controller<br/>[play.ts]"]
  node_persistence["Game persistence<br/>[persistence.ts]"]
  node_games["Game imports<br/>[games.ts]"]
end

subgraph group_analysis["Analysis and rules"]
  node_chess["Chess rules<br/>[chess.ts]"]
  node_tree["Game tree<br/>[tree.ts]"]
  node_evaluation["Evaluation metrics<br/>[eval.ts]"]
  node_grading["Move grading<br/>[review.ts]"]
  node_insights["Move insights<br/>[insights.ts]"]
  node_tactics["Tactics detection<br/>[tactics.ts]"]
  node_pgn["PGN handling<br/>[pgn.ts]"]
  node_openings["Opening lookup<br/>[openings.ts]"]
end

subgraph group_engine["Engine and data"]
  node_stockfish["Stockfish engine<br/>[stockfish.ts]"]
  node_worker["Stockfish WebAssembly"]
  node_cloud["Cloud evaluations<br/>[cloud.ts]"]
  node_tablebase["Syzygy tablebases<br/>[tablebase.ts]"]
end

subgraph group_state["State and preferences"]
  node_analysis_state[("Game analysis state<br/>[analysis.ts]")]
  node_ui_state[("Interface state<br/>[ui.ts]")]
  node_settings[("Saved preferences<br/>[settings.ts]")]
end

node_player(("Player"))
node_lichess["Lichess services"]
node_chesscom["Chess.com games"]

node_player -->|"uses"| node_app
node_app -->|"renders"| node_analysis_ui
node_app -->|"renders"| node_play_ui
node_app -->|"renders"| node_setup_ui
node_app -->|"renders"| node_dialogs
node_analysis_ui -->|"shows"| node_board
node_analysis_ui -->|"shows"| node_engine_panel
node_analysis_ui -->|"shows"| node_tools
node_analysis_ui -->|"requests analysis"| node_live
node_analysis_ui -->|"reads and updates"| node_analysis_state
node_live -->|"searches locally"| node_stockfish
node_live -->|"checks cache"| node_cloud
node_stockfish -->|"runs worker"| node_worker
node_stockfish -->|"parses scores"| node_evaluation
node_live -->|"stores evaluations"| node_analysis_state
node_review_panel -->|"starts review"| node_review
node_review -->|"searches positions"| node_stockfish
node_review -->|"checks evaluations"| node_cloud
node_review -->|"grades moves"| node_grading
node_review -->|"saves results"| node_analysis_state
node_grading -->|"converts scores"| node_evaluation
node_play_ui -->|"controls game"| node_play
node_play -->|"requests moves"| node_stockfish
node_play -->|"reviews finished game"| node_review
node_play -->|"plays sounds"| node_sound
node_setup_ui -->|"validates positions"| node_chess
node_dialogs -->|"imports and exports"| node_pgn
node_dialogs -->|"loads player games"| node_games
node_games -.->|"fetches games"| node_lichess
node_games -.->|"fetches games"| node_chesscom
node_tools -.->|"explains positions"| node_insights
node_tools -.->|"shows continuations"| node_openings
node_tools -.->|"checks endgames"| node_tablebase
node_insights -->|"detects motifs"| node_tactics
node_openings -.->|"optional lookup"| node_lichess
node_persistence -->|"saves game"| node_analysis_state
node_app -->|"restores session"| node_persistence
node_app -->|"uses interface state"| node_ui_state
node_app -->|"loads preferences"| node_settings
node_settings -->|"configures sound"| node_sound
node_analysis_ui -->|"navigates variations"| node_tree
node_tree -->|"applies moves"| node_chess
node_player -->|"sets up position"| node_setup_ui
node_player -->|"plays engine game"| node_play_ui
node_player -->|"reviews game"| node_review_panel

click node_app "https://github.com/yaswish/chess-advisor/blob/main/src/App.tsx"
click node_analysis_ui "https://github.com/yaswish/chess-advisor/blob/main/src/components/AnalysisView.tsx"
click node_board "https://github.com/yaswish/chess-advisor/blob/main/src/components/Board.tsx"
click node_engine_panel "https://github.com/yaswish/chess-advisor/blob/main/src/components/EnginePanel.tsx"
click node_review_panel "https://github.com/yaswish/chess-advisor/blob/main/src/components/ReviewPanel.tsx"
click node_play_ui "https://github.com/yaswish/chess-advisor/blob/main/src/components/PlayView.tsx"
click node_setup_ui "https://github.com/yaswish/chess-advisor/blob/main/src/components/SetupView.tsx"
click node_dialogs "https://github.com/yaswish/chess-advisor/blob/main/src/components/Dialogs.tsx"
click node_tools "https://github.com/yaswish/chess-advisor/blob/main/src/components/ToolTabs.tsx"
click node_live "https://github.com/yaswish/chess-advisor/blob/main/src/controllers/liveAnalysis.ts"
click node_review "https://github.com/yaswish/chess-advisor/blob/main/src/controllers/review.ts"
click node_play "https://github.com/yaswish/chess-advisor/blob/main/src/controllers/play.ts"
click node_persistence "https://github.com/yaswish/chess-advisor/blob/main/src/controllers/persistence.ts"
click node_games "https://github.com/yaswish/chess-advisor/blob/main/src/services/games.ts"
click node_chess "https://github.com/yaswish/chess-advisor/blob/main/src/lib/chess.ts"
click node_tree "https://github.com/yaswish/chess-advisor/blob/main/src/lib/tree.ts"
click node_evaluation "https://github.com/yaswish/chess-advisor/blob/main/src/lib/eval.ts"
click node_grading "https://github.com/yaswish/chess-advisor/blob/main/src/lib/review.ts"
click node_insights "https://github.com/yaswish/chess-advisor/blob/main/src/lib/insights.ts"
click node_tactics "https://github.com/yaswish/chess-advisor/blob/main/src/lib/tactics.ts"
click node_pgn "https://github.com/yaswish/chess-advisor/blob/main/src/lib/pgn.ts"
click node_openings "https://github.com/yaswish/chess-advisor/blob/main/src/lib/openings.ts"
click node_stockfish "https://github.com/yaswish/chess-advisor/blob/main/src/engine/stockfish.ts"
click node_worker "https://github.com/yaswish/chess-advisor/blob/main/public/engine/stockfish-19-lite-single.js"
click node_cloud "https://github.com/yaswish/chess-advisor/blob/main/src/engine/cloud.ts"
click node_tablebase "https://github.com/yaswish/chess-advisor/blob/main/src/engine/tablebase.ts"
click node_analysis_state "https://github.com/yaswish/chess-advisor/blob/main/src/state/analysis.ts"
click node_ui_state "https://github.com/yaswish/chess-advisor/blob/main/src/state/ui.ts"
click node_settings "https://github.com/yaswish/chess-advisor/blob/main/src/state/settings.ts"
click node_sound "https://github.com/yaswish/chess-advisor/blob/main/src/audio/sound.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_app,node_analysis_ui,node_board,node_engine_panel,node_review_panel,node_play_ui,node_setup_ui,node_dialogs,node_tools,node_sound toneBlue
class node_live,node_review,node_play,node_persistence,node_games toneAmber
class node_chess,node_tree,node_evaluation,node_grading,node_insights,node_tactics,node_pgn,node_openings toneMint
class node_stockfish,node_worker,node_cloud,node_tablebase toneRose
class node_analysis_state,node_ui_state,node_settings,node_player,node_lichess,node_chesscom toneIndigo
```

## Components

### Application

- [App shell](https://github.com/yaswish/chess-advisor/blob/main/src/App.tsx): `src/App.tsx`
- [Analysis board](https://github.com/yaswish/chess-advisor/blob/main/src/components/AnalysisView.tsx): `src/components/AnalysisView.tsx`
- [Chess board](https://github.com/yaswish/chess-advisor/blob/main/src/components/Board.tsx): `src/components/Board.tsx`
- [Engine panel](https://github.com/yaswish/chess-advisor/blob/main/src/components/EnginePanel.tsx): `src/components/EnginePanel.tsx`
- [Review panel](https://github.com/yaswish/chess-advisor/blob/main/src/components/ReviewPanel.tsx): `src/components/ReviewPanel.tsx`
- [Play view](https://github.com/yaswish/chess-advisor/blob/main/src/components/PlayView.tsx): `src/components/PlayView.tsx`
- [Position editor](https://github.com/yaswish/chess-advisor/blob/main/src/components/SetupView.tsx): `src/components/SetupView.tsx`
- [Import and share](https://github.com/yaswish/chess-advisor/blob/main/src/components/Dialogs.tsx): `src/components/Dialogs.tsx`
- [Analysis tools](https://github.com/yaswish/chess-advisor/blob/main/src/components/ToolTabs.tsx): `src/components/ToolTabs.tsx`
- [Move sounds](https://github.com/yaswish/chess-advisor/blob/main/src/audio/sound.ts): `src/audio/sound.ts`

### Chess workflows

- [Live analysis](https://github.com/yaswish/chess-advisor/blob/main/src/controllers/liveAnalysis.ts): `src/controllers/liveAnalysis.ts`
- [Game review](https://github.com/yaswish/chess-advisor/blob/main/src/controllers/review.ts): `src/controllers/review.ts`
- [Play controller](https://github.com/yaswish/chess-advisor/blob/main/src/controllers/play.ts): `src/controllers/play.ts`
- [Game persistence](https://github.com/yaswish/chess-advisor/blob/main/src/controllers/persistence.ts): `src/controllers/persistence.ts`
- [Game imports](https://github.com/yaswish/chess-advisor/blob/main/src/services/games.ts): `src/services/games.ts`

### Analysis and rules

- [Chess rules](https://github.com/yaswish/chess-advisor/blob/main/src/lib/chess.ts): `src/lib/chess.ts`
- [Game tree](https://github.com/yaswish/chess-advisor/blob/main/src/lib/tree.ts): `src/lib/tree.ts`
- [Evaluation metrics](https://github.com/yaswish/chess-advisor/blob/main/src/lib/eval.ts): `src/lib/eval.ts`
- [Move grading](https://github.com/yaswish/chess-advisor/blob/main/src/lib/review.ts): `src/lib/review.ts`
- [Move insights](https://github.com/yaswish/chess-advisor/blob/main/src/lib/insights.ts): `src/lib/insights.ts`
- [Tactics detection](https://github.com/yaswish/chess-advisor/blob/main/src/lib/tactics.ts): `src/lib/tactics.ts`
- [PGN handling](https://github.com/yaswish/chess-advisor/blob/main/src/lib/pgn.ts): `src/lib/pgn.ts`
- [Opening lookup](https://github.com/yaswish/chess-advisor/blob/main/src/lib/openings.ts): `src/lib/openings.ts`

### Engine and data

- [Stockfish engine](https://github.com/yaswish/chess-advisor/blob/main/src/engine/stockfish.ts): `src/engine/stockfish.ts`
- [Stockfish WebAssembly](https://github.com/yaswish/chess-advisor/blob/main/public/engine/stockfish-19-lite-single.js): `public/engine/stockfish-19-lite-single.js`
- [Cloud evaluations](https://github.com/yaswish/chess-advisor/blob/main/src/engine/cloud.ts): `src/engine/cloud.ts`
- [Syzygy tablebases](https://github.com/yaswish/chess-advisor/blob/main/src/engine/tablebase.ts): `src/engine/tablebase.ts`

### State and preferences

- [Game analysis state](https://github.com/yaswish/chess-advisor/blob/main/src/state/analysis.ts): `src/state/analysis.ts`
- [Interface state](https://github.com/yaswish/chess-advisor/blob/main/src/state/ui.ts): `src/state/ui.ts`
- [Saved preferences](https://github.com/yaswish/chess-advisor/blob/main/src/state/settings.ts): `src/state/settings.ts`

### Other components

- **Player**
- **Lichess services**
- **Chess.com games**

## Connections

- Player → App shell: uses (evidence: `README.md`)
- App shell → Analysis board: renders (evidence: `src/App.tsx`)
- App shell → Play view: renders (evidence: `src/App.tsx`)
- App shell → Position editor: renders (evidence: `src/App.tsx`)
- App shell → Import and share: renders (evidence: `src/App.tsx`)
- Analysis board → Chess board: shows (evidence: `src/components/AnalysisView.tsx`)
- Analysis board → Engine panel: shows (evidence: `src/components/AnalysisView.tsx`)
- Analysis board → Analysis tools: shows (evidence: `src/components/AnalysisView.tsx`)
- Analysis board → Live analysis: requests analysis (evidence: `src/components/AnalysisView.tsx`)
- Analysis board → Game analysis state: reads and updates (evidence: `src/components/AnalysisView.tsx`)
- Live analysis → Stockfish engine: searches locally (evidence: `src/controllers/liveAnalysis.ts`)
- Live analysis → Cloud evaluations: checks cache (evidence: `src/controllers/liveAnalysis.ts`)
- Stockfish engine → Stockfish WebAssembly: runs worker (evidence: `README.md`)
- Stockfish engine → Evaluation metrics: parses scores (evidence: `src/engine/stockfish.ts`)
- Live analysis → Game analysis state: stores evaluations (evidence: `src/controllers/liveAnalysis.ts`)
- Review panel → Game review: starts review (evidence: `src/components/ReviewPanel.tsx`)
- Game review → Stockfish engine: searches positions (evidence: `src/controllers/review.ts`)
- Game review → Cloud evaluations: checks evaluations (evidence: `src/controllers/review.ts`)
- Game review → Move grading: grades moves (evidence: `src/controllers/review.ts`)
- Game review → Game analysis state: saves results (evidence: `src/controllers/review.ts`)
- Move grading → Evaluation metrics: converts scores (evidence: `src/lib/review.ts`)
- Play view → Play controller: controls game (evidence: `src/components/PlayView.tsx`)
- Play controller → Stockfish engine: requests moves (evidence: `src/controllers/play.ts`)
- Play controller → Game review: reviews finished game (evidence: `src/controllers/play.ts`)
- Play controller → Move sounds: plays sounds (evidence: `src/controllers/play.ts`)
- Position editor → Chess rules: validates positions (evidence: `src/components/SetupView.tsx`)
- Import and share → PGN handling: imports and exports (evidence: `src/components/Dialogs.tsx`)
- Import and share → Game imports: loads player games (evidence: `src/components/Dialogs.tsx`)
- Game imports → Lichess services: fetches games (evidence: `README.md`)
- Game imports → Chess.com games: fetches games (evidence: `README.md`)
- Analysis tools → Move insights: explains positions (evidence: `README.md`)
- Analysis tools → Opening lookup: shows continuations (evidence: `README.md`)
- Analysis tools → Syzygy tablebases: checks endgames (evidence: `README.md`)
- Move insights → Tactics detection: detects motifs (evidence: `src/lib/insights.ts`)
- Opening lookup → Lichess services: optional lookup
- Game persistence → Game analysis state: saves game (evidence: `src/controllers/persistence.ts`)
- App shell → Game persistence: restores session (evidence: `src/App.tsx`)
- App shell → Interface state: uses interface state (evidence: `src/App.tsx`)
- App shell → Saved preferences: loads preferences (evidence: `src/App.tsx`)
- Saved preferences → Move sounds: configures sound (evidence: `src/audio/sound.ts`)
- Analysis board → Game tree: navigates variations (evidence: `src/components/AnalysisView.tsx`)
- Game tree → Chess rules: applies moves (evidence: `src/lib/tree.ts`)
- Player → Position editor: sets up position (evidence: `README.md`)
- Player → Play view: plays engine game (evidence: `README.md`)
- Player → Review panel: reviews game (evidence: `README.md`)
