# lynx-chess/lynx architecture

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

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

## Overview

Lynx is a hand-crafted-evaluation chess engine. Its main workflow accepts UCI commands, updates a game position, searches for a move, and reports engine output; the README identifies UCI-compatible GUIs as the interface for the executable. The graph also preserves position parsing, move generation, evaluation, transposition storage, and optional online tablebase probing. Connections are limited to relationships supported by the README or SOURCE INDEX references; several internals were not sampled, so uncertain links are omitted.

Main entry points: [`src/Lynx/Model/Game.cs`](https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Model/Game.cs) (Game state), [`src/Lynx/Search/NegaMax.cs`](https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Search/NegaMax.cs) (NegaMax search), [`src/Lynx/Engine.cs`](https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Engine.cs) (Engine), [`src/Lynx/MoveGenerator.cs`](https://github.com/lynx-chess/lynx/blob/main/src/Lynx/MoveGenerator.cs) (Move generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["UCI interface"]
  node_uci["UCI handler<br/>[UCIHandler.cs]"]
  node_commands["UCI commands<br/>[GoCommand.cs]"]
  node_cli["CLI runner<br/>[Runner.cs]"]
end

subgraph group_chess["Chess state"]
  node_game["Game state<br/>[Game.cs]"]
  node_position["Position<br/>[Position.cs]"]
  node_fen["FEN parser<br/>[FENParser.cs]"]
  node_moves["Move encoding<br/>[Move.cs]"]
  node_generator["Move generator<br/>[MoveGenerator.cs]"]
end

subgraph group_search["Search and evaluation"]
  node_engine["Engine<br/>[Engine.cs]"]
  node_searcher["Search orchestration<br/>[Searcher.cs]"]
  node_negamax["NegaMax search<br/>[NegaMax.cs]"]
  node_evaluation["Hand-crafted evaluation<br/>[Evaluation.cs]"]
  node_tt[("Transposition table")]
end

subgraph group_support["Engine support"]
  node_attacks["Attack tables<br/>[Attacks.cs]"]
  node_attackgen["Attack generation<br/>[AttackGenerator.cs]"]
  node_config["Configuration<br/>[Configuration.cs]"]
  node_tablebase["Online tablebase"]
  node_datagen["Viriformat data"]
end

node_gui(("Chess GUI"))

node_gui -->|"sends UCI"| node_uci
node_cli -->|"runs handler"| node_uci
node_uci -->|"routes commands"| node_commands
node_commands -.->|"requests search"| node_engine
node_engine -->|"delegates search"| node_searcher
node_engine -->|"owns game"| node_game
node_game -->|"parses position"| node_fen
node_game -->|"updates position"| node_position
node_game -->|"parses moves"| node_moves
node_searcher -.->|"dispatches search"| node_negamax
node_negamax -->|"searches position"| node_game
node_negamax -->|"generates moves"| node_generator
node_negamax -->|"probes table"| node_tt
node_negamax -.->|"evaluates positions"| node_evaluation
node_generator -->|"reads position"| node_position
node_generator -->|"encodes moves"| node_moves
node_attackgen -.->|"builds attacks"| node_attacks
node_position -->|"uses attacks"| node_attacks
node_engine -->|"probes positions"| node_tablebase
node_config -.->|"configures probing"| node_tablebase
node_datagen -->|"loads games"| node_game

click node_uci "https://github.com/lynx-chess/lynx/blob/main/src/Lynx/UCIHandler.cs"
click node_commands "https://github.com/lynx-chess/lynx/blob/main/src/Lynx/UCI/Commands/GUI/GoCommand.cs"
click node_cli "https://github.com/lynx-chess/lynx/blob/main/src/Lynx.Cli/Runner.cs"
click node_game "https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Model/Game.cs"
click node_position "https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Model/Position.cs"
click node_fen "https://github.com/lynx-chess/lynx/blob/main/src/Lynx/FENParser.cs"
click node_moves "https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Model/Move.cs"
click node_generator "https://github.com/lynx-chess/lynx/blob/main/src/Lynx/MoveGenerator.cs"
click node_engine "https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Engine.cs"
click node_searcher "https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Searcher.cs"
click node_negamax "https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Search/NegaMax.cs"
click node_evaluation "https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Evaluation.cs"
click node_tt "https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Model/TranspositionTable.cs"
click node_attacks "https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Attacks.cs"
click node_attackgen "https://github.com/lynx-chess/lynx/blob/main/src/Lynx/AttackGenerator.cs"
click node_config "https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Configuration.cs"
click node_tablebase "https://github.com/lynx-chess/lynx/blob/main/src/Lynx/OnlineTablebaseProber.cs"
click node_datagen "https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Datagen/ViriformatLoader.cs"

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_commands,node_cli,node_gui toneBlue
class node_game,node_position,node_fen,node_moves,node_generator toneAmber
class node_engine,node_searcher,node_negamax,node_evaluation,node_tt toneMint
class node_attacks,node_attackgen,node_config,node_tablebase,node_datagen toneRose
```

## Components

### UCI interface

- [UCI handler](https://github.com/lynx-chess/lynx/blob/main/src/Lynx/UCIHandler.cs): `src/Lynx/UCIHandler.cs`
- [UCI commands](https://github.com/lynx-chess/lynx/blob/main/src/Lynx/UCI/Commands/GUI/GoCommand.cs): `src/Lynx/UCI/Commands/GUI/GoCommand.cs`
- [CLI runner](https://github.com/lynx-chess/lynx/blob/main/src/Lynx.Cli/Runner.cs): `src/Lynx.Cli/Runner.cs`

### Chess state

- [Game state](https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Model/Game.cs): `src/Lynx/Model/Game.cs`
- [Position](https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Model/Position.cs): `src/Lynx/Model/Position.cs`
- [FEN parser](https://github.com/lynx-chess/lynx/blob/main/src/Lynx/FENParser.cs): `src/Lynx/FENParser.cs`
- [Move encoding](https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Model/Move.cs): `src/Lynx/Model/Move.cs`
- [Move generator](https://github.com/lynx-chess/lynx/blob/main/src/Lynx/MoveGenerator.cs): `src/Lynx/MoveGenerator.cs`

### Search and evaluation

- [Engine](https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Engine.cs): `src/Lynx/Engine.cs`
- [Search orchestration](https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Searcher.cs): `src/Lynx/Searcher.cs`
- [NegaMax search](https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Search/NegaMax.cs): `src/Lynx/Search/NegaMax.cs`
- [Hand-crafted evaluation](https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Evaluation.cs): `src/Lynx/Evaluation.cs`
- [Transposition table](https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Model/TranspositionTable.cs): `src/Lynx/Model/TranspositionTable.cs`

### Engine support

- [Attack tables](https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Attacks.cs): `src/Lynx/Attacks.cs`
- [Attack generation](https://github.com/lynx-chess/lynx/blob/main/src/Lynx/AttackGenerator.cs): `src/Lynx/AttackGenerator.cs`
- [Configuration](https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Configuration.cs): `src/Lynx/Configuration.cs`
- [Online tablebase](https://github.com/lynx-chess/lynx/blob/main/src/Lynx/OnlineTablebaseProber.cs): `src/Lynx/OnlineTablebaseProber.cs`
- [Viriformat data](https://github.com/lynx-chess/lynx/blob/main/src/Lynx/Datagen/ViriformatLoader.cs): `src/Lynx/Datagen/ViriformatLoader.cs`

### Other components

- **Chess GUI**

## Connections

- Chess GUI → UCI handler: sends UCI (evidence: `README.md`)
- CLI runner → UCI handler: runs handler (evidence: `src/Lynx.Cli/Runner.cs`)
- UCI handler → UCI commands: routes commands (evidence: `src/Lynx/UCIHandler.cs`)
- UCI commands → Engine: requests search (evidence: `src/Lynx/Engine.cs`)
- Engine → Search orchestration: delegates search (evidence: `src/Lynx/Engine.cs`)
- Engine → Game state: owns game (evidence: `src/Lynx/Engine.cs`)
- Game state → FEN parser: parses position (evidence: `src/Lynx/Model/Game.cs`)
- Game state → Position: updates position (evidence: `src/Lynx/Model/Game.cs`)
- Game state → Move encoding: parses moves (evidence: `src/Lynx/Model/Game.cs`)
- Search orchestration → NegaMax search: dispatches search
- NegaMax search → Game state: searches position (evidence: `src/Lynx/Search/NegaMax.cs`)
- NegaMax search → Move generator: generates moves (evidence: `src/Lynx/Search/NegaMax.cs`)
- NegaMax search → Transposition table: probes table (evidence: `src/Lynx/Search/NegaMax.cs`)
- NegaMax search → Hand-crafted evaluation: evaluates positions
- Move generator → Position: reads position (evidence: `src/Lynx/MoveGenerator.cs`)
- Move generator → Move encoding: encodes moves (evidence: `src/Lynx/MoveGenerator.cs`)
- Attack generation → Attack tables: builds attacks
- Position → Attack tables: uses attacks (evidence: `src/Lynx/Model/Position.cs`)
- Engine → Online tablebase: probes positions (evidence: `src/Lynx/Engine.cs`)
- Configuration → Online tablebase: configures probing
- Viriformat data → Game state: loads games (evidence: `src/Lynx/Datagen/ViriformatLoader.cs`)
