# kenmangubat/chessiq architecture

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

- Interactive diagram: https://gitdiagram.com/kenmangubat/chessiq
- Repository: https://github.com/kenmangubat/chessiq

## Overview

Chess Ken is a desktop chess game centered on choosing an opponent, playing a timed or untimed match, and receiving bot reactions and audio feedback. Its runtime flow runs from the application screen manager through the game screen to chess rules and bot move selection, with Stockfish analysis and learned style informing the bot. Separate calibration modules build opening-book and style data from archived games. Source excerpts establish the main runtime components; unsampled calibration and screen details are represented only where the source index or file tree supports them.

Main entry points: [`screens/game.py`](https://github.com/kenmangubat/chessiq/blob/main/screens/game.py) (Game Screen), [`main.py`](https://github.com/kenmangubat/chessiq/blob/main/main.py) (Screen Manager), [`bots/ken_bot.py`](https://github.com/kenmangubat/chessiq/blob/main/bots/ken_bot.py) (Ken Bot), [`calibration/style_analyzer.py`](https://github.com/kenmangubat/chessiq/blob/main/calibration/style_analyzer.py) (Style Analyzer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application UI"]
  node_main["Screen Manager<br/>[main.py]"]
  node_dashboard["Dashboard<br/>[dashboard.py]"]
  node_opponent["Opponent Selection<br/>[opponent_select.py]"]
  node_settings["Settings<br/>[settings.py]"]
  node_base["Screen Base<br/>[base_screen.py]"]
end

subgraph group_gameplay["Chess Gameplay"]
  node_game["Game Screen<br/>[game.py]"]
  node_chess["Chess Rules<br/>[chess_game.py]"]
  node_board["Animated Board<br/>[animated_board.py]"]
end

subgraph group_bot["Bot Intelligence"]
  node_bot["Ken Bot<br/>[ken_bot.py]"]
  node_engine["Stockfish Wrapper"]
end

subgraph group_calibration["Bot Calibration"]
  node_style["Style Analyzer<br/>[style_analyzer.py]"]
  node_book["Opening Book Builder<br/>[build_book.py]"]
  node_calibrate["Bot Calibration<br/>[calibrate_bots.py]"]
  node_archives["Game Archives"]
  node_bookdata[("Opening Book<br/>[ken_book.db]")]
  node_profile["Style Profile"]
end

subgraph group_presentation["Game Presentation"]
  node_button["Buttons<br/>[button.py]"]
  node_sound["Sound Manager<br/>[sound_manager.py]"]
  node_speech["Speech Bubble<br/>[speech_bubble.py]"]
  node_assets["Audio Assets"]
end

node_player(("Player"))
node_stockfish["Stockfish Engine"]

node_player -->|"uses"| node_main
node_main -->|"routes to"| node_dashboard
node_main -->|"routes to"| node_game
node_main -->|"routes to"| node_opponent
node_main -->|"routes to"| node_settings
node_dashboard -->|"renders"| node_button
node_opponent -->|"renders"| node_button
node_settings -->|"renders"| node_button
node_game -->|"updates game"| node_chess
node_game -->|"requests moves"| node_bot
node_game -->|"renders position"| node_board
node_game -->|"plays effects"| node_sound
node_game -->|"shows reactions"| node_speech
node_board -->|"reads position"| node_chess
node_bot -->|"analyzes moves"| node_engine
node_engine -->|"sends UCI"| node_stockfish
node_bot -->|"uses profile"| node_style
node_bot -->|"reads book"| node_bookdata
node_style -->|"reads game data"| node_bookdata
node_book -->|"ingests games"| node_archives
node_book -->|"uses analysis"| node_style
node_style -.->|"writes profile"| node_profile
node_calibrate -->|"benchmarks"| node_bot
node_calibrate -->|"evaluates against"| node_engine
node_sound -->|"loads audio"| node_assets
node_speech -.->|"syncs voice"| node_sound

click node_main "https://github.com/kenmangubat/chessiq/blob/main/main.py"
click node_dashboard "https://github.com/kenmangubat/chessiq/blob/main/screens/dashboard.py"
click node_opponent "https://github.com/kenmangubat/chessiq/blob/main/screens/opponent_select.py"
click node_settings "https://github.com/kenmangubat/chessiq/blob/main/screens/settings.py"
click node_base "https://github.com/kenmangubat/chessiq/blob/main/screens/base_screen.py"
click node_game "https://github.com/kenmangubat/chessiq/blob/main/screens/game.py"
click node_chess "https://github.com/kenmangubat/chessiq/blob/main/chess_logic/chess_game.py"
click node_board "https://github.com/kenmangubat/chessiq/blob/main/ui/animated_board.py"
click node_bot "https://github.com/kenmangubat/chessiq/blob/main/bots/ken_bot.py"
click node_engine "https://github.com/kenmangubat/chessiq/blob/main/engine/stockfish_engine.py"
click node_style "https://github.com/kenmangubat/chessiq/blob/main/calibration/style_analyzer.py"
click node_book "https://github.com/kenmangubat/chessiq/blob/main/calibration/build_book.py"
click node_calibrate "https://github.com/kenmangubat/chessiq/blob/main/calibration/calibrate_bots.py"
click node_archives "https://github.com/kenmangubat/chessiq/tree/main/data"
click node_bookdata "https://github.com/kenmangubat/chessiq/blob/main/data/ken_book.db"
click node_profile "https://github.com/kenmangubat/chessiq/blob/main/data/ken_style_profile.json"
click node_button "https://github.com/kenmangubat/chessiq/blob/main/ui/button.py"
click node_sound "https://github.com/kenmangubat/chessiq/blob/main/ui/sound_manager.py"
click node_speech "https://github.com/kenmangubat/chessiq/blob/main/ui/speech_bubble.py"
click node_assets "https://github.com/kenmangubat/chessiq/tree/main/assets/sounds"

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_main,node_dashboard,node_opponent,node_settings,node_base toneBlue
class node_game,node_chess,node_board toneAmber
class node_bot,node_engine toneMint
class node_style,node_book,node_calibrate,node_archives,node_bookdata,node_profile toneRose
class node_button,node_sound,node_speech,node_assets,node_player,node_stockfish toneIndigo
```

## Components

### Application UI

- [Screen Manager](https://github.com/kenmangubat/chessiq/blob/main/main.py): `main.py`
- [Dashboard](https://github.com/kenmangubat/chessiq/blob/main/screens/dashboard.py): `screens/dashboard.py`
- [Opponent Selection](https://github.com/kenmangubat/chessiq/blob/main/screens/opponent_select.py): `screens/opponent_select.py`
- [Settings](https://github.com/kenmangubat/chessiq/blob/main/screens/settings.py): `screens/settings.py`
- [Screen Base](https://github.com/kenmangubat/chessiq/blob/main/screens/base_screen.py): `screens/base_screen.py`

### Chess Gameplay

- [Game Screen](https://github.com/kenmangubat/chessiq/blob/main/screens/game.py): `screens/game.py`
- [Chess Rules](https://github.com/kenmangubat/chessiq/blob/main/chess_logic/chess_game.py): `chess_logic/chess_game.py`
- [Animated Board](https://github.com/kenmangubat/chessiq/blob/main/ui/animated_board.py): `ui/animated_board.py`

### Bot Intelligence

- [Ken Bot](https://github.com/kenmangubat/chessiq/blob/main/bots/ken_bot.py): `bots/ken_bot.py`
- [Stockfish Wrapper](https://github.com/kenmangubat/chessiq/blob/main/engine/stockfish_engine.py): `engine/stockfish_engine.py`

### Bot Calibration

- [Style Analyzer](https://github.com/kenmangubat/chessiq/blob/main/calibration/style_analyzer.py): `calibration/style_analyzer.py`
- [Opening Book Builder](https://github.com/kenmangubat/chessiq/blob/main/calibration/build_book.py): `calibration/build_book.py`
- [Bot Calibration](https://github.com/kenmangubat/chessiq/blob/main/calibration/calibrate_bots.py): `calibration/calibrate_bots.py`
- [Game Archives](https://github.com/kenmangubat/chessiq/tree/main/data): `data`
- [Opening Book](https://github.com/kenmangubat/chessiq/blob/main/data/ken_book.db): `data/ken_book.db`
- [Style Profile](https://github.com/kenmangubat/chessiq/blob/main/data/ken_style_profile.json): `data/ken_style_profile.json`

### Game Presentation

- [Buttons](https://github.com/kenmangubat/chessiq/blob/main/ui/button.py): `ui/button.py`
- [Sound Manager](https://github.com/kenmangubat/chessiq/blob/main/ui/sound_manager.py): `ui/sound_manager.py`
- [Speech Bubble](https://github.com/kenmangubat/chessiq/blob/main/ui/speech_bubble.py): `ui/speech_bubble.py`
- [Audio Assets](https://github.com/kenmangubat/chessiq/tree/main/assets/sounds): `assets/sounds`

### Other components

- **Player**
- **Stockfish Engine**

## Connections

- Player → Screen Manager: uses (evidence: `main.py`)
- Screen Manager → Dashboard: routes to (evidence: `main.py`)
- Screen Manager → Game Screen: routes to (evidence: `main.py`)
- Screen Manager → Opponent Selection: routes to (evidence: `main.py`)
- Screen Manager → Settings: routes to (evidence: `main.py`)
- Dashboard → Buttons: renders (evidence: `screens/dashboard.py`)
- Opponent Selection → Buttons: renders (evidence: `screens/opponent_select.py`)
- Settings → Buttons: renders (evidence: `screens/settings.py`)
- Game Screen → Chess Rules: updates game (evidence: `screens/game.py`)
- Game Screen → Ken Bot: requests moves (evidence: `screens/game.py`)
- Game Screen → Animated Board: renders position (evidence: `screens/game.py`)
- Game Screen → Sound Manager: plays effects (evidence: `screens/game.py`)
- Game Screen → Speech Bubble: shows reactions (evidence: `screens/game.py`)
- Animated Board → Chess Rules: reads position (evidence: `ui/animated_board.py`)
- Ken Bot → Stockfish Wrapper: analyzes moves (evidence: `bots/ken_bot.py`)
- Stockfish Wrapper → Stockfish Engine: sends UCI (evidence: `engine/stockfish_engine.py`)
- Ken Bot → Style Analyzer: uses profile (evidence: `bots/ken_bot.py`)
- Ken Bot → Opening Book: reads book (evidence: `bots/ken_bot.py`)
- Style Analyzer → Opening Book: reads game data (evidence: `calibration/style_analyzer.py`)
- Opening Book Builder → Game Archives: ingests games (evidence: `calibration/build_book.py`)
- Opening Book Builder → Style Analyzer: uses analysis (evidence: `calibration/build_book.py`)
- Style Analyzer → Style Profile: writes profile
- Bot Calibration → Ken Bot: benchmarks (evidence: `calibration/calibrate_bots.py`)
- Bot Calibration → Stockfish Wrapper: evaluates against (evidence: `calibration/calibrate_bots.py`)
- Sound Manager → Audio Assets: loads audio (evidence: `ui/sound_manager.py`)
- Speech Bubble → Sound Manager: syncs voice
