# magomeddr/chessmovepred architecture

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

- Interactive diagram: https://gitdiagram.com/magomeddr/chessmovepred
- Repository: https://github.com/magomeddr/chessmovepred

## Overview

This is a command-line chess AI for training a move-prediction model, fine-tuning it on a player’s games, and playing against it. The main workflow takes a human UCI move, updates the chess position, asks the prediction interface for a legal AI move, and displays the result. Training and personalization share CSV-based position preparation, action encoding, and the neural model. The README is empty; unsampled capabilities are not inferred, and edges below are supported by the shown source.

Main entry points: [`src/personalize.py`](https://github.com/magomeddr/chessmovepred/blob/main/src/personalize.py) (Player fine-tuning), [`src/train.py`](https://github.com/magomeddr/chessmovepred/blob/main/src/train.py) (Model training), [`src/interface.py`](https://github.com/magomeddr/chessmovepred/blob/main/src/interface.py) (Prediction interface), [`main.py`](https://github.com/magomeddr/chessmovepred/blob/main/main.py) (CLI and game)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User workflow"]
  node_cli["CLI and game<br/>[main.py]"]
end

subgraph group_learning["Model learning"]
  node_train["Model training<br/>[train.py]"]
  node_personalize["Player fine-tuning<br/>[personalize.py]"]
  node_dataset["Chess data loader<br/>[data.py]"]
  node_encoding["Board and action encoding<br/>[utils.py]"]
  node_network["Policy network<br/>[model.py]"]
end

subgraph group_inference["Move prediction"]
  node_interface["Prediction interface<br/>[interface.py]"]
end

node_player(("Player"))
node_csv["Training games"]
node_weights["Model weights"]

node_player -->|"chooses action"| node_cli
node_cli -->|"starts training"| node_train
node_cli -->|"starts fine-tuning"| node_personalize
node_cli -->|"loads model"| node_interface
node_cli -->|"requests move"| node_interface
node_dataset -->|"reads positions"| node_csv
node_dataset -->|"encodes positions"| node_encoding
node_train -->|"loads batches"| node_dataset
node_train -->|"trains"| node_network
node_train -->|"uses action size"| node_encoding
node_train -->|"saves weights"| node_weights
node_personalize -->|"loads base weights"| node_weights
node_personalize -->|"loads batches"| node_dataset
node_personalize -->|"fine-tunes"| node_network
node_personalize -->|"uses logit mask"| node_train
node_personalize -->|"uses action size"| node_encoding
node_personalize -->|"saves weights"| node_weights
node_interface -->|"runs inference"| node_network
node_interface -->|"encodes position"| node_encoding
node_interface -->|"uses logit mask"| node_train
node_interface -->|"loads weights"| node_weights

click node_cli "https://github.com/magomeddr/chessmovepred/blob/main/main.py"
click node_train "https://github.com/magomeddr/chessmovepred/blob/main/src/train.py"
click node_personalize "https://github.com/magomeddr/chessmovepred/blob/main/src/personalize.py"
click node_dataset "https://github.com/magomeddr/chessmovepred/blob/main/src/data.py"
click node_csv "https://github.com/magomeddr/chessmovepred/blob/main/data/fens_training_set.csv"
click node_encoding "https://github.com/magomeddr/chessmovepred/blob/main/src/utils.py"
click node_network "https://github.com/magomeddr/chessmovepred/blob/main/src/model.py"
click node_interface "https://github.com/magomeddr/chessmovepred/blob/main/src/interface.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_cli toneBlue
class node_train,node_personalize,node_dataset,node_encoding,node_network toneAmber
class node_interface toneMint
class node_player,node_weights toneIndigo
class node_csv toneTeal
```

## Components

### User workflow

- [CLI and game](https://github.com/magomeddr/chessmovepred/blob/main/main.py): `main.py`

### Model learning

- [Model training](https://github.com/magomeddr/chessmovepred/blob/main/src/train.py): `src/train.py`
- [Player fine-tuning](https://github.com/magomeddr/chessmovepred/blob/main/src/personalize.py): `src/personalize.py`
- [Chess data loader](https://github.com/magomeddr/chessmovepred/blob/main/src/data.py): `src/data.py`
- [Board and action encoding](https://github.com/magomeddr/chessmovepred/blob/main/src/utils.py): `src/utils.py`
- [Policy network](https://github.com/magomeddr/chessmovepred/blob/main/src/model.py): `src/model.py`

### Move prediction

- [Prediction interface](https://github.com/magomeddr/chessmovepred/blob/main/src/interface.py): `src/interface.py`

### Other components

- **Player**
- [Training games](https://github.com/magomeddr/chessmovepred/blob/main/data/fens_training_set.csv): `data/fens_training_set.csv`
- **Model weights**

## Connections

- Player → CLI and game: chooses action (evidence: `main.py`)
- CLI and game → Model training: starts training (evidence: `main.py`)
- CLI and game → Player fine-tuning: starts fine-tuning (evidence: `main.py`)
- CLI and game → Prediction interface: loads model (evidence: `main.py`)
- CLI and game → Prediction interface: requests move (evidence: `main.py`)
- Chess data loader → Training games: reads positions (evidence: `src/data.py`)
- Chess data loader → Board and action encoding: encodes positions (evidence: `src/data.py`)
- Model training → Chess data loader: loads batches (evidence: `src/train.py`)
- Model training → Policy network: trains (evidence: `src/train.py`)
- Model training → Board and action encoding: uses action size (evidence: `src/train.py`)
- Model training → Model weights: saves weights (evidence: `src/train.py`)
- Player fine-tuning → Model weights: loads base weights (evidence: `src/personalize.py`)
- Player fine-tuning → Chess data loader: loads batches (evidence: `src/personalize.py`)
- Player fine-tuning → Policy network: fine-tunes (evidence: `src/personalize.py`)
- Player fine-tuning → Model training: uses logit mask (evidence: `src/personalize.py`)
- Player fine-tuning → Board and action encoding: uses action size (evidence: `src/personalize.py`)
- Player fine-tuning → Model weights: saves weights (evidence: `src/personalize.py`)
- Prediction interface → Policy network: runs inference (evidence: `src/interface.py`)
- Prediction interface → Board and action encoding: encodes position (evidence: `src/interface.py`)
- Prediction interface → Model training: uses logit mask (evidence: `src/interface.py`)
- Prediction interface → Model weights: loads weights (evidence: `src/interface.py`)
