# chesscom/chess-game architecture

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

- Interactive diagram: https://gitdiagram.com/chesscom/chess-game
- Repository: https://github.com/chesscom/chess-game

## Overview

Chess-Game is a PHP library that represents and manipulates a chess game as an object. The principal workflow is a caller using the game object to initialize a position, submit moves, and inspect or update game state; the sampled class includes move parsing and validation. PEAR.php is also autoloaded as a bundled compatibility file. The excerpts do not establish a direct call from ChessGame to PEAR, so that connection is omitted.

Main entry points: [`src/Chess/Game/ChessGame.php`](https://github.com/chesscom/chess-game/blob/develop/src/Chess/Game/ChessGame.php) (Chess game object)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime library"]
  node_chess_game["Chess game object<br/>[ChessGame.php]"]
  node_pear["PEAR compatibility<br/>[PEAR.php]"]
end

node_caller(("Library caller"))

node_caller -->|"uses game API"| node_chess_game

click node_chess_game "https://github.com/chesscom/chess-game/blob/develop/src/Chess/Game/ChessGame.php"
click node_pear "https://github.com/chesscom/chess-game/blob/develop/PEAR.php"

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_chess_game,node_pear toneBlue
class node_caller toneIndigo
```

## Components

### Runtime library

- [Chess game object](https://github.com/chesscom/chess-game/blob/develop/src/Chess/Game/ChessGame.php): `src/Chess/Game/ChessGame.php`
- [PEAR compatibility](https://github.com/chesscom/chess-game/blob/develop/PEAR.php): `PEAR.php`

### Other components

- **Library caller**

## Connections

- Library caller → Chess game object: uses game API (evidence: `README.md`)
