# til7701/puzzled architecture

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

- Interactive diagram: https://gitdiagram.com/til7701/puzzled
- Repository: https://github.com/til7701/puzzled

## Overview

Puzzled is a GTK/Libadwaita puzzle-solving application with configuration, puzzle collections, interactive placement, and a solver. The principal workflow is to load a collection, select a puzzle, manipulate its tiles, and check whether the arrangement solves it; the README also describes feasibility feedback and multiple puzzle formats. The source index supports key model, configuration, polyform, and solver connections, but several UI components were not sampled, so their internal calls are not asserted.

Main entry points: [`puzzled/src/model/collection.rs`](https://github.com/til7701/puzzled/blob/main/puzzled/src/model/collection.rs) (Puzzle collections), [`puzzled/src/model/puzzle.rs`](https://github.com/til7701/puzzled/blob/main/puzzled/src/model/puzzle.rs) (Puzzle progress), [`puzzled/src/model/store/mod.rs`](https://github.com/til7701/puzzled/blob/main/puzzled/src/model/store/mod.rs) (Collection store), [`puzzled_solver/src/dlx/mod.rs`](https://github.com/til7701/puzzled/blob/main/puzzled_solver/src/dlx/mod.rs) (Exact-cover search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Application interface"]
  node_application["Application<br/>[application.rs]"]
  node_window["Main window<br/>[window.rs]"]
  node_collection_ui["Collection selection"]
  node_puzzle_ui["Puzzle interaction<br/>[puzzle_state.rs]"]
  node_placement_ui["Board placement<br/>[mod.rs]"]
end

subgraph group_domain["Puzzle domain"]
  node_collection["Puzzle collections<br/>[collection.rs]"]
  node_puzzle["Puzzle progress<br/>[puzzle.rs]"]
  node_metadata["Puzzle metadata<br/>[puzzle_meta.rs]"]
  node_extension["Puzzle variants<br/>[extension.rs]"]
  node_stars["Progress stars<br/>[stars.rs]"]
  node_store[("Collection store<br/>[mod.rs]")]
  node_community[("Community collections<br/>[community.rs]")]
  node_placement_model["Placement models<br/>[mod.rs]"]
end

subgraph group_config["Puzzle configuration"]
  node_json_model["Puzzle JSON model<br/>[model.rs]"]
  node_json_converter["JSON conversion<br/>[converter.rs]"]
  node_config_validation["Config validation<br/>[validation.rs]"]
  node_random_config["Random puzzles<br/>[mod.rs]"]
end

subgraph group_geometry["Polyform geometry"]
  node_coordinates["Coordinates<br/>[coord_box.rs]"]
  node_polyforms["Polyforms<br/>[polyomino.rs]"]
end

subgraph group_solver["Puzzle solver"]
  node_solver_entry["Solver integration<br/>[mod.rs]"]
  node_solver_api["Solver engine<br/>[lib.rs]"]
  node_solver_tiles["Solver tiles<br/>[tile.rs]"]
  node_solver_dlx["Exact-cover search<br/>[mod.rs]"]
  node_solver_board["Solver board<br/>[board.rs]"]
  node_solver_result["Solve result<br/>[result.rs]"]
  node_combinations["Tile combinations"]
end

node_player(("Player"))

node_player -->|"opens"| node_application
node_application -->|"presents"| node_window
node_application -->|"loads collections"| node_store
node_window -.->|"shows collection"| node_collection_ui
node_collection_ui -.->|"selects"| node_collection
node_collection -->|"contains"| node_puzzle
node_puzzle_ui -->|"uses variants"| node_extension
node_placement_ui -->|"extracts state"| node_puzzle_ui
node_placement_ui -->|"delegates placement"| node_placement_model
node_puzzle -->|"belongs to"| node_collection
node_collection -->|"reads progress"| node_metadata
node_puzzle -->|"records progress"| node_metadata
node_puzzle -->|"uses scoring"| node_stars
node_store -->|"builds collections"| node_collection
node_store -->|"loads and saves"| node_community
node_json_converter -->|"converts"| node_json_model
node_json_converter -->|"validates"| node_config_validation
node_store -->|"loads JSON"| node_json_converter
node_random_config -.->|"generates puzzles"| node_config_validation
node_polyforms -->|"uses coordinates"| node_coordinates
node_placement_model -.->|"positions shapes"| node_polyforms
node_solver_entry -->|"reads puzzle state"| node_puzzle_ui
node_solver_entry -->|"uses combinations"| node_combinations
node_solver_entry -.->|"invokes solver"| node_solver_api
node_solver_api -->|"dispatches search"| node_solver_dlx
node_solver_dlx -->|"reads board"| node_solver_board
node_solver_dlx -->|"places tiles"| node_solver_tiles
node_solver_dlx -->|"returns solutions"| node_solver_result

click node_application "https://github.com/til7701/puzzled/blob/main/puzzled/src/application.rs"
click node_window "https://github.com/til7701/puzzled/blob/main/puzzled/src/window.rs"
click node_collection_ui "https://github.com/til7701/puzzled/blob/main/puzzled/src/app/collection_selection/collection_selection_page.rs"
click node_puzzle_ui "https://github.com/til7701/puzzled/blob/main/puzzled/src/app/puzzle/puzzle_area/puzzle_state.rs"
click node_placement_ui "https://github.com/til7701/puzzled/blob/main/puzzled/src/model/placement/mod.rs"
click node_collection "https://github.com/til7701/puzzled/blob/main/puzzled/src/model/collection.rs"
click node_puzzle "https://github.com/til7701/puzzled/blob/main/puzzled/src/model/puzzle.rs"
click node_metadata "https://github.com/til7701/puzzled/blob/main/puzzled/src/model/puzzle_meta.rs"
click node_extension "https://github.com/til7701/puzzled/blob/main/puzzled/src/model/extension.rs"
click node_stars "https://github.com/til7701/puzzled/blob/main/puzzled/src/model/stars.rs"
click node_store "https://github.com/til7701/puzzled/blob/main/puzzled/src/model/store/mod.rs"
click node_community "https://github.com/til7701/puzzled/blob/main/puzzled/src/model/store/community.rs"
click node_json_model "https://github.com/til7701/puzzled/blob/main/puzzled_config/src/json/model.rs"
click node_json_converter "https://github.com/til7701/puzzled/blob/main/puzzled_config/src/json/converter.rs"
click node_config_validation "https://github.com/til7701/puzzled/blob/main/puzzled_config/src/validation.rs"
click node_random_config "https://github.com/til7701/puzzled/blob/main/puzzled_config/src/random/mod.rs"
click node_coordinates "https://github.com/til7701/puzzled/blob/main/puzzled_polyform/src/coord/coord_box.rs"
click node_polyforms "https://github.com/til7701/puzzled/blob/main/puzzled_polyform/src/poly/polyomino.rs"
click node_placement_model "https://github.com/til7701/puzzled/blob/main/puzzled/src/model/placement/model/mod.rs"
click node_solver_entry "https://github.com/til7701/puzzled/blob/main/puzzled/src/solver/mod.rs"
click node_solver_api "https://github.com/til7701/puzzled/blob/main/puzzled_solver/src/lib.rs"
click node_solver_tiles "https://github.com/til7701/puzzled/blob/main/puzzled_solver/src/tile.rs"
click node_solver_dlx "https://github.com/til7701/puzzled/blob/main/puzzled_solver/src/dlx/mod.rs"
click node_solver_board "https://github.com/til7701/puzzled/blob/main/puzzled_solver/src/board.rs"
click node_solver_result "https://github.com/til7701/puzzled/blob/main/puzzled_solver/src/result.rs"
click node_combinations "https://github.com/til7701/puzzled/blob/main/puzzled/src/solver/combination_solutions.rs"

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_application,node_window,node_collection_ui,node_puzzle_ui,node_placement_ui toneBlue
class node_collection,node_puzzle,node_metadata,node_extension,node_stars,node_store,node_community,node_placement_model toneAmber
class node_json_model,node_json_converter,node_config_validation,node_random_config toneMint
class node_coordinates,node_polyforms toneRose
class node_solver_entry,node_solver_api,node_solver_tiles,node_solver_dlx,node_solver_board,node_solver_result,node_combinations,node_player toneIndigo
```

## Components

### Application interface

- [Application](https://github.com/til7701/puzzled/blob/main/puzzled/src/application.rs): `puzzled/src/application.rs`
- [Main window](https://github.com/til7701/puzzled/blob/main/puzzled/src/window.rs): `puzzled/src/window.rs`
- [Collection selection](https://github.com/til7701/puzzled/blob/main/puzzled/src/app/collection_selection/collection_selection_page.rs): `puzzled/src/app/collection_selection/collection_selection_page.rs`
- [Puzzle interaction](https://github.com/til7701/puzzled/blob/main/puzzled/src/app/puzzle/puzzle_area/puzzle_state.rs): `puzzled/src/app/puzzle/puzzle_area/puzzle_state.rs`
- [Board placement](https://github.com/til7701/puzzled/blob/main/puzzled/src/model/placement/mod.rs): `puzzled/src/model/placement/mod.rs`

### Puzzle domain

- [Puzzle collections](https://github.com/til7701/puzzled/blob/main/puzzled/src/model/collection.rs): `puzzled/src/model/collection.rs`
- [Puzzle progress](https://github.com/til7701/puzzled/blob/main/puzzled/src/model/puzzle.rs): `puzzled/src/model/puzzle.rs`
- [Puzzle metadata](https://github.com/til7701/puzzled/blob/main/puzzled/src/model/puzzle_meta.rs): `puzzled/src/model/puzzle_meta.rs`
- [Puzzle variants](https://github.com/til7701/puzzled/blob/main/puzzled/src/model/extension.rs): `puzzled/src/model/extension.rs`
- [Progress stars](https://github.com/til7701/puzzled/blob/main/puzzled/src/model/stars.rs): `puzzled/src/model/stars.rs`
- [Collection store](https://github.com/til7701/puzzled/blob/main/puzzled/src/model/store/mod.rs): `puzzled/src/model/store/mod.rs`
- [Community collections](https://github.com/til7701/puzzled/blob/main/puzzled/src/model/store/community.rs): `puzzled/src/model/store/community.rs`
- [Placement models](https://github.com/til7701/puzzled/blob/main/puzzled/src/model/placement/model/mod.rs): `puzzled/src/model/placement/model/mod.rs`

### Puzzle configuration

- [Puzzle JSON model](https://github.com/til7701/puzzled/blob/main/puzzled_config/src/json/model.rs): `puzzled_config/src/json/model.rs`
- [JSON conversion](https://github.com/til7701/puzzled/blob/main/puzzled_config/src/json/converter.rs): `puzzled_config/src/json/converter.rs`
- [Config validation](https://github.com/til7701/puzzled/blob/main/puzzled_config/src/validation.rs): `puzzled_config/src/validation.rs`
- [Random puzzles](https://github.com/til7701/puzzled/blob/main/puzzled_config/src/random/mod.rs): `puzzled_config/src/random/mod.rs`

### Polyform geometry

- [Coordinates](https://github.com/til7701/puzzled/blob/main/puzzled_polyform/src/coord/coord_box.rs): `puzzled_polyform/src/coord/coord_box.rs`
- [Polyforms](https://github.com/til7701/puzzled/blob/main/puzzled_polyform/src/poly/polyomino.rs): `puzzled_polyform/src/poly/polyomino.rs`

### Puzzle solver

- [Solver integration](https://github.com/til7701/puzzled/blob/main/puzzled/src/solver/mod.rs): `puzzled/src/solver/mod.rs`
- [Solver engine](https://github.com/til7701/puzzled/blob/main/puzzled_solver/src/lib.rs): `puzzled_solver/src/lib.rs`
- [Solver tiles](https://github.com/til7701/puzzled/blob/main/puzzled_solver/src/tile.rs): `puzzled_solver/src/tile.rs`
- [Exact-cover search](https://github.com/til7701/puzzled/blob/main/puzzled_solver/src/dlx/mod.rs): `puzzled_solver/src/dlx/mod.rs`
- [Solver board](https://github.com/til7701/puzzled/blob/main/puzzled_solver/src/board.rs): `puzzled_solver/src/board.rs`
- [Solve result](https://github.com/til7701/puzzled/blob/main/puzzled_solver/src/result.rs): `puzzled_solver/src/result.rs`
- [Tile combinations](https://github.com/til7701/puzzled/blob/main/puzzled/src/solver/combination_solutions.rs): `puzzled/src/solver/combination_solutions.rs`

### Other components

- **Player**

## Connections

- Player → Application: opens
- Application → Main window: presents (evidence: `puzzled/src/application.rs`)
- Application → Collection store: loads collections (evidence: `puzzled/src/application.rs`)
- Main window → Collection selection: shows collection
- Collection selection → Puzzle collections: selects
- Puzzle collections → Puzzle progress: contains (evidence: `puzzled/src/model/collection.rs`)
- Puzzle interaction → Puzzle variants: uses variants (evidence: `puzzled/src/app/puzzle/puzzle_area/puzzle_state.rs`)
- Board placement → Puzzle interaction: extracts state (evidence: `puzzled/src/model/placement/mod.rs`)
- Board placement → Placement models: delegates placement (evidence: `puzzled/src/model/placement/mod.rs`)
- Puzzle progress → Puzzle collections: belongs to (evidence: `puzzled/src/model/puzzle.rs`)
- Puzzle collections → Puzzle metadata: reads progress (evidence: `puzzled/src/model/collection.rs`)
- Puzzle progress → Puzzle metadata: records progress (evidence: `puzzled/src/model/puzzle.rs`)
- Puzzle progress → Progress stars: uses scoring (evidence: `puzzled/src/model/puzzle.rs`)
- Collection store → Puzzle collections: builds collections (evidence: `puzzled/src/model/store/mod.rs`)
- Collection store → Community collections: loads and saves (evidence: `puzzled/src/model/store/mod.rs`)
- JSON conversion → Puzzle JSON model: converts (evidence: `puzzled_config/src/json/converter.rs`)
- JSON conversion → Config validation: validates (evidence: `puzzled_config/src/json/converter.rs`)
- Collection store → JSON conversion: loads JSON (evidence: `puzzled/src/model/store/mod.rs`)
- Random puzzles → Config validation: generates puzzles
- Polyforms → Coordinates: uses coordinates (evidence: `puzzled_polyform/src/poly/polyomino.rs`)
- Placement models → Polyforms: positions shapes
- Solver integration → Puzzle interaction: reads puzzle state (evidence: `puzzled/src/solver/mod.rs`)
- Solver integration → Tile combinations: uses combinations (evidence: `puzzled/src/solver/mod.rs`)
- Solver integration → Solver engine: invokes solver
- Solver engine → Exact-cover search: dispatches search (evidence: `puzzled_solver/src/lib.rs`)
- Exact-cover search → Solver board: reads board (evidence: `puzzled_solver/src/dlx/mod.rs`)
- Exact-cover search → Solver tiles: places tiles (evidence: `puzzled_solver/src/dlx/mod.rs`)
- Exact-cover search → Solve result: returns solutions (evidence: `puzzled_solver/src/dlx/mod.rs`)
