# flkdpis/xiangqi architecture

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

- Interactive diagram: https://gitdiagram.com/flkdpis/xiangqi
- Repository: https://github.com/flkdpis/xiangqi
- Video tour (about a minute): https://gitdiagram.com/flkdpis/xiangqi/video

## Overview

Xiangqi is a pygame-based Chinese chess game, though the README marks this version obsolete. Its runtime starts in main.py, which initializes the game, creates the pieces and handles mouse-driven turns and captures. Piece movement and board rules live alongside rendering and game control in that same large file; variables.py supplies board, piece, and movement definitions, while functions.py provides occupancy and distance helpers. The excerpts show the core game loop but not all rendering or rules, so the graph stays at the evidenced module boundaries.

Main entry points: [`Xiangqi/main.py`](https://github.com/flkdpis/xiangqi/blob/main/Xiangqi/main.py) (Game loop and UI), [`Xiangqi/variables.py`](https://github.com/flkdpis/xiangqi/blob/main/Xiangqi/variables.py) (Board and rule data), [`Xiangqi/functions.py`](https://github.com/flkdpis/xiangqi/blob/main/Xiangqi/functions.py) (Move helpers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game runtime"]
  node_game["Game loop and UI<br/>[main.py]"]
  node_pieces["Pieces and movement<br/>[main.py]"]
  node_board["Board rendering<br/>[main.py]"]
end

subgraph group_rules["Game data and helpers"]
  node_definitions["Board and rule data<br/>[variables.py]"]
  node_helpers["Move helpers<br/>[functions.py]"]
end

node_player(("Player"))

node_player -->|"starts and plays"| node_game
node_game -->|"loads definitions"| node_definitions
node_game -->|"creates pieces"| node_pieces
node_game -->|"calls helpers"| node_helpers
node_game -.->|"draws board"| node_board
node_pieces -.->|"uses move data"| node_definitions

click node_game "https://github.com/flkdpis/xiangqi/blob/main/Xiangqi/main.py"
click node_pieces "https://github.com/flkdpis/xiangqi/blob/main/Xiangqi/main.py"
click node_board "https://github.com/flkdpis/xiangqi/blob/main/Xiangqi/main.py"
click node_definitions "https://github.com/flkdpis/xiangqi/blob/main/Xiangqi/variables.py"
click node_helpers "https://github.com/flkdpis/xiangqi/blob/main/Xiangqi/functions.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_game,node_pieces,node_board toneBlue
class node_definitions,node_helpers toneAmber
class node_player toneIndigo
```

## Components

### Game runtime

- [Game loop and UI](https://github.com/flkdpis/xiangqi/blob/main/Xiangqi/main.py): `Xiangqi/main.py`
- [Pieces and movement](https://github.com/flkdpis/xiangqi/blob/main/Xiangqi/main.py): `Xiangqi/main.py`
- [Board rendering](https://github.com/flkdpis/xiangqi/blob/main/Xiangqi/main.py): `Xiangqi/main.py`

### Game data and helpers

- [Board and rule data](https://github.com/flkdpis/xiangqi/blob/main/Xiangqi/variables.py): `Xiangqi/variables.py`
- [Move helpers](https://github.com/flkdpis/xiangqi/blob/main/Xiangqi/functions.py): `Xiangqi/functions.py`

### Other components

- **Player**

## Connections

- Player → Game loop and UI: starts and plays (evidence: `README.md`)
- Game loop and UI → Board and rule data: loads definitions (evidence: `Xiangqi/main.py`)
- Game loop and UI → Pieces and movement: creates pieces (evidence: `Xiangqi/main.py`)
- Game loop and UI → Move helpers: calls helpers (evidence: `Xiangqi/main.py`)
- Game loop and UI → Board rendering: draws board (evidence: `Xiangqi/main.py`)
- Pieces and movement → Board and rule data: uses move data (evidence: `Xiangqi/main.py`)
