# davo999666/chess_next_ts architecture

> Architecture diagram of the GitHub repository davo999666/chess_next_ts, 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/davo999666/chess_next_ts
- Repository: https://github.com/davo999666/chess_next_ts

## Overview

This is a child-focused chess teaching app: a teacher arranges pieces on an interactive board, demonstrates moves, and adds arrows or circles to explain positions. The page composes the board and sidebars; board interactions coordinate piece placement, move history, legal-move display, and visual annotations. Chess rules and board transformations form an internal logic layer. The README documents the teaching capabilities; unsampled component internals are represented only where the README or source index supports them, so some links are intentionally omitted.

Main entry points: [`src/component/board/Board.tsx`](https://github.com/davo999666/chess_next_ts/blob/main/src/component/board/Board.tsx) (Interactive board), [`src/app/page.tsx`](https://github.com/davo999666/chess_next_ts/blob/main/src/app/page.tsx) (Lesson page), [`src/component/PieceImage.tsx`](https://github.com/davo999666/chess_next_ts/blob/main/src/component/PieceImage.tsx) (Piece image), [`src/component/board/BoardGrid.tsx`](https://github.com/davo999666/chess_next_ts/blob/main/src/component/board/BoardGrid.tsx) (Board grid)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App composition"]
  node_home["Lesson page<br/>[page.tsx]"]
  node_sidebar["Board controls<br/>[Sidebar.tsx]"]
  node_rightsidebar["Right sidebar<br/>[SidebarRight.tsx]"]
end

subgraph group_board["Board interaction"]
  node_board["Interactive board<br/>[Board.tsx]"]
  node_handlers["Board commands"]
  node_history["Move history<br/>[HistoryContext.tsx]"]
  node_grid["Board grid<br/>[BoardGrid.tsx]"]
  node_drag["Drag layer<br/>[DragLayer.tsx]"]
end

subgraph group_teaching["Teaching visuals"]
  node_arrows["Move arrows<br/>[MoveArrows.tsx]"]
  node_circles["Square circles"]
  node_arrowhook["Arrow drawing<br/>[useArrowDrawing.ts]"]
end

subgraph group_rules["Chess logic"]
  node_legal["Legal moves<br/>[legalMoves.ts]"]
  node_pseudo["Pseudo moves"]
  node_boardutils["Board utilities<br/>[boardUtils.ts]"]
  node_constants["Chess constants<br/>[constant.ts]"]
end

subgraph group_presentation["Pieces and layout"]
  node_pools["Piece pools<br/>[PiecePools.tsx]"]
  node_pieceimage["Piece image<br/>[PieceImage.tsx]"]
  node_piecemap["Piece mapping<br/>[pieceMap.ts]"]
  node_sizing["Responsive sizing<br/>[classNameSize.ts]"]
end

node_teacher(("Teacher"))

node_teacher -->|"opens lesson"| node_home
node_home -->|"renders"| node_board
node_home -->|"renders"| node_sidebar
node_home -->|"renders"| node_rightsidebar
node_sidebar -->|"invokes commands"| node_handlers
node_board -->|"registers commands"| node_handlers
node_board -->|"uses history"| node_history
node_board -->|"renders grid"| node_grid
node_board -->|"renders pools"| node_pools
node_board -->|"renders annotations"| node_arrows
node_board -->|"renders annotations"| node_circles
node_board -->|"tracks drawing"| node_arrowhook
node_board -->|"requests moves"| node_legal
node_board -->|"flips board"| node_boardutils
node_grid -->|"renders pieces"| node_pieceimage
node_grid -->|"renders drag layer"| node_drag
node_drag -->|"renders piece"| node_pieceimage
node_pools -->|"uses piece images"| node_piecemap
node_pools -->|"uses sizing"| node_sizing
node_pieceimage -->|"resolves image"| node_piecemap
node_pieceimage -->|"uses sizing"| node_sizing
node_legal -->|"filters moves"| node_pseudo
node_legal -->|"uses rules"| node_constants
node_pseudo -->|"checks bounds"| node_constants
node_boardutils -->|"types board"| node_piecemap

click node_home "https://github.com/davo999666/chess_next_ts/blob/main/src/app/page.tsx"
click node_board "https://github.com/davo999666/chess_next_ts/blob/main/src/component/board/Board.tsx"
click node_sidebar "https://github.com/davo999666/chess_next_ts/blob/main/src/component/sidebar/Sidebar.tsx"
click node_rightsidebar "https://github.com/davo999666/chess_next_ts/blob/main/src/component/sidebar/SidebarRight.tsx"
click node_handlers "https://github.com/davo999666/chess_next_ts/blob/main/src/hooks/useBoardHandlers.ts"
click node_history "https://github.com/davo999666/chess_next_ts/blob/main/src/context/HistoryContext.tsx"
click node_grid "https://github.com/davo999666/chess_next_ts/blob/main/src/component/board/BoardGrid.tsx"
click node_drag "https://github.com/davo999666/chess_next_ts/blob/main/src/component/board/DragLayer.tsx"
click node_pools "https://github.com/davo999666/chess_next_ts/blob/main/src/component/PiecePools.tsx"
click node_pieceimage "https://github.com/davo999666/chess_next_ts/blob/main/src/component/PieceImage.tsx"
click node_arrows "https://github.com/davo999666/chess_next_ts/blob/main/src/component/MoveArrows.tsx"
click node_circles "https://github.com/davo999666/chess_next_ts/blob/main/src/component/RightClickCircles.tsx"
click node_arrowhook "https://github.com/davo999666/chess_next_ts/blob/main/src/hooks/useArrowDrawing.ts"
click node_legal "https://github.com/davo999666/chess_next_ts/blob/main/src/utils/legalMoves.ts"
click node_pseudo "https://github.com/davo999666/chess_next_ts/blob/main/src/utils/pseudoMovesForPiece.ts"
click node_boardutils "https://github.com/davo999666/chess_next_ts/blob/main/src/utils/boardUtils.ts"
click node_constants "https://github.com/davo999666/chess_next_ts/blob/main/src/utils/constant.ts"
click node_piecemap "https://github.com/davo999666/chess_next_ts/blob/main/src/utils/pieceMap.ts"
click node_sizing "https://github.com/davo999666/chess_next_ts/blob/main/src/utils/classNameSize.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_sidebar,node_rightsidebar toneBlue
class node_board,node_handlers,node_history,node_grid,node_drag toneAmber
class node_arrows,node_circles,node_arrowhook toneMint
class node_legal,node_pseudo,node_boardutils,node_constants toneRose
class node_pools,node_pieceimage,node_piecemap,node_sizing,node_teacher toneIndigo
```

## Components

### App composition

- [Lesson page](https://github.com/davo999666/chess_next_ts/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Board controls](https://github.com/davo999666/chess_next_ts/blob/main/src/component/sidebar/Sidebar.tsx): `src/component/sidebar/Sidebar.tsx`
- [Right sidebar](https://github.com/davo999666/chess_next_ts/blob/main/src/component/sidebar/SidebarRight.tsx): `src/component/sidebar/SidebarRight.tsx`

### Board interaction

- [Interactive board](https://github.com/davo999666/chess_next_ts/blob/main/src/component/board/Board.tsx): `src/component/board/Board.tsx`
- [Board commands](https://github.com/davo999666/chess_next_ts/blob/main/src/hooks/useBoardHandlers.ts): `src/hooks/useBoardHandlers.ts`
- [Move history](https://github.com/davo999666/chess_next_ts/blob/main/src/context/HistoryContext.tsx): `src/context/HistoryContext.tsx`
- [Board grid](https://github.com/davo999666/chess_next_ts/blob/main/src/component/board/BoardGrid.tsx): `src/component/board/BoardGrid.tsx`
- [Drag layer](https://github.com/davo999666/chess_next_ts/blob/main/src/component/board/DragLayer.tsx): `src/component/board/DragLayer.tsx`

### Teaching visuals

- [Move arrows](https://github.com/davo999666/chess_next_ts/blob/main/src/component/MoveArrows.tsx): `src/component/MoveArrows.tsx`
- [Square circles](https://github.com/davo999666/chess_next_ts/blob/main/src/component/RightClickCircles.tsx): `src/component/RightClickCircles.tsx`
- [Arrow drawing](https://github.com/davo999666/chess_next_ts/blob/main/src/hooks/useArrowDrawing.ts): `src/hooks/useArrowDrawing.ts`

### Chess logic

- [Legal moves](https://github.com/davo999666/chess_next_ts/blob/main/src/utils/legalMoves.ts): `src/utils/legalMoves.ts`
- [Pseudo moves](https://github.com/davo999666/chess_next_ts/blob/main/src/utils/pseudoMovesForPiece.ts): `src/utils/pseudoMovesForPiece.ts`
- [Board utilities](https://github.com/davo999666/chess_next_ts/blob/main/src/utils/boardUtils.ts): `src/utils/boardUtils.ts`
- [Chess constants](https://github.com/davo999666/chess_next_ts/blob/main/src/utils/constant.ts): `src/utils/constant.ts`

### Pieces and layout

- [Piece pools](https://github.com/davo999666/chess_next_ts/blob/main/src/component/PiecePools.tsx): `src/component/PiecePools.tsx`
- [Piece image](https://github.com/davo999666/chess_next_ts/blob/main/src/component/PieceImage.tsx): `src/component/PieceImage.tsx`
- [Piece mapping](https://github.com/davo999666/chess_next_ts/blob/main/src/utils/pieceMap.ts): `src/utils/pieceMap.ts`
- [Responsive sizing](https://github.com/davo999666/chess_next_ts/blob/main/src/utils/classNameSize.ts): `src/utils/classNameSize.ts`

### Other components

- **Teacher**

## Connections

- Teacher → Lesson page: opens lesson (evidence: `README.md`)
- Lesson page → Interactive board: renders (evidence: `src/app/page.tsx`)
- Lesson page → Board controls: renders (evidence: `src/app/page.tsx`)
- Lesson page → Right sidebar: renders (evidence: `src/app/page.tsx`)
- Board controls → Board commands: invokes commands (evidence: `src/component/sidebar/Sidebar.tsx`)
- Interactive board → Board commands: registers commands (evidence: `src/component/board/Board.tsx`)
- Interactive board → Move history: uses history (evidence: `src/component/board/Board.tsx`)
- Interactive board → Board grid: renders grid (evidence: `src/component/board/Board.tsx`)
- Interactive board → Piece pools: renders pools (evidence: `src/component/board/Board.tsx`)
- Interactive board → Move arrows: renders annotations (evidence: `src/component/board/Board.tsx`)
- Interactive board → Square circles: renders annotations (evidence: `src/component/board/Board.tsx`)
- Interactive board → Arrow drawing: tracks drawing (evidence: `src/component/board/Board.tsx`)
- Interactive board → Legal moves: requests moves (evidence: `src/component/board/Board.tsx`)
- Interactive board → Board utilities: flips board (evidence: `src/component/board/Board.tsx`)
- Board grid → Piece image: renders pieces (evidence: `src/component/board/BoardGrid.tsx`)
- Board grid → Drag layer: renders drag layer (evidence: `src/component/board/BoardGrid.tsx`)
- Drag layer → Piece image: renders piece (evidence: `src/component/board/DragLayer.tsx`)
- Piece pools → Piece mapping: uses piece images (evidence: `src/component/PiecePools.tsx`)
- Piece pools → Responsive sizing: uses sizing (evidence: `src/component/PiecePools.tsx`)
- Piece image → Piece mapping: resolves image (evidence: `src/component/PieceImage.tsx`)
- Piece image → Responsive sizing: uses sizing (evidence: `src/component/PieceImage.tsx`)
- Legal moves → Pseudo moves: filters moves (evidence: `src/utils/legalMoves.ts`)
- Legal moves → Chess constants: uses rules (evidence: `src/utils/legalMoves.ts`)
- Pseudo moves → Chess constants: checks bounds (evidence: `src/utils/pseudoMovesForPiece.ts`)
- Board utilities → Piece mapping: types board (evidence: `src/utils/boardUtils.ts`)
