# rlynx0/colorsort-mosaic architecture

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

- Interactive diagram: https://gitdiagram.com/rlynx0/colorsort-mosaic
- Repository: https://github.com/rlynx0/colorsort-mosaic

## Overview

colorsort-mosaic is a command-line image mosaic generator. The user supplies image directories, an output path, and tile size; the program loads and analyzes images, assigns tiles to a hue/lightness grid, composites the mosaic, and saves it. All runtime behavior is implemented in src/main.rs; the graph reflects the sampled source, with no README available.

Main entry points: [`src/main.rs`](https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs) (Run workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Image preparation"]
  node_directory_scan["Directory scan<br/>[main.rs]"]
  node_image_decode["Image decode<br/>[main.rs]"]
  node_tile_process["Prepare tiles<br/>[main.rs]"]
  node_color_analysis["Color analysis<br/>[main.rs]"]
end

subgraph group_layout["Mosaic generation"]
  node_mosaic["Build mosaic<br/>[main.rs]"]
  node_grid["Grid sizing<br/>[main.rs]"]
  node_assignment["Tile assignment<br/>[main.rs]"]
  node_distance["Color distance<br/>[main.rs]"]
end

subgraph group_interface["CLI and feedback"]
  node_cli["CLI options<br/>[main.rs]"]
  node_main["Run workflow<br/>[main.rs]"]
  node_progress["Progress display<br/>[main.rs]"]
end

node_user(("User"))
node_image_dirs["Image directories"]
node_output_file["Mosaic image"]

node_user -->|"sets options"| node_cli
node_cli -->|"provides options"| node_main
node_main -->|"reads entries"| node_image_dirs
node_main -->|"scans directories"| node_directory_scan
node_main -->|"decodes entries"| node_image_decode
node_main -->|"processes images"| node_tile_process
node_image_decode -->|"returns images"| node_tile_process
node_tile_process -->|"computes colors"| node_color_analysis
node_tile_process -->|"updates status"| node_progress
node_main -->|"builds from tiles"| node_mosaic
node_mosaic -->|"chooses dimensions"| node_grid
node_mosaic -->|"assigns tiles"| node_assignment
node_assignment -->|"scores matches"| node_distance
node_main -->|"saves image"| node_output_file

click node_cli "https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs"
click node_main "https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs"
click node_directory_scan "https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs"
click node_image_decode "https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs"
click node_tile_process "https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs"
click node_color_analysis "https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs"
click node_progress "https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs"
click node_mosaic "https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs"
click node_grid "https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs"
click node_assignment "https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs"
click node_distance "https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.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_directory_scan,node_image_decode,node_tile_process,node_color_analysis,node_user toneBlue
class node_mosaic,node_grid,node_assignment,node_distance toneAmber
class node_cli,node_main,node_progress toneMint
class node_image_dirs,node_output_file toneIndigo
```

## Components

### Image preparation

- [Directory scan](https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs): `src/main.rs`
- [Image decode](https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs): `src/main.rs`
- [Prepare tiles](https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs): `src/main.rs`
- [Color analysis](https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs): `src/main.rs`

### Mosaic generation

- [Build mosaic](https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs): `src/main.rs`
- [Grid sizing](https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs): `src/main.rs`
- [Tile assignment](https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs): `src/main.rs`
- [Color distance](https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs): `src/main.rs`

### CLI and feedback

- [CLI options](https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs): `src/main.rs`
- [Run workflow](https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs): `src/main.rs`
- [Progress display](https://github.com/rlynx0/colorsort-mosaic/blob/main/src/main.rs): `src/main.rs`

### Other components

- **User**
- **Image directories**
- **Mosaic image**

## Connections

- User → CLI options: sets options
- CLI options → Run workflow: provides options
- Run workflow → Image directories: reads entries
- Run workflow → Directory scan: scans directories
- Run workflow → Image decode: decodes entries
- Run workflow → Prepare tiles: processes images
- Image decode → Prepare tiles: returns images
- Prepare tiles → Color analysis: computes colors
- Prepare tiles → Progress display: updates status
- Run workflow → Build mosaic: builds from tiles
- Build mosaic → Grid sizing: chooses dimensions
- Build mosaic → Tile assignment: assigns tiles
- Tile assignment → Color distance: scores matches
- Run workflow → Mosaic image: saves image
