# smashinu/chessbot architecture

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

- Interactive diagram: https://gitdiagram.com/smashinu/chessbot
- Repository: https://github.com/smashinu/chessbot

## Overview

ChessBotMVP is a browser chess game: the player makes a move on an interactive board, the app validates and records it, Stockfish computes a reply, and the app updates the board and reports game outcomes. The README also documents a per-side timer, difficulty scaling, promotion, invalid-move feedback, and sound effects. The sampled game component implements promotion, difficulty, outcomes, and move feedback; timer behavior is not visible in the sampled source, so its wiring is omitted.

Main entry points: [`src/chessBotMVP.jsx`](https://github.com/smashinu/chessbot/blob/master/src/chessBotMVP.jsx) (Chess game UI), [`src/index.js`](https://github.com/smashinu/chessbot/blob/master/src/index.js) (App entry), [`src/App.js`](https://github.com/smashinu/chessbot/blob/master/src/App.js) (App shell), [`public/stockfish.js`](https://github.com/smashinu/chessbot/blob/master/public/stockfish.js) (Stockfish runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gameplay["Game interface"]
  node_app_entry["App entry<br/>[index.js]"]
  node_app_shell["App shell<br/>[App.js]"]
  node_game_ui["Chess game UI<br/>[chessBotMVP.jsx]"]
  node_board["Interactive board"]
  node_timer["Game timer<br/>[chessBotMVP.jsx]"]
end

subgraph group_rules["Chess gameplay"]
  node_chess_rules["Chess rules"]
  node_game_state["Game state<br/>[chessBotMVP.jsx]"]
  node_outcomes["Game outcomes<br/>[chessBotMVP.jsx]"]
  node_difficulty["Difficulty scaling<br/>[chessBotMVP.jsx]"]
end

subgraph group_engine_audio["Engine and audio"]
  node_worker["Stockfish worker<br/>[stockfishWorker.js]"]
  node_engine_asset["Stockfish runtime<br/>[stockfish.js]"]
  node_engine_wasm["Engine WASM<br/>[stockfish.wasm]"]
  node_sound_effects["Sound effects<br/>[sounds.jsx]"]
end

node_player(("Player"))

node_player -->|"opens game"| node_app_entry
node_app_entry -->|"renders"| node_app_shell
node_app_shell -->|"renders"| node_game_ui
node_game_ui -->|"renders board"| node_board
node_board -->|"reports moves"| node_game_ui
node_game_ui -->|"validates moves"| node_chess_rules
node_game_ui -->|"updates state"| node_game_state
node_game_ui -->|"checks outcomes"| node_outcomes
node_outcomes -->|"reports result"| node_game_ui
node_game_ui -->|"updates level"| node_difficulty
node_game_ui -->|"starts worker"| node_worker
node_game_ui -->|"sends position"| node_engine_asset
node_engine_asset -->|"uses engine"| node_engine_wasm
node_game_ui -->|"applies reply"| node_game_state
node_game_ui -->|"plays feedback"| node_sound_effects

click node_app_entry "https://github.com/smashinu/chessbot/blob/master/src/index.js"
click node_app_shell "https://github.com/smashinu/chessbot/blob/master/src/App.js"
click node_game_ui "https://github.com/smashinu/chessbot/blob/master/src/chessBotMVP.jsx"
click node_timer "https://github.com/smashinu/chessbot/blob/master/src/chessBotMVP.jsx"
click node_game_state "https://github.com/smashinu/chessbot/blob/master/src/chessBotMVP.jsx"
click node_outcomes "https://github.com/smashinu/chessbot/blob/master/src/chessBotMVP.jsx"
click node_difficulty "https://github.com/smashinu/chessbot/blob/master/src/chessBotMVP.jsx"
click node_worker "https://github.com/smashinu/chessbot/blob/master/src/engine/stockfishWorker.js"
click node_engine_asset "https://github.com/smashinu/chessbot/blob/master/public/stockfish.js"
click node_engine_wasm "https://github.com/smashinu/chessbot/blob/master/public/stockfish.wasm"
click node_sound_effects "https://github.com/smashinu/chessbot/blob/master/src/sounds.jsx"

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_entry,node_app_shell,node_game_ui,node_board,node_timer toneBlue
class node_chess_rules,node_game_state,node_outcomes,node_difficulty toneAmber
class node_worker,node_engine_asset,node_engine_wasm,node_sound_effects toneMint
class node_player toneIndigo
```

## Components

### Game interface

- [App entry](https://github.com/smashinu/chessbot/blob/master/src/index.js): `src/index.js`
- [App shell](https://github.com/smashinu/chessbot/blob/master/src/App.js): `src/App.js`
- [Chess game UI](https://github.com/smashinu/chessbot/blob/master/src/chessBotMVP.jsx): `src/chessBotMVP.jsx`
- **Interactive board**
- [Game timer](https://github.com/smashinu/chessbot/blob/master/src/chessBotMVP.jsx): `src/chessBotMVP.jsx`

### Chess gameplay

- **Chess rules**
- [Game state](https://github.com/smashinu/chessbot/blob/master/src/chessBotMVP.jsx): `src/chessBotMVP.jsx`
- [Game outcomes](https://github.com/smashinu/chessbot/blob/master/src/chessBotMVP.jsx): `src/chessBotMVP.jsx`
- [Difficulty scaling](https://github.com/smashinu/chessbot/blob/master/src/chessBotMVP.jsx): `src/chessBotMVP.jsx`

### Engine and audio

- [Stockfish worker](https://github.com/smashinu/chessbot/blob/master/src/engine/stockfishWorker.js): `src/engine/stockfishWorker.js`
- [Stockfish runtime](https://github.com/smashinu/chessbot/blob/master/public/stockfish.js): `public/stockfish.js`
- [Engine WASM](https://github.com/smashinu/chessbot/blob/master/public/stockfish.wasm): `public/stockfish.wasm`
- [Sound effects](https://github.com/smashinu/chessbot/blob/master/src/sounds.jsx): `src/sounds.jsx`

### Other components

- **Player**

## Connections

- Player → App entry: opens game
- App entry → App shell: renders
- App shell → Chess game UI: renders
- Chess game UI → Interactive board: renders board
- Interactive board → Chess game UI: reports moves
- Chess game UI → Chess rules: validates moves
- Chess game UI → Game state: updates state
- Chess game UI → Game outcomes: checks outcomes
- Game outcomes → Chess game UI: reports result
- Chess game UI → Difficulty scaling: updates level
- Chess game UI → Stockfish worker: starts worker
- Chess game UI → Stockfish runtime: sends position
- Stockfish runtime → Engine WASM: uses engine
- Chess game UI → Game state: applies reply
- Chess game UI → Sound effects: plays feedback
