# abineshkumarr/chessley architecture

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

- Interactive diagram: https://gitdiagram.com/abineshkumarr/chessley
- Repository: https://github.com/abineshkumarr/chessley

## Overview

#### Purpose and Entry Points
This is a browser-based chess game built as a Vite/React single-page application. Startup flows from `index.html` to `src/main.jsx`, which mounts the application root in `src/App.jsx`. Styling is application-wide in `src/index.css`, with Tailwind/PostCSS configuration available for the build pipeline.

#### Application Composition
`src/App.jsx` is the top-level composition boundary. The UI is organized around the playable game surface in `src/components/ChessGame.jsx`, with surrounding navigation and lobby/setup experiences in:
- `src/components/TopNav.jsx`
- `src/components/SetupLobby.jsx`
- `src/components/ChessSidebar.jsx`

The lobby likely collects game mode, player, bot, or theme choices before handing control to the active game view.

#### Game Session and Board Interaction
`src/components/ChessGame.jsx` is the central game-session coordinator: it should own or orchestrate board position, turn progression, selected pieces/squares, legal move application, and transitions into promotion or game-over states. Its direct presentation/control boundaries include:
- `src/components/GameControls.jsx`
- `src/components/GameStatus.jsx`
- `src/components/PromotionModal.jsx`

Promotion and terminal-game dialogs isolate exceptional game-state decisions from ordinary board interaction.

#### Player, Clock, and History Surfaces
The game shell exposes player-facing state through specialized components rather than embedding it in the board:
- `src/components/ChessClock.jsx`
- `src/components/PlayerRibbon.jsx`
- `src/components/MoveHistory.jsx`

Captured material and full historical review are separate views in `src/components/CapturedPieces.jsx` and `src/components/GameHistoryModal.jsx`. This division permits the core session state to drive multiple synchronized read-only displays, while controls send actions back to the game coordinator.

#### Engine and Bot Boundary
Chess-specific automated-opponent logic is isolated under `src/engine`, especially:
- `src/engine/bot.js`
- `src/engine/pst.js`
- `src/engine/threats.js`

`bot.js` is the likely decision boundary between UI state and computer moves. Piece-square tables in `pst.js` and tactical/threat evaluation in `threats.js` support move scoring or selection. Sound behavior is similarly separated in `src/engine/sound.js`, preventing audio effects from being coupled to React presentation components.

#### Configuration, Persistence, and Assets
Static game choices are centralized in `src/constants/bots.js` and `src/constants/themes.js`, allowing setup and game UI to consume shared bot/theme definitions. Browser persistence is abstracted behind `src/utils/storage.js`, likely for saved preferences or resumable game-related state.

Avatar assets reside in `public/avatars`; `scripts/download-avatars.mjs` is an asset-acquisition integration point and may contact an external avatar source during development or asset refresh, not at normal runtime.

#### Runtime and Build Infrastructure
The runtime is client-side JavaScript in the browser, packaged by Vite via `vite.config.js`. Dependency and script definitions are in `package.json`. Tailwind/PostCSS are configured through `tailwind.config.js` and `postcss.config.js`; they support the frontend styling pipeline rather than game execution. No backend, database, API client, or server-side service is represented in the supplied tree.

