# joechrisman/ray architecture

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

- Interactive diagram: https://gitdiagram.com/joechrisman/ray
- Repository: https://github.com/joechrisman/ray

## Overview

Ray is a UCI chess engine: a chess GUI or user sends commands, the engine interprets positions and search requests, and returns moves and analysis. Its main runtime domains are protocol handling, board representation and move generation, evaluation, and search. Search combines move ordering and a transposition table; the README also documents perft testing as a capability. The source index identifies module references but does not expose most call sites, so several likely runtime connections are shown as unverified dashed edges rather than asserted calls.

Main entry points: [`Uci.c`](https://github.com/joechrisman/ray/blob/master/Uci.c) (UCI command handling), [`Search.c`](https://github.com/joechrisman/ray/blob/master/Search.c) (Alpha-beta search), [`MoveGen.c`](https://github.com/joechrisman/ray/blob/master/MoveGen.c) (Legal move generation), [`Position.c`](https://github.com/joechrisman/ray/blob/master/Position.c) (Position and game state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_protocol["UCI protocol"]
  node_uci["UCI command handling<br/>[Uci.c]"]
  node_utils["Runtime utilities<br/>[Utils.c]"]
end

subgraph group_chess["Chess state and moves"]
  node_position["Position and game state<br/>[Position.c]"]
  node_notation["Move notation<br/>[Notation.c]"]
  node_move["Move representation<br/>[Move.c]"]
  node_movegen["Legal move generation<br/>[MoveGen.c]"]
  node_attacks["Attack tables<br/>[AttackTables.c]"]
  node_bitboard["Bitboard operations<br/>[Bitboard.c]"]
end

subgraph group_analysis["Position analysis"]
  node_evaluation["Position evaluation<br/>[Eval.c]"]
  node_perft["Perft analysis<br/>[Perft.c]"]
end

subgraph group_search["Search"]
  node_searchmanager["Search orchestration<br/>[SearchManager.c]"]
  node_search["Alpha-beta search<br/>[Search.c]"]
  node_moveorder["Search move ordering<br/>[MoveOrder.c]"]
  node_hashtable[("Transposition table<br/>[HashTable.c]")]
end

node_gui(("Chess GUI / user"))

node_gui -.->|"sends commands"| node_uci
node_uci -.->|"sets position"| node_position
node_uci -.->|"starts search"| node_searchmanager
node_uci -.->|"requests perft"| node_perft
node_searchmanager -.->|"runs search"| node_search
node_search -.->|"generates moves"| node_movegen
node_search -.->|"scores positions"| node_evaluation
node_search -.->|"orders moves"| node_moveorder
node_search -.->|"probes and stores"| node_hashtable
node_position -.->|"applies moves"| node_move
node_movegen -.->|"uses attack data"| node_attacks
node_movegen -.->|"uses bitboards"| node_bitboard
node_uci -.->|"formats moves"| node_notation
node_uci -.->|"returns analysis"| node_gui

click node_uci "https://github.com/joechrisman/ray/blob/master/Uci.c"
click node_position "https://github.com/joechrisman/ray/blob/master/Position.c"
click node_notation "https://github.com/joechrisman/ray/blob/master/Notation.c"
click node_move "https://github.com/joechrisman/ray/blob/master/Move.c"
click node_movegen "https://github.com/joechrisman/ray/blob/master/MoveGen.c"
click node_attacks "https://github.com/joechrisman/ray/blob/master/AttackTables.c"
click node_bitboard "https://github.com/joechrisman/ray/blob/master/Bitboard.c"
click node_evaluation "https://github.com/joechrisman/ray/blob/master/Eval.c"
click node_perft "https://github.com/joechrisman/ray/blob/master/Perft.c"
click node_searchmanager "https://github.com/joechrisman/ray/blob/master/SearchManager.c"
click node_search "https://github.com/joechrisman/ray/blob/master/Search.c"
click node_moveorder "https://github.com/joechrisman/ray/blob/master/MoveOrder.c"
click node_hashtable "https://github.com/joechrisman/ray/blob/master/HashTable.c"
click node_utils "https://github.com/joechrisman/ray/blob/master/Utils.c"

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_uci,node_utils,node_gui toneBlue
class node_position,node_notation,node_move,node_movegen,node_attacks,node_bitboard toneAmber
class node_evaluation,node_perft toneMint
class node_searchmanager,node_search,node_moveorder,node_hashtable toneRose
```

## Components

### UCI protocol

- [UCI command handling](https://github.com/joechrisman/ray/blob/master/Uci.c): `Uci.c`
- [Runtime utilities](https://github.com/joechrisman/ray/blob/master/Utils.c): `Utils.c`

### Chess state and moves

- [Position and game state](https://github.com/joechrisman/ray/blob/master/Position.c): `Position.c`
- [Move notation](https://github.com/joechrisman/ray/blob/master/Notation.c): `Notation.c`
- [Move representation](https://github.com/joechrisman/ray/blob/master/Move.c): `Move.c`
- [Legal move generation](https://github.com/joechrisman/ray/blob/master/MoveGen.c): `MoveGen.c`
- [Attack tables](https://github.com/joechrisman/ray/blob/master/AttackTables.c): `AttackTables.c`
- [Bitboard operations](https://github.com/joechrisman/ray/blob/master/Bitboard.c): `Bitboard.c`

### Position analysis

- [Position evaluation](https://github.com/joechrisman/ray/blob/master/Eval.c): `Eval.c`
- [Perft analysis](https://github.com/joechrisman/ray/blob/master/Perft.c): `Perft.c`

### Search

- [Search orchestration](https://github.com/joechrisman/ray/blob/master/SearchManager.c): `SearchManager.c`
- [Alpha-beta search](https://github.com/joechrisman/ray/blob/master/Search.c): `Search.c`
- [Search move ordering](https://github.com/joechrisman/ray/blob/master/MoveOrder.c): `MoveOrder.c`
- [Transposition table](https://github.com/joechrisman/ray/blob/master/HashTable.c): `HashTable.c`

### Other components

- **Chess GUI / user**

## Connections

- Chess GUI / user → UCI command handling: sends commands (evidence: `README.md`)
- UCI command handling → Position and game state: sets position
- UCI command handling → Search orchestration: starts search
- UCI command handling → Perft analysis: requests perft
- Search orchestration → Alpha-beta search: runs search (evidence: `SearchManager.c`)
- Alpha-beta search → Legal move generation: generates moves (evidence: `Search.c`)
- Alpha-beta search → Position evaluation: scores positions (evidence: `Search.c`)
- Alpha-beta search → Search move ordering: orders moves (evidence: `Search.c`)
- Alpha-beta search → Transposition table: probes and stores (evidence: `Search.c`)
- Position and game state → Move representation: applies moves (evidence: `Position.c`)
- Legal move generation → Attack tables: uses attack data (evidence: `MoveGen.c`)
- Legal move generation → Bitboard operations: uses bitboards (evidence: `MoveGen.c`)
- UCI command handling → Move notation: formats moves (evidence: `Uci.c`)
- UCI command handling → Chess GUI / user: returns analysis (evidence: `README.md`)
