# husnain-official/tabiya_2.0 architecture

> Architecture diagram of the GitHub repository husnain-official/tabiya_2.0, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/husnain-official/tabiya_2.0
- Repository: https://github.com/husnain-official/tabiya_2.0

## Overview

Tabiya is a Python chess game combining a from-scratch rules engine, a minimax bot, and a Pygame interface. Players choose local two-player or bot play, interact with the board, and receive rendered game and end-state feedback; the manager coordinates moves and asynchronous bot search. The graph separates engine state, legal-move rules, evaluation, bot search, and UI responsibilities. Some detailed UI and engine internals are documented but not fully excerpted, so those links rely on README statements rather than unsampled implementation claims.

Main entry points: [`Engine/chess_engine.py`](https://github.com/husnain-official/tabiya_2.0/blob/main/Engine/chess_engine.py) (Engine state), [`Game_loop/main.py`](https://github.com/husnain-official/tabiya_2.0/blob/main/Game_loop/main.py) (Game manager), [`Engine/chess_bot.py`](https://github.com/husnain-official/tabiya_2.0/blob/main/Engine/chess_bot.py) (Chess bot), [`Front_end/board.py`](https://github.com/husnain-official/tabiya_2.0/blob/main/Front_end/board.py) (Board visuals)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Game application"]
  node_game_loop["Game loop<br/>[main.py]"]
  node_manager["Game manager<br/>[main.py]"]
  node_menu["Game menu<br/>[main.py]"]
  node_resource_paths["Resource paths<br/>[resource_paths.py]"]
end

subgraph group_engine["Chess engine"]
  node_engine_state["Engine state<br/>[chess_engine.py]"]
  node_board_state["Board state<br/>[chess_engine.py]"]
  node_move_rules["Move rules<br/>[chess_engine.py]"]
  node_move_history["Move history<br/>[chess_engine.py]"]
  node_game_status["Game status<br/>[chess_engine.py]"]
  node_evaluation["Position evaluation<br/>[chess_engine.py]"]
  node_pst_data["Piece-square tables<br/>[resources.py]"]
end

subgraph group_bot["Bot search"]
  node_bot["Chess bot<br/>[chess_bot.py]"]
end

subgraph group_ui["Pygame interface"]
  node_board_ui["Board visuals<br/>[board.py]"]
  node_game_over_ui["Game overlays<br/>[board.py]"]
  node_assets["Game assets"]
end

node_player(("Player"))

node_player -->|"interacts with"| node_game_loop
node_game_loop -->|"shows"| node_menu
node_menu -->|"selects mode"| node_manager
node_game_loop -->|"polls search"| node_manager
node_manager -->|"creates"| node_engine_state
node_manager -->|"creates"| node_board_ui
node_manager -->|"starts search"| node_bot
node_manager -->|"applies bot move"| node_engine_state
node_manager -->|"handles player moves"| node_engine_state
node_engine_state -->|"creates"| node_board_state
node_engine_state -->|"creates"| node_move_history
node_engine_state -->|"creates"| node_move_rules
node_move_rules -->|"queries"| node_board_state
node_engine_state -->|"detects outcomes"| node_game_status
node_engine_state -->|"evaluates position"| node_evaluation
node_evaluation -->|"uses tables"| node_pst_data
node_bot -->|"searches positions"| node_engine_state
node_bot -->|"scores positions"| node_evaluation
node_bot -->|"gets legal moves"| node_move_rules
node_game_loop -->|"renders game"| node_board_ui
node_game_loop -->|"renders outcomes"| node_game_over_ui
node_board_ui -->|"resolves assets"| node_resource_paths
node_menu -->|"resolves backgrounds"| node_resource_paths
node_resource_paths -->|"locates files"| node_assets
node_board_ui -->|"draws overlays"| node_game_over_ui

click node_game_loop "https://github.com/husnain-official/tabiya_2.0/blob/main/Game_loop/main.py"
click node_manager "https://github.com/husnain-official/tabiya_2.0/blob/main/Game_loop/main.py"
click node_menu "https://github.com/husnain-official/tabiya_2.0/blob/main/Game_loop/main.py"
click node_board_ui "https://github.com/husnain-official/tabiya_2.0/blob/main/Front_end/board.py"
click node_game_over_ui "https://github.com/husnain-official/tabiya_2.0/blob/main/Front_end/board.py"
click node_engine_state "https://github.com/husnain-official/tabiya_2.0/blob/main/Engine/chess_engine.py"
click node_board_state "https://github.com/husnain-official/tabiya_2.0/blob/main/Engine/chess_engine.py"
click node_move_rules "https://github.com/husnain-official/tabiya_2.0/blob/main/Engine/chess_engine.py"
click node_move_history "https://github.com/husnain-official/tabiya_2.0/blob/main/Engine/chess_engine.py"
click node_game_status "https://github.com/husnain-official/tabiya_2.0/blob/main/Engine/chess_engine.py"
click node_evaluation "https://github.com/husnain-official/tabiya_2.0/blob/main/Engine/chess_engine.py"
click node_pst_data "https://github.com/husnain-official/tabiya_2.0/blob/main/Engine/resources.py"
click node_bot "https://github.com/husnain-official/tabiya_2.0/blob/main/Engine/chess_bot.py"
click node_resource_paths "https://github.com/husnain-official/tabiya_2.0/blob/main/resource_paths.py"
click node_assets "https://github.com/husnain-official/tabiya_2.0/tree/main/Assets"

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_game_loop,node_manager,node_menu,node_resource_paths toneBlue
class node_engine_state,node_board_state,node_move_rules,node_move_history,node_game_status,node_evaluation,node_pst_data toneAmber
class node_bot toneMint
class node_board_ui,node_game_over_ui,node_assets toneRose
class node_player toneIndigo
```

## Components

### Game application

- [Game loop](https://github.com/husnain-official/tabiya_2.0/blob/main/Game_loop/main.py): `Game_loop/main.py`
- [Game manager](https://github.com/husnain-official/tabiya_2.0/blob/main/Game_loop/main.py): `Game_loop/main.py`
- [Game menu](https://github.com/husnain-official/tabiya_2.0/blob/main/Game_loop/main.py): `Game_loop/main.py`
- [Resource paths](https://github.com/husnain-official/tabiya_2.0/blob/main/resource_paths.py): `resource_paths.py`

### Chess engine

- [Engine state](https://github.com/husnain-official/tabiya_2.0/blob/main/Engine/chess_engine.py): `Engine/chess_engine.py`
- [Board state](https://github.com/husnain-official/tabiya_2.0/blob/main/Engine/chess_engine.py): `Engine/chess_engine.py`
- [Move rules](https://github.com/husnain-official/tabiya_2.0/blob/main/Engine/chess_engine.py): `Engine/chess_engine.py`
- [Move history](https://github.com/husnain-official/tabiya_2.0/blob/main/Engine/chess_engine.py): `Engine/chess_engine.py`
- [Game status](https://github.com/husnain-official/tabiya_2.0/blob/main/Engine/chess_engine.py): `Engine/chess_engine.py`
- [Position evaluation](https://github.com/husnain-official/tabiya_2.0/blob/main/Engine/chess_engine.py): `Engine/chess_engine.py`
- [Piece-square tables](https://github.com/husnain-official/tabiya_2.0/blob/main/Engine/resources.py): `Engine/resources.py`

### Bot search

- [Chess bot](https://github.com/husnain-official/tabiya_2.0/blob/main/Engine/chess_bot.py): `Engine/chess_bot.py`

### Pygame interface

- [Board visuals](https://github.com/husnain-official/tabiya_2.0/blob/main/Front_end/board.py): `Front_end/board.py`
- [Game overlays](https://github.com/husnain-official/tabiya_2.0/blob/main/Front_end/board.py): `Front_end/board.py`
- [Game assets](https://github.com/husnain-official/tabiya_2.0/tree/main/Assets): `Assets`

### Other components

- **Player**

## Connections

- Player → Game loop: interacts with (evidence: `README.md`)
- Game loop → Game menu: shows (evidence: `Game_loop/main.py`)
- Game menu → Game manager: selects mode (evidence: `README.md`)
- Game loop → Game manager: polls search (evidence: `Game_loop/main.py`)
- Game manager → Engine state: creates (evidence: `Game_loop/main.py`)
- Game manager → Board visuals: creates (evidence: `Game_loop/main.py`)
- Game manager → Chess bot: starts search (evidence: `Game_loop/main.py`)
- Game manager → Engine state: applies bot move (evidence: `Game_loop/main.py`)
- Game manager → Engine state: handles player moves (evidence: `Game_loop/main.py`)
- Engine state → Board state: creates (evidence: `Engine/chess_engine.py`)
- Engine state → Move history: creates (evidence: `Engine/chess_engine.py`)
- Engine state → Move rules: creates (evidence: `Engine/chess_engine.py`)
- Move rules → Board state: queries (evidence: `Engine/chess_engine.py`)
- Engine state → Game status: detects outcomes (evidence: `README.md`)
- Engine state → Position evaluation: evaluates position (evidence: `README.md`)
- Position evaluation → Piece-square tables: uses tables (evidence: `Engine/chess_engine.py`)
- Chess bot → Engine state: searches positions (evidence: `Engine/chess_bot.py`)
- Chess bot → Position evaluation: scores positions (evidence: `Engine/chess_bot.py`)
- Chess bot → Move rules: gets legal moves (evidence: `Engine/chess_bot.py`)
- Game loop → Board visuals: renders game (evidence: `Game_loop/main.py`)
- Game loop → Game overlays: renders outcomes (evidence: `Game_loop/main.py`)
- Board visuals → Resource paths: resolves assets (evidence: `Front_end/board.py`)
- Game menu → Resource paths: resolves backgrounds (evidence: `Game_loop/main.py`)
- Resource paths → Game assets: locates files (evidence: `resource_paths.py`)
- Board visuals → Game overlays: draws overlays (evidence: `Front_end/board.py`)
