# dsnext412-jpg/chess architecture

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

- Interactive diagram: https://gitdiagram.com/dsnext412-jpg/chess
- Repository: https://github.com/dsnext412-jpg/chess

## Overview

Chess Session is a browser-based, account-free multiplayer chess app. Players create or join a private room, connect peer-to-peer, play a synchronized match, and see its result. The graph separates navigation and room entry, session networking, chess rules/state, and the game interface and preferences. The sampled session and engine excerpts support their internal calls; several UI relationships and feature details are documented or listed in the source index but not shown in full source excerpts.

Main entry points: [`src/components/GameView.tsx`](https://github.com/dsnext412-jpg/chess/blob/main/src/components/GameView.tsx) (Game View), [`src/App.tsx`](https://github.com/dsnext412-jpg/chess/blob/main/src/App.tsx) (App Routing), [`src/session/SessionManager.ts`](https://github.com/dsnext412-jpg/chess/blob/main/src/session/SessionManager.ts) (Session Manager), [`src/hooks/useSession.ts`](https://github.com/dsnext412-jpg/chess/blob/main/src/hooks/useSession.ts) (Session Hook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and Rooms"]
  node_app["App Routing<br/>[App.tsx]"]
  node_home["Home Page<br/>[HomePage.tsx]"]
  node_create["Create Room<br/>[CreateRoom.tsx]"]
  node_join["Join Room<br/>[JoinRoom.tsx]"]
  node_waiting["Waiting Room<br/>[WaitingRoom.tsx]"]
end

subgraph group_session["Session Networking"]
  node_sessionhook["Session Hook<br/>[useSession.ts]"]
  node_manager["Session Manager<br/>[SessionManager.ts]"]
  node_peer(("PeerJS / WebRTC"))
  node_protocol["Message Protocol<br/>[protocol.ts]"]
end

subgraph group_game["Chess State"]
  node_engine["Game Engine<br/>[gameEngine.ts]"]
  node_board["Board Utilities<br/>[board.ts]"]
end

subgraph group_experience["Game Experience"]
  node_gameview["Game View<br/>[GameView.tsx]"]
  node_chessboard["Chess Board<br/>[ChessBoard.tsx]"]
  node_history["Move History<br/>[MoveHistory.tsx]"]
  node_captured["Captured Pieces<br/>[CapturedPieces.tsx]"]
  node_controls["Game Controls<br/>[GameControls.tsx]"]
  node_settings["Game Settings<br/>[GameSettings.tsx]"]
  node_preferences["Preferences<br/>[usePreferences.ts]"]
  node_themes["Board and Piece Themes<br/>[themes.ts]"]
end

node_player(("Player"))

node_player -->|"opens"| node_app
node_app -->|"renders"| node_home
node_app -->|"renders"| node_create
node_app -->|"renders"| node_join
node_app -->|"renders"| node_waiting
node_app -->|"renders"| node_gameview
node_player -->|"creates room"| node_create
node_player -->|"joins room"| node_join
node_create -->|"starts hosting"| node_sessionhook
node_join -->|"requests join"| node_sessionhook
node_waiting -->|"reads session"| node_manager
node_sessionhook -->|"dispatches actions"| node_manager
node_manager -->|"connects peers"| node_peer
node_manager -->|"parses messages"| node_protocol
node_manager -->|"updates game"| node_engine
node_manager -.->|"exchanges messages"| node_peer
node_gameview -->|"reads session"| node_sessionhook
node_gameview -->|"renders"| node_chessboard
node_gameview -->|"renders"| node_history
node_gameview -->|"renders"| node_captured
node_gameview -->|"renders"| node_controls
node_gameview -->|"renders"| node_settings
node_chessboard -->|"checks moves"| node_engine
node_engine -->|"uses coordinates"| node_board
node_settings -->|"updates options"| node_preferences
node_settings -->|"offers themes"| node_themes

click node_app "https://github.com/dsnext412-jpg/chess/blob/main/src/App.tsx"
click node_home "https://github.com/dsnext412-jpg/chess/blob/main/src/components/HomePage.tsx"
click node_create "https://github.com/dsnext412-jpg/chess/blob/main/src/components/CreateRoom.tsx"
click node_join "https://github.com/dsnext412-jpg/chess/blob/main/src/components/JoinRoom.tsx"
click node_waiting "https://github.com/dsnext412-jpg/chess/blob/main/src/components/WaitingRoom.tsx"
click node_sessionhook "https://github.com/dsnext412-jpg/chess/blob/main/src/hooks/useSession.ts"
click node_manager "https://github.com/dsnext412-jpg/chess/blob/main/src/session/SessionManager.ts"
click node_protocol "https://github.com/dsnext412-jpg/chess/blob/main/src/lib/protocol.ts"
click node_engine "https://github.com/dsnext412-jpg/chess/blob/main/src/lib/gameEngine.ts"
click node_board "https://github.com/dsnext412-jpg/chess/blob/main/src/lib/board.ts"
click node_gameview "https://github.com/dsnext412-jpg/chess/blob/main/src/components/GameView.tsx"
click node_chessboard "https://github.com/dsnext412-jpg/chess/blob/main/src/components/ChessBoard.tsx"
click node_history "https://github.com/dsnext412-jpg/chess/blob/main/src/components/MoveHistory.tsx"
click node_captured "https://github.com/dsnext412-jpg/chess/blob/main/src/components/CapturedPieces.tsx"
click node_controls "https://github.com/dsnext412-jpg/chess/blob/main/src/components/GameControls.tsx"
click node_settings "https://github.com/dsnext412-jpg/chess/blob/main/src/components/GameSettings.tsx"
click node_preferences "https://github.com/dsnext412-jpg/chess/blob/main/src/hooks/usePreferences.ts"
click node_themes "https://github.com/dsnext412-jpg/chess/blob/main/src/lib/themes.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_home,node_create,node_join,node_waiting toneBlue
class node_sessionhook,node_manager,node_peer,node_protocol toneAmber
class node_engine,node_board toneMint
class node_gameview,node_chessboard,node_history,node_captured,node_controls,node_settings,node_preferences,node_themes toneRose
class node_player toneIndigo
```

## Components

### Entry and Rooms

- [App Routing](https://github.com/dsnext412-jpg/chess/blob/main/src/App.tsx): `src/App.tsx`
- [Home Page](https://github.com/dsnext412-jpg/chess/blob/main/src/components/HomePage.tsx): `src/components/HomePage.tsx`
- [Create Room](https://github.com/dsnext412-jpg/chess/blob/main/src/components/CreateRoom.tsx): `src/components/CreateRoom.tsx`
- [Join Room](https://github.com/dsnext412-jpg/chess/blob/main/src/components/JoinRoom.tsx): `src/components/JoinRoom.tsx`
- [Waiting Room](https://github.com/dsnext412-jpg/chess/blob/main/src/components/WaitingRoom.tsx): `src/components/WaitingRoom.tsx`

### Session Networking

- [Session Hook](https://github.com/dsnext412-jpg/chess/blob/main/src/hooks/useSession.ts): `src/hooks/useSession.ts`
- [Session Manager](https://github.com/dsnext412-jpg/chess/blob/main/src/session/SessionManager.ts): `src/session/SessionManager.ts`
- **PeerJS / WebRTC**
- [Message Protocol](https://github.com/dsnext412-jpg/chess/blob/main/src/lib/protocol.ts): `src/lib/protocol.ts`

### Chess State

- [Game Engine](https://github.com/dsnext412-jpg/chess/blob/main/src/lib/gameEngine.ts): `src/lib/gameEngine.ts`
- [Board Utilities](https://github.com/dsnext412-jpg/chess/blob/main/src/lib/board.ts): `src/lib/board.ts`

### Game Experience

- [Game View](https://github.com/dsnext412-jpg/chess/blob/main/src/components/GameView.tsx): `src/components/GameView.tsx`
- [Chess Board](https://github.com/dsnext412-jpg/chess/blob/main/src/components/ChessBoard.tsx): `src/components/ChessBoard.tsx`
- [Move History](https://github.com/dsnext412-jpg/chess/blob/main/src/components/MoveHistory.tsx): `src/components/MoveHistory.tsx`
- [Captured Pieces](https://github.com/dsnext412-jpg/chess/blob/main/src/components/CapturedPieces.tsx): `src/components/CapturedPieces.tsx`
- [Game Controls](https://github.com/dsnext412-jpg/chess/blob/main/src/components/GameControls.tsx): `src/components/GameControls.tsx`
- [Game Settings](https://github.com/dsnext412-jpg/chess/blob/main/src/components/GameSettings.tsx): `src/components/GameSettings.tsx`
- [Preferences](https://github.com/dsnext412-jpg/chess/blob/main/src/hooks/usePreferences.ts): `src/hooks/usePreferences.ts`
- [Board and Piece Themes](https://github.com/dsnext412-jpg/chess/blob/main/src/lib/themes.ts): `src/lib/themes.ts`

### Other components

- **Player**

## Connections

- Player → App Routing: opens
- App Routing → Home Page: renders (evidence: `src/App.tsx`)
- App Routing → Create Room: renders (evidence: `src/App.tsx`)
- App Routing → Join Room: renders (evidence: `src/App.tsx`)
- App Routing → Waiting Room: renders (evidence: `src/App.tsx`)
- App Routing → Game View: renders (evidence: `src/App.tsx`)
- Player → Create Room: creates room
- Player → Join Room: joins room
- Create Room → Session Hook: starts hosting (evidence: `src/components/CreateRoom.tsx`)
- Join Room → Session Hook: requests join (evidence: `src/components/JoinRoom.tsx`)
- Waiting Room → Session Manager: reads session (evidence: `src/components/WaitingRoom.tsx`)
- Session Hook → Session Manager: dispatches actions (evidence: `src/hooks/useSession.ts`)
- Session Manager → PeerJS / WebRTC: connects peers
- Session Manager → Message Protocol: parses messages (evidence: `src/session/SessionManager.ts`)
- Session Manager → Game Engine: updates game (evidence: `src/session/SessionManager.ts`)
- Session Manager → PeerJS / WebRTC: exchanges messages
- Game View → Session Hook: reads session (evidence: `src/components/GameView.tsx`)
- Game View → Chess Board: renders (evidence: `src/components/GameView.tsx`)
- Game View → Move History: renders (evidence: `src/components/GameView.tsx`)
- Game View → Captured Pieces: renders (evidence: `src/components/GameView.tsx`)
- Game View → Game Controls: renders (evidence: `src/components/GameView.tsx`)
- Game View → Game Settings: renders (evidence: `src/components/GameView.tsx`)
- Chess Board → Game Engine: checks moves (evidence: `src/components/ChessBoard.tsx`)
- Game Engine → Board Utilities: uses coordinates (evidence: `src/lib/gameEngine.ts`)
- Game Settings → Preferences: updates options (evidence: `src/components/GameSettings.tsx`)
- Game Settings → Board and Piece Themes: offers themes (evidence: `src/components/GameSettings.tsx`)
