# godofjan/chessengine-with-sfml architecture

> Architecture diagram of the GitHub repository godofjan/chessengine-with-sfml, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/godofjan/chessengine-with-sfml
- Repository: https://github.com/godofjan/chessengine-with-sfml

## Overview

This is a C++/SFML graphical chess game. A player drags a piece; the Game controller requests legal moves, commits a legal move to the Engine, and the UI renders the board and move feedback. Keyboard and reset events also dispatch to the Engine. The README documents special rules, game-end detection, history, and FEN conversion. The sampled sources show the main UI/engine wiring, but not all engine internals; uncertain internal call links are omitted.

Main entry points: [`src/Engine/engine.cpp`](https://github.com/godofjan/chessengine-with-sfml/blob/master/src/Engine/engine.cpp) (Move Engine), [`src/UI/render.cpp`](https://github.com/godofjan/chessengine-with-sfml/blob/master/src/UI/render.cpp) (Renderer), [`src/UI/game.cpp`](https://github.com/godofjan/chessengine-with-sfml/blob/master/src/UI/game.cpp) (Game Controller), [`src/UI/processEvents.cpp`](https://github.com/godofjan/chessengine-with-sfml/blob/master/src/UI/processEvents.cpp) (Event Handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Game UI"]
  node_game["Game Controller<br/>[game.cpp]"]
  node_events["Event Handler<br/>[processEvents.cpp]"]
  node_render["Renderer<br/>[render.cpp]"]
  node_fen["FEN Conversion<br/>[game.cpp]"]
end

subgraph group_rules["Chess Engine"]
  node_engine["Move Engine<br/>[engine.cpp]"]
  node_movegen["Legal Moves<br/>[engine.cpp]"]
  node_special["Special Rules<br/>[engine.cpp]"]
  node_gameend["End Detection<br/>[engine.cpp]"]
  node_board[("Board State<br/>[engine.hpp]")]
  node_history[("Move History<br/>[engine.hpp]")]
end

subgraph group_assets["Visual Assets"]
  node_pieceassets["Piece Textures"]
  node_uiassets["UI Icons"]
end

node_player(("Player"))
node_window["SFML Window"]

node_player -->|"uses"| node_window
node_window -->|"delivers events"| node_events
node_game -->|"processes events"| node_events
node_game -->|"requests legal moves"| node_engine
node_game -->|"commits move"| node_engine
node_game -->|"renders frame"| node_render
node_events -->|"undo, redo, reset"| node_engine
node_engine -->|"calculates"| node_movegen
node_engine -->|"applies rules"| node_special
node_engine -->|"checks outcome"| node_gameend
node_engine -->|"updates"| node_board
node_engine -->|"records moves"| node_history
node_render -->|"reads position"| node_board
node_render -->|"reads move index"| node_history
node_render -->|"loads textures"| node_pieceassets
node_render -->|"loads icons"| node_uiassets
node_render -->|"draws frame"| node_window
node_fen -->|"converts position"| node_board

click node_game "https://github.com/godofjan/chessengine-with-sfml/blob/master/src/UI/game.cpp"
click node_events "https://github.com/godofjan/chessengine-with-sfml/blob/master/src/UI/processEvents.cpp"
click node_render "https://github.com/godofjan/chessengine-with-sfml/blob/master/src/UI/render.cpp"
click node_engine "https://github.com/godofjan/chessengine-with-sfml/blob/master/src/Engine/engine.cpp"
click node_movegen "https://github.com/godofjan/chessengine-with-sfml/blob/master/src/Engine/engine.cpp"
click node_special "https://github.com/godofjan/chessengine-with-sfml/blob/master/src/Engine/engine.cpp"
click node_gameend "https://github.com/godofjan/chessengine-with-sfml/blob/master/src/Engine/engine.cpp"
click node_board "https://github.com/godofjan/chessengine-with-sfml/blob/master/src/Engine/engine.hpp"
click node_history "https://github.com/godofjan/chessengine-with-sfml/blob/master/src/Engine/engine.hpp"
click node_fen "https://github.com/godofjan/chessengine-with-sfml/blob/master/src/UI/game.cpp"
click node_pieceassets "https://github.com/godofjan/chessengine-with-sfml/tree/master/Assets"
click node_uiassets "https://github.com/godofjan/chessengine-with-sfml/tree/master/Icons"

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_events,node_render,node_fen toneBlue
class node_engine,node_movegen,node_special,node_gameend,node_board,node_history toneAmber
class node_pieceassets,node_uiassets toneMint
class node_player,node_window toneIndigo
```

## Components

### Game UI

- [Game Controller](https://github.com/godofjan/chessengine-with-sfml/blob/master/src/UI/game.cpp): `src/UI/game.cpp`
- [Event Handler](https://github.com/godofjan/chessengine-with-sfml/blob/master/src/UI/processEvents.cpp): `src/UI/processEvents.cpp`
- [Renderer](https://github.com/godofjan/chessengine-with-sfml/blob/master/src/UI/render.cpp): `src/UI/render.cpp`
- [FEN Conversion](https://github.com/godofjan/chessengine-with-sfml/blob/master/src/UI/game.cpp): `src/UI/game.cpp`

### Chess Engine

- [Move Engine](https://github.com/godofjan/chessengine-with-sfml/blob/master/src/Engine/engine.cpp): `src/Engine/engine.cpp`
- [Legal Moves](https://github.com/godofjan/chessengine-with-sfml/blob/master/src/Engine/engine.cpp): `src/Engine/engine.cpp`
- [Special Rules](https://github.com/godofjan/chessengine-with-sfml/blob/master/src/Engine/engine.cpp): `src/Engine/engine.cpp`
- [End Detection](https://github.com/godofjan/chessengine-with-sfml/blob/master/src/Engine/engine.cpp): `src/Engine/engine.cpp`
- [Board State](https://github.com/godofjan/chessengine-with-sfml/blob/master/src/Engine/engine.hpp): `src/Engine/engine.hpp`
- [Move History](https://github.com/godofjan/chessengine-with-sfml/blob/master/src/Engine/engine.hpp): `src/Engine/engine.hpp`

### Visual Assets

- [Piece Textures](https://github.com/godofjan/chessengine-with-sfml/tree/master/Assets): `Assets`
- [UI Icons](https://github.com/godofjan/chessengine-with-sfml/tree/master/Icons): `Icons`

### Other components

- **Player**
- **SFML Window**

## Connections

- Player → SFML Window: uses
- SFML Window → Event Handler: delivers events
- Game Controller → Event Handler: processes events
- Game Controller → Move Engine: requests legal moves
- Game Controller → Move Engine: commits move
- Game Controller → Renderer: renders frame
- Event Handler → Move Engine: undo, redo, reset
- Move Engine → Legal Moves: calculates
- Move Engine → Special Rules: applies rules
- Move Engine → End Detection: checks outcome
- Move Engine → Board State: updates
- Move Engine → Move History: records moves
- Renderer → Board State: reads position
- Renderer → Move History: reads move index
- Renderer → Piece Textures: loads textures
- Renderer → UI Icons: loads icons
- Renderer → SFML Window: draws frame
- FEN Conversion → Board State: converts position