Main entry points: [`src/components/ChessGame.jsx`](https://github.com/abineshkumarr/chessley/blob/main/src/components/ChessGame.jsx) (Chess game), [`src/App.jsx`](https://github.com/abineshkumarr/chessley/blob/main/src/App.jsx) (App root), [`src/main.jsx`](https://github.com/abineshkumarr/chessley/blob/main/src/main.jsx) (React mount), [`src/components/SetupLobby.jsx`](https://github.com/abineshkumarr/chessley/blob/main/src/components/SetupLobby.jsx) (Setup lobby)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React UI"]
  node_html["HTML entry<br/>[index.html]"]
  node_main["React mount<br/>bootstrap<br/>[main.jsx]"]
  node_app["App root<br/>composition<br/>[App.jsx]"]
  node_styles["Global styles<br/>[index.css]"]
  node_topnav["Top navigation<br/>[TopNav.jsx]"]
  node_lobby["Setup lobby<br/>[SetupLobby.jsx]"]
  node_sidebar["Chess sidebar<br/>[ChessSidebar.jsx]"]
end

subgraph group_session["Game Session"]
  node_game{{"Chess game<br/>session coordinator<br/>[ChessGame.jsx]"}}
  node_controls["Game controls<br/>[GameControls.jsx]"]
  node_status["Game status<br/>[GameStatus.jsx]"]
  node_promotion["Promotion modal<br/>[PromotionModal.jsx]"]
  node_clock["Chess clock<br/>[ChessClock.jsx]"]
  node_players["Player ribbon<br/>[PlayerRibbon.jsx]"]
  node_moves["Move history<br/>[MoveHistory.jsx]"]
  node_captured["Captured pieces<br/>[CapturedPieces.jsx]"]
  node_historymodal["Game history modal"]
end

subgraph group_engine["Chess Engine"]
  node_bot{{"Bot decision<br/>engine<br/>[bot.js]"}}
  node_pst["Piece-square tables<br/>evaluation data<br/>[pst.js]"]
  node_threats["Threat evaluation<br/>engine helper<br/>[threats.js]"]
  node_sound["Sound effects<br/>audio service<br/>[sound.js]"]
end

subgraph group_shared["Shared Runtime"]
  node_choices["Bot and theme choices<br/>constants<br/>[bots.js]"]
  node_storage[("Browser storage<br/>persistence<br/>[storage.js]")]
end

node_html -->|"loads"| node_main
node_main -->|"mounts"| node_app
node_main -->|"imports"| node_styles
node_app -->|"composes"| node_topnav
node_app -->|"composes"| node_lobby
node_app -->|"hosts"| node_game
node_app -->|"composes"| node_sidebar
node_lobby -->|"reads setup options"| node_choices
node_lobby -->|"starts session"| node_game
node_game -->|"drives"| node_controls
node_game -->|"drives"| node_status
node_game -->|"opens when needed"| node_promotion
node_game -->|"drives"| node_clock
node_game -->|"drives"| node_players
node_game -->|"drives"| node_moves
node_game -->|"drives"| node_captured
node_game -->|"opens"| node_historymodal
node_controls -->|"sends actions"| node_game
node_promotion -->|"selects piece"| node_game
node_game -->|"requests bot move"| node_bot
node_bot -->|"scores with"| node_pst
node_bot -->|"evaluates"| node_threats
node_game -->|"triggers"| node_sound
node_game -->|"persists state"| node_storage

click node_html "https://github.com/abineshkumarr/chessley/blob/main/index.html"
click node_main "https://github.com/abineshkumarr/chessley/blob/main/src/main.jsx"
click node_app "https://github.com/abineshkumarr/chessley/blob/main/src/App.jsx"
click node_styles "https://github.com/abineshkumarr/chessley/blob/main/src/index.css"
click node_topnav "https://github.com/abineshkumarr/chessley/blob/main/src/components/TopNav.jsx"
click node_lobby "https://github.com/abineshkumarr/chessley/blob/main/src/components/SetupLobby.jsx"
click node_sidebar "https://github.com/abineshkumarr/chessley/blob/main/src/components/ChessSidebar.jsx"
click node_game "https://github.com/abineshkumarr/chessley/blob/main/src/components/ChessGame.jsx"
click node_controls "https://github.com/abineshkumarr/chessley/blob/main/src/components/GameControls.jsx"
click node_status "https://github.com/abineshkumarr/chessley/blob/main/src/components/GameStatus.jsx"
click node_promotion "https://github.com/abineshkumarr/chessley/blob/main/src/components/PromotionModal.jsx"
click node_clock "https://github.com/abineshkumarr/chessley/blob/main/src/components/ChessClock.jsx"
click node_players "https://github.com/abineshkumarr/chessley/blob/main/src/components/PlayerRibbon.jsx"
click node_moves "https://github.com/abineshkumarr/chessley/blob/main/src/components/MoveHistory.jsx"
click node_captured "https://github.com/abineshkumarr/chessley/blob/main/src/components/CapturedPieces.jsx"
click node_historymodal "https://github.com/abineshkumarr/chessley/blob/main/src/components/GameHistoryModal.jsx"
click node_bot "https://github.com/abineshkumarr/chessley/blob/main/src/engine/bot.js"
click node_pst "https://github.com/abineshkumarr/chessley/blob/main/src/engine/pst.js"
click node_threats "https://github.com/abineshkumarr/chessley/blob/main/src/engine/threats.js"
click node_sound "https://github.com/abineshkumarr/chessley/blob/main/src/engine/sound.js"
click node_choices "https://github.com/abineshkumarr/chessley/blob/main/src/constants/bots.js"
click node_storage "https://github.com/abineshkumarr/chessley/blob/main/src/utils/storage.js"

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_html,node_main,node_app,node_styles,node_topnav,node_lobby,node_sidebar toneBlue
class node_game,node_controls,node_status,node_promotion,node_clock,node_players,node_moves,node_captured,node_historymodal toneAmber
class node_bot,node_pst,node_threats,node_sound toneMint
class node_choices,node_storage toneRose
```

## Components

### React UI

- [HTML entry](https://github.com/abineshkumarr/chessley/blob/main/index.html): entry · `index.html`
- [React mount](https://github.com/abineshkumarr/chessley/blob/main/src/main.jsx): bootstrap · `src/main.jsx`
- [App root](https://github.com/abineshkumarr/chessley/blob/main/src/App.jsx): composition · `src/App.jsx`
- [Global styles](https://github.com/abineshkumarr/chessley/blob/main/src/index.css): styles · `src/index.css`
- [Top navigation](https://github.com/abineshkumarr/chessley/blob/main/src/components/TopNav.jsx): `src/components/TopNav.jsx`
- [Setup lobby](https://github.com/abineshkumarr/chessley/blob/main/src/components/SetupLobby.jsx): `src/components/SetupLobby.jsx`
- [Chess sidebar](https://github.com/abineshkumarr/chessley/blob/main/src/components/ChessSidebar.jsx): `src/components/ChessSidebar.jsx`

### Game Session

- [Chess game](https://github.com/abineshkumarr/chessley/blob/main/src/components/ChessGame.jsx): session coordinator · Owns board interaction, turn progression, and game-state transitions. · `src/components/ChessGame.jsx`
- [Game controls](https://github.com/abineshkumarr/chessley/blob/main/src/components/GameControls.jsx): `src/components/GameControls.jsx`
- [Game status](https://github.com/abineshkumarr/chessley/blob/main/src/components/GameStatus.jsx): `src/components/GameStatus.jsx`
- [Promotion modal](https://github.com/abineshkumarr/chessley/blob/main/src/components/PromotionModal.jsx): `src/components/PromotionModal.jsx`
- [Chess clock](https://github.com/abineshkumarr/chessley/blob/main/src/components/ChessClock.jsx): `src/components/ChessClock.jsx`
- [Player ribbon](https://github.com/abineshkumarr/chessley/blob/main/src/components/PlayerRibbon.jsx): `src/components/PlayerRibbon.jsx`
- [Move history](https://github.com/abineshkumarr/chessley/blob/main/src/components/MoveHistory.jsx): `src/components/MoveHistory.jsx`
- [Captured pieces](https://github.com/abineshkumarr/chessley/blob/main/src/components/CapturedPieces.jsx): `src/components/CapturedPieces.jsx`
- [Game history modal](https://github.com/abineshkumarr/chessley/blob/main/src/components/GameHistoryModal.jsx): `src/components/GameHistoryModal.jsx`

### Chess Engine

- [Bot decision](https://github.com/abineshkumarr/chessley/blob/main/src/engine/bot.js): engine · Selects automated-opponent moves from game state. · `src/engine/bot.js`
- [Piece-square tables](https://github.com/abineshkumarr/chessley/blob/main/src/engine/pst.js): evaluation data · `src/engine/pst.js`
- [Threat evaluation](https://github.com/abineshkumarr/chessley/blob/main/src/engine/threats.js): engine helper · `src/engine/threats.js`
- [Sound effects](https://github.com/abineshkumarr/chessley/blob/main/src/engine/sound.js): audio service · `src/engine/sound.js`

### Shared Runtime

- [Bot and theme choices](https://github.com/abineshkumarr/chessley/blob/main/src/constants/bots.js): constants · `src/constants/bots.js`
- [Browser storage](https://github.com/abineshkumarr/chessley/blob/main/src/utils/storage.js): persistence · `src/utils/storage.js`

## Connections

- HTML entry → React mount: loads
- React mount → App root: mounts
- React mount → Global styles: imports
- App root → Top navigation: composes
- App root → Setup lobby: composes
- App root → Chess game: hosts
- App root → Chess sidebar: composes
- Setup lobby → Bot and theme choices: reads setup options
- Setup lobby → Chess game: starts session
- Chess game → Game controls: drives
- Chess game → Game status: drives
- Chess game → Promotion modal: opens when needed
- Chess game → Chess clock: drives
- Chess game → Player ribbon: drives
- Chess game → Move history: drives
- Chess game → Captured pieces: drives
- Chess game → Game history modal: opens
- Game controls → Chess game: sends actions
- Promotion modal → Chess game: selects piece
- Chess game → Bot decision: requests bot move
- Bot decision → Piece-square tables: scores with
- Bot decision → Threat evaluation: evaluates
- Chess game → Sound effects: triggers
- Chess game → Browser storage: persists state
