# dziq21/geneticsudokusolver architecture

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

- Interactive diagram: https://gitdiagram.com/dziq21/geneticsudokusolver
- Repository: https://github.com/dziq21/geneticsudokusolver

## Overview

GeneticSudokuSolver is a command-line Sudoku solver that searches for a valid grid using configurable genetic algorithms. The main workflow loads configuration and a puzzle, selects a genotype representation and fitness-selection strategy, then repeatedly evaluates and evolves a population until it finds a solution or reaches its iteration limit. Genotypes encode candidate grids and implement scoring, crossover, and mutation; population management handles generations and statistics. The README is brief, so capability details come from the sampled source and index; unsampled internals are not inferred.

Main entry points: [`src/main.cpp`](https://github.com/dziq21/geneticsudokusolver/blob/main/src/main.cpp) (Solver orchestration), [`src/Population.cpp`](https://github.com/dziq21/geneticsudokusolver/blob/main/src/Population.cpp) (Population evolution), [`src/Fitest.cpp`](https://github.com/dziq21/geneticsudokusolver/blob/main/src/Fitest.cpp) (Fitness selection), [`src/ConfigLoader.cpp`](https://github.com/dziq21/geneticsudokusolver/blob/main/src/ConfigLoader.cpp) (Config parsing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Inputs and configuration"]
  node_config["Config parsing<br/>[ConfigLoader.cpp]"]
  node_settings["Solver settings<br/>[ConfigLoader.h]"]
  node_puzzle["Puzzle loading<br/>[SudokuLoader.cpp]"]
end

subgraph group_search["Genetic search"]
  node_population["Population evolution<br/>[Population.cpp]"]
  node_selection["Fitness selection<br/>[Fitest.cpp]"]
  node_genotypes["Candidate encodings<br/>[Genotype.cpp]"]
  node_scoring["Candidate scoring<br/>[Genotype.cpp]"]
end

subgraph group_runtime["Command-line runtime"]
  node_main["Solver orchestration<br/>[main.cpp]"]
  node_console["Progress output<br/>[main.cpp]"]
end

node_user(("Operator"))

node_user -->|"starts"| node_main
node_main -->|"loads settings"| node_config
node_config -->|"parses entries"| node_settings
node_main -->|"loads puzzle"| node_puzzle
node_main -->|"creates and advances"| node_population
node_main -->|"selects strategy"| node_selection
node_population -->|"dispatches selection"| node_selection
node_selection -->|"crosses parents"| node_genotypes
node_population -->|"mutates candidates"| node_genotypes
node_population -->|"evaluates candidates"| node_scoring
node_main -->|"prints progress"| node_console
node_main -->|"reads options"| node_settings
node_main -->|"passes grid"| node_puzzle

click node_config "https://github.com/dziq21/geneticsudokusolver/blob/main/src/ConfigLoader.cpp"
click node_settings "https://github.com/dziq21/geneticsudokusolver/blob/main/inc/ConfigLoader.h"
click node_puzzle "https://github.com/dziq21/geneticsudokusolver/blob/main/src/SudokuLoader.cpp"
click node_main "https://github.com/dziq21/geneticsudokusolver/blob/main/src/main.cpp"
click node_population "https://github.com/dziq21/geneticsudokusolver/blob/main/src/Population.cpp"
click node_selection "https://github.com/dziq21/geneticsudokusolver/blob/main/src/Fitest.cpp"
click node_genotypes "https://github.com/dziq21/geneticsudokusolver/blob/main/src/Genotype.cpp"
click node_scoring "https://github.com/dziq21/geneticsudokusolver/blob/main/src/Genotype.cpp"
click node_console "https://github.com/dziq21/geneticsudokusolver/blob/main/src/main.cpp"

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_config,node_settings,node_puzzle toneBlue
class node_population,node_selection,node_genotypes,node_scoring toneAmber
class node_main,node_console toneMint
class node_user toneIndigo
```

## Components

### Inputs and configuration

- [Config parsing](https://github.com/dziq21/geneticsudokusolver/blob/main/src/ConfigLoader.cpp): `src/ConfigLoader.cpp`
- [Solver settings](https://github.com/dziq21/geneticsudokusolver/blob/main/inc/ConfigLoader.h): `inc/ConfigLoader.h`
- [Puzzle loading](https://github.com/dziq21/geneticsudokusolver/blob/main/src/SudokuLoader.cpp): `src/SudokuLoader.cpp`

### Genetic search

- [Population evolution](https://github.com/dziq21/geneticsudokusolver/blob/main/src/Population.cpp): `src/Population.cpp`
- [Fitness selection](https://github.com/dziq21/geneticsudokusolver/blob/main/src/Fitest.cpp): `src/Fitest.cpp`
- [Candidate encodings](https://github.com/dziq21/geneticsudokusolver/blob/main/src/Genotype.cpp): `src/Genotype.cpp`
- [Candidate scoring](https://github.com/dziq21/geneticsudokusolver/blob/main/src/Genotype.cpp): `src/Genotype.cpp`

### Command-line runtime

- [Solver orchestration](https://github.com/dziq21/geneticsudokusolver/blob/main/src/main.cpp): `src/main.cpp`
- [Progress output](https://github.com/dziq21/geneticsudokusolver/blob/main/src/main.cpp): `src/main.cpp`

### Other components

- **Operator**

## Connections

- Operator → Solver orchestration: starts
- Solver orchestration → Config parsing: loads settings (evidence: `src/main.cpp`)
- Config parsing → Solver settings: parses entries (evidence: `src/ConfigLoader.cpp`)
- Solver orchestration → Puzzle loading: loads puzzle (evidence: `src/main.cpp`)
- Solver orchestration → Population evolution: creates and advances (evidence: `src/main.cpp`)
- Solver orchestration → Fitness selection: selects strategy (evidence: `src/main.cpp`)
- Population evolution → Fitness selection: dispatches selection (evidence: `src/Population.cpp`)
- Fitness selection → Candidate encodings: crosses parents (evidence: `src/Fitest.cpp`)
- Population evolution → Candidate encodings: mutates candidates (evidence: `src/Population.cpp`)
- Population evolution → Candidate scoring: evaluates candidates (evidence: `src/Population.cpp`)
- Solver orchestration → Progress output: prints progress (evidence: `src/main.cpp`)
- Solver orchestration → Solver settings: reads options (evidence: `src/main.cpp`)
- Solver orchestration → Puzzle loading: passes grid (evidence: `src/main.cpp`)
