# gabrieltofvesson/sudoku architecture

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

- Interactive diagram: https://gitdiagram.com/gabrieltofvesson/sudoku
- Repository: https://github.com/gabrieltofvesson/sudoku

## Overview

##### Project type and purpose
- This is a small, command-line C tool for solving Sudoku puzzles.
- Key indicators: single executable (`main.c` + `board.c`), no network or UI, just file I/O, a solver algorithm, and optional verbose logging.

##### File structure
- Top-level sources:
- `main.c` – CLI entry point, argument parsing, verbosity flags.
- `board.c` / `board.h` – core solver: data structures, constraint checks, backtracking/optimization.
- `examples/` – sample input boards (text files) used as data sources.
- Config/build artifacts: none (Makefile TODO), but compile via `gcc -o sudoku main.c board.c`.

##### README for additional insights
- Describes input format (9×9 grid, ‘0’ or space for blanks).
- Explains optional compile-time optimization (`-DOPTIMIZE`) and runtime verbosity (`-v`, `-vv`).
- Mentions future refactoring: splitting printing and algorithm into separate modules.

##### Elements
[Filename + Flags] → CLI → Parser → BoardStruct → Solver → BoardStruct → Printer → stdout
- Blue rectangles for core algorithm (board.c/h)
- Green for I/O modules (file reader, printer)
- Orange for CLI/flags

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "CLI Layer"
        CLI["CLI Interface\n(main.c)"]:::cli
        CLI -->|"parse_args()"| ArgParser["Arg Parser"]:::cli
    end

    subgraph "I/O Layer"
        ArgParser -->|"filename & flags"| InputReader["Input Reader\n(load_board)"]:::io
        InputReader -->|"BoardStruct"| BoardStruct["Board Struct"]:::core
    end

    subgraph "Solver Layer"
        BoardStruct -->|"solve_board()"| Solver["Sudoku Solver Engine"]:::core
        Solver --> BoardStruct
    end

    subgraph "Output Layer"
        BoardStruct -->|"print_board()"| Printer["Output Formatter\n(print_board)"]:::io
        Printer --> stdout["stdout"]:::external
    end

    Examples["Example Data\n(examples/)"]:::external
    Examples --> InputReader
    CLI -.->|"OPTIMIZE macro"| Solver

    click CLI "https://github.com/gabrieltofvesson/sudoku/blob/master/main.c"
    click InputReader "https://github.com/gabrieltofvesson/sudoku/blob/master/board.c"
    click Solver "https://github.com/gabrieltofvesson/sudoku/blob/master/board.c"
    click Printer "https://github.com/gabrieltofvesson/sudoku/blob/master/board.c"
    click Examples "https://github.com/gabrieltofvesson/sudoku/tree/master/examples/"

    classDef cli fill:#FFA500,stroke:#333,stroke-width:1px;
    classDef io fill:#7CFC00,stroke:#333,stroke-width:1px;
    classDef core fill:#1E90FF,stroke:#333,stroke-width:1px;
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px;
```
