# saadzahem/textual-chess architecture

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

## Overview

textual-chess is a terminal chess game built with Textual. A player launches the app, chooses a bot, and enters a game screen with a chessboard and player/move information; the board handles moves and can request bot moves. The game screen also exposes options such as takeback, draw claims, board flipping, and FEN copying. Bot strategies include random, greedy, and minimax. The README gives no feature overview, so these capabilities and relationships are based on the sampled source; unsampled integrations are not inferred.

Main entry points: [`src/textual_chess/chesspage.py`](https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/chesspage.py) (Game screen), [`src/textual_chess/app.py`](https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/app.py) (Chess app), [`src/textual_chess/chessboard.py`](https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/chessboard.py) (Chessboard), [`src/textual_chess/bot.py`](https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/bot.py) (Bot strategies)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Terminal interface"]
  node_app["Chess app<br/>[app.py]"]
  node_home["Home screen<br/>[app.py]"]
  node_text_utils["Text rendering helper<br/>[utils.py]"]
end

subgraph group_game["Game experience"]
  node_game_screen["Game screen<br/>[chesspage.py]"]
  node_board["Chessboard<br/>[chessboard.py]"]
  node_game_info["Moves and info<br/>[chesspage.py]"]
  node_chess_player["Player display<br/>[chessplayer.py]"]
end

subgraph group_bots["Bot strategies"]
  node_bot_factory["Bot selection<br/>[bot.py]"]
  node_bot["Bot strategies<br/>[bot.py]"]
  node_minimax["Minimax search<br/>[minimax.py]"]
end

subgraph group_dialogs["Options dialogs"]
  node_options["Options dialog<br/>[dialog.py]"]
  node_dialog_base["Modal base<br/>[modal.py]"]
end

subgraph group_rules["Chess support"]
  node_board_constants["Board styling<br/>[constants.py]"]
  node_better_board["Repetition tracking<br/>[_chess.py]"]
end

node_player(("Player"))

node_player -->|"launches"| node_app
node_app -->|"shows"| node_home
node_app -->|"opens"| node_game_screen
node_home -->|"opens"| node_options
node_game_screen -->|"selects bot"| node_bot_factory
node_bot_factory -->|"creates"| node_bot
node_game_screen -->|"creates"| node_board
node_game_screen -->|"composes"| node_game_info
node_game_info -->|"displays"| node_chess_player
node_board -->|"requests move"| node_bot
node_bot -->|"searches with"| node_minimax
node_game_screen -->|"opens"| node_options
node_options -->|"inherits"| node_dialog_base
node_board -->|"uses styling"| node_board_constants
node_game_info -->|"formats text"| node_text_utils

click node_app "https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/app.py"
click node_home "https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/app.py"
click node_game_screen "https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/chesspage.py"
click node_board "https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/chessboard.py"
click node_game_info "https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/chesspage.py"
click node_chess_player "https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/chessplayer.py"
click node_options "https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/dialog.py"
click node_dialog_base "https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/modal.py"
click node_bot_factory "https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/bot.py"
click node_bot "https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/bot.py"
click node_minimax "https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/minimax.py"
click node_board_constants "https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/constants.py"
click node_better_board "https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/_chess.py"
click node_text_utils "https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/utils.py"

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_text_utils toneBlue
class node_game_screen,node_board,node_game_info,node_chess_player toneAmber
class node_bot_factory,node_bot,node_minimax toneMint
class node_options,node_dialog_base toneRose
class node_board_constants,node_better_board,node_player toneIndigo
```

## Components

### Terminal interface

- [Chess app](https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/app.py): `src/textual_chess/app.py`
- [Home screen](https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/app.py): `src/textual_chess/app.py`
- [Text rendering helper](https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/utils.py): `src/textual_chess/utils.py`

### Game experience

- [Game screen](https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/chesspage.py): `src/textual_chess/chesspage.py`
- [Chessboard](https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/chessboard.py): `src/textual_chess/chessboard.py`
- [Moves and info](https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/chesspage.py): `src/textual_chess/chesspage.py`
- [Player display](https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/chessplayer.py): `src/textual_chess/chessplayer.py`

### Bot strategies

- [Bot selection](https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/bot.py): `src/textual_chess/bot.py`
- [Bot strategies](https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/bot.py): `src/textual_chess/bot.py`
- [Minimax search](https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/minimax.py): `src/textual_chess/minimax.py`

### Options dialogs

- [Options dialog](https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/dialog.py): `src/textual_chess/dialog.py`
- [Modal base](https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/modal.py): `src/textual_chess/modal.py`

### Chess support

- [Board styling](https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/constants.py): `src/textual_chess/constants.py`
- [Repetition tracking](https://github.com/saadzahem/textual-chess/blob/main/src/textual_chess/_chess.py): `src/textual_chess/_chess.py`

### Other components

- **Player**

## Connections

- Player → Chess app: launches (evidence: `src/textual_chess/app.py`)
- Chess app → Home screen: shows (evidence: `src/textual_chess/app.py`)
- Chess app → Game screen: opens (evidence: `src/textual_chess/app.py`)
- Home screen → Options dialog: opens (evidence: `src/textual_chess/app.py`)
- Game screen → Bot selection: selects bot (evidence: `src/textual_chess/chesspage.py`)
- Bot selection → Bot strategies: creates (evidence: `src/textual_chess/bot.py`)
- Game screen → Chessboard: creates (evidence: `src/textual_chess/chesspage.py`)
- Game screen → Moves and info: composes (evidence: `src/textual_chess/chesspage.py`)
- Moves and info → Player display: displays (evidence: `src/textual_chess/chesspage.py`)
- Chessboard → Bot strategies: requests move (evidence: `src/textual_chess/chessboard.py`)
- Bot strategies → Minimax search: searches with (evidence: `src/textual_chess/bot.py`)
- Game screen → Options dialog: opens (evidence: `src/textual_chess/chesspage.py`)
- Options dialog → Modal base: inherits (evidence: `src/textual_chess/dialog.py`)
- Chessboard → Board styling: uses styling (evidence: `src/textual_chess/chessboard.py`)
- Moves and info → Text rendering helper: formats text (evidence: `src/textual_chess/chesspage.py`)
