# emadgh/windows-shade-editor architecture

> Architecture diagram of the GitHub repository emadgh/windows-shade-editor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/emadgh/windows-shade-editor
- Repository: https://github.com/emadgh/windows-shade-editor

## Overview

#### Purpose and Runtime
Shade Editor is a native Windows Rust/egui desktop application for non-destructive editing and production conversion of multi-channel TIFF artwork used in ceramic printing. It preserves source TIFF pixels; `.shade` projects persist recipes, metadata, previews, and recovery state. Primary executable entry is `src/main.rs`; shared module wiring is in `src/lib.rs`.

#### Application and Project Lifecycle
Application orchestration connects UI actions to project state, persistence, autosave, history, and recovery. The project schema represents Faces, recipes, preview settings, source/production roles, snapshots, and conversion provenance. TIFF paths are generally project-relative.
- `src/main.rs`
- `src/model.rs`
- `src/project_lifecycle.rs`
- `src/project_autosave.rs`
- `src/recovery.rs`

#### Face Ingestion and TIFF Boundary
TIFF inspection/decoding discovers dynamic RGB, CMYK, extra, and Spot channels plus ICC and Photoshop metadata. This is the boundary between immutable source files and in-memory project/preview state. Filesystem safety and path validation support atomic operations and relinking.
- `src/tiff_io.rs`
- `src/tiff_inspect.rs`
- `src/png_source.rs`
- `src/safe_fs.rs`
- `src/path_safety.rs`

#### Non-Destructive Adjustment and Preview Rendering
Each Face carries an adjustment recipe applied in production order: Levels → dynamic N×N channel mixer → Curve. Rendering creates viewport/thumbnail previews without modifying sources. Preview color management selects embedded or assigned ICC profiles, transforms to sRGB, and can soft-proof through an output profile.
- `src/adjustment_tools.rs`
- `src/render.rs`
- `src/color_management.rs`
- `src/thumbnail.rs`
- `src/snapshot_preview_cache.rs`

#### UI Control Layer
egui views and input routing expose face navigation, adjustment editors, color conversion, export/conversion queues, settings, and status. Controllers/features form the application-facing command boundary rather than embedding workflow behavior directly in UI panels.
- `src/ui/mod.rs`
- `src/ui/actions.rs`
- `src/ui/input_router.rs`
- `src/app_controllers.rs`
- `src/app_features.rs`

#### Production Color Conversion
Production setup separately assigns hash-verified source ICCs and validates target Output ICC or DeviceLink recipes, channel topology, precision, and destination safety. The worker renders the saved immutable adjustment state into a disk-backed mmap spool, invokes ICC/device-link conversion, and writes bounded strips to a staged TIFF. N-channel output uses separated ink semantics and authoritative ink names.
- `src/conversion_preflight.rs`
- `src/conversion_recipe.rs`
- `src/icc_conversion_worker.rs`
- `src/devicelink_conversion.rs`
- `src/conversion_tiff.rs`

#### Durable Queues, Transactions, and Output
Conversion captures are immutable and serialized before background work. Persistent queue state supports restart recovery, pause/resume, retry, progress, and cancellation before commit. Transaction handling makes TIFF commit atomic; post-commit project/link failures retain recovery payloads. A parallel export queue handles normal full-resolution TIFF exports and batches.
- `src/conversion_queue.rs`
- `src/conversion_transaction.rs`
- `src/conversion_workflow.rs`
- `src/export_queue.rs`
- `src/export.rs`

#### Validation and Windows Integration
Production acceptance validates output profiles, TIFF transport properties, metadata retention, and round-trip expectations. Windows-specific infrastructure includes installed ICC catalog access, native file/process support, and an optional Explorer Shell extension built from `shell/`.
- `src/validation.rs`
- `src/production_acceptance.rs`
- `src/production_project.rs`
- `shell/ShadeEditorShell.cpp`
- `.github/workflows/build-windows.yml`

Main entry points: [`src/project_lifecycle.rs`](https://github.com/emadgh/windows-shade-editor/blob/main/src/project_lifecycle.rs) (Project lifecycle), [`src/model.rs`](https://github.com/emadgh/windows-shade-editor/blob/main/src/model.rs) (Project model), [`src/app_controllers.rs`](https://github.com/emadgh/windows-shade-editor/blob/main/src/app_controllers.rs) (Controllers and features), [`src/tiff_io.rs`](https://github.com/emadgh/windows-shade-editor/blob/main/src/tiff_io.rs) (TIFF ingest and inspection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Desktop application"]
  node_main{{"Application entry<br/>Rust executable<br/>[main.rs]"}}
  node_ui["egui UI and input<br/>UI layer<br/>[mod.rs]"]
  node_commands["Controllers and features<br/>command boundary<br/>[app_controllers.rs]"]
  node_project["Project model<br/>project schema<br/>[model.rs]"]
  node_lifecycle["Project lifecycle<br/>project orchestration"]
  node_autosave["Autosave and recovery<br/>durability service"]
end

subgraph group_image["Image pipeline"]
  node_tiff["TIFF ingest and inspection<br/>source-file boundary<br/>[tiff_io.rs]"]
  node_safe_fs["Safe filesystem paths<br/>filesystem safety<br/>[safe_fs.rs]"]
  node_adjustments["Adjustment recipes<br/>non-destructive processing"]
  node_preview["Preview rendering<br/>viewport renderer<br/>[render.rs]"]
  node_color_management["Preview color management<br/>ICC transform"]
end

subgraph group_production["Production output"]
  node_preflight["Conversion preflight<br/>production validation"]
  node_recipe["Conversion recipe<br/>production recipe"]
  node_conversion_queue["Persistent conversion queue<br/>durable background queue"]
  node_workflow["Conversion workflow<br/>transaction coordinator"]
  node_worker["ICC conversion worker<br/>disk-backed renderer"]
  node_tiff_output["Staged TIFF writer<br/>production encoder<br/>[conversion_tiff.rs]"]
  node_transaction["Atomic output commit<br/>file transaction"]
  node_acceptance["Production acceptance<br/>output validation"]
  node_export_queue["Export queue<br/>[export_queue.rs]"]
end

subgraph group_platform["Windows integration"]
  node_windows["Windows ICC and shell support<br/>Windows integration"]
end

node_main -->|"starts"| node_ui
node_main -->|"initializes"| node_lifecycle
node_ui -->|"user actions"| node_commands
node_commands -->|"project commands"| node_lifecycle
node_lifecycle -->|"loads and updates"| node_project
node_lifecycle -->|"persists recovery state"| node_autosave
node_lifecycle -->|"ingests faces"| node_tiff
node_tiff -->|"source metadata and channels"| node_project
node_safe_fs -->|"safe paths and relinking"| node_lifecycle
node_project -->|"stores recipes"| node_adjustments
node_adjustments -->|"applies recipe"| node_preview
node_tiff -->|"immutable source pixels"| node_preview
node_color_management -->|"display transform"| node_preview
node_commands -->|"requests production setup"| node_preflight
node_project -->|"saved conversion state"| node_recipe
node_preflight -->|"validates"| node_recipe
node_recipe -->|"immutable capture"| node_conversion_queue
node_conversion_queue -->|"scheduled job"| node_workflow
node_workflow -->|"renders and converts"| node_worker
node_adjustments -->|"production-order state"| node_worker
node_worker -->|"converted strips"| node_tiff_output
node_tiff_output -->|"staged output"| node_acceptance
node_acceptance -->|"accepted TIFF"| node_transaction
node_transaction -->|"committed output link"| node_project
node_workflow -.->|"failure recovery payload"| node_autosave
node_commands -->|"export requests"| node_export_queue
node_windows -->|"installed ICC catalog"| node_preflight

click node_main "https://github.com/emadgh/windows-shade-editor/blob/main/src/main.rs"
click node_ui "https://github.com/emadgh/windows-shade-editor/blob/main/src/ui/mod.rs"
click node_commands "https://github.com/emadgh/windows-shade-editor/blob/main/src/app_controllers.rs"
click node_project "https://github.com/emadgh/windows-shade-editor/blob/main/src/model.rs"
click node_lifecycle "https://github.com/emadgh/windows-shade-editor/blob/main/src/project_lifecycle.rs"
click node_autosave "https://github.com/emadgh/windows-shade-editor/blob/main/src/project_autosave.rs"
click node_tiff "https://github.com/emadgh/windows-shade-editor/blob/main/src/tiff_io.rs"
click node_safe_fs "https://github.com/emadgh/windows-shade-editor/blob/main/src/safe_fs.rs"
click node_adjustments "https://github.com/emadgh/windows-shade-editor/blob/main/src/adjustment_tools.rs"
click node_preview "https://github.com/emadgh/windows-shade-editor/blob/main/src/render.rs"
click node_color_management "https://github.com/emadgh/windows-shade-editor/blob/main/src/color_management.rs"
click node_preflight "https://github.com/emadgh/windows-shade-editor/blob/main/src/conversion_preflight.rs"
click node_recipe "https://github.com/emadgh/windows-shade-editor/blob/main/src/conversion_recipe.rs"
click node_conversion_queue "https://github.com/emadgh/windows-shade-editor/blob/main/src/conversion_queue.rs"
click node_workflow "https://github.com/emadgh/windows-shade-editor/blob/main/src/conversion_workflow.rs"
click node_worker "https://github.com/emadgh/windows-shade-editor/blob/main/src/icc_conversion_worker.rs"
click node_tiff_output "https://github.com/emadgh/windows-shade-editor/blob/main/src/conversion_tiff.rs"
click node_transaction "https://github.com/emadgh/windows-shade-editor/blob/main/src/conversion_transaction.rs"
click node_acceptance "https://github.com/emadgh/windows-shade-editor/blob/main/src/production_acceptance.rs"
click node_export_queue "https://github.com/emadgh/windows-shade-editor/blob/main/src/export_queue.rs"
click node_windows "https://github.com/emadgh/windows-shade-editor/blob/main/shell/ShadeEditorShell.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_main,node_ui,node_commands,node_project,node_lifecycle,node_autosave toneBlue
class node_tiff,node_safe_fs,node_adjustments,node_preview,node_color_management toneAmber
class node_preflight,node_recipe,node_conversion_queue,node_workflow,node_worker,node_tiff_output,node_transaction,node_acceptance,node_export_queue toneMint
class node_windows toneRose
```

## Components

### Desktop application

- [Application entry](https://github.com/emadgh/windows-shade-editor/blob/main/src/main.rs): Rust executable · `src/main.rs`
- [egui UI and input](https://github.com/emadgh/windows-shade-editor/blob/main/src/ui/mod.rs): UI layer · `src/ui/mod.rs`
- [Controllers and features](https://github.com/emadgh/windows-shade-editor/blob/main/src/app_controllers.rs): command boundary · Maps UI intent to application workflows. · `src/app_controllers.rs`
- [Project model](https://github.com/emadgh/windows-shade-editor/blob/main/src/model.rs): project schema · Faces, recipes, roles, snapshots, and provenance in .shade projects. · `src/model.rs`
- [Project lifecycle](https://github.com/emadgh/windows-shade-editor/blob/main/src/project_lifecycle.rs): project orchestration · `src/project_lifecycle.rs`
- [Autosave and recovery](https://github.com/emadgh/windows-shade-editor/blob/main/src/project_autosave.rs): durability service · `src/project_autosave.rs`

### Image pipeline

- [TIFF ingest and inspection](https://github.com/emadgh/windows-shade-editor/blob/main/src/tiff_io.rs): source-file boundary · Decodes dynamic channels and extracts ICC and Photoshop metadata. · `src/tiff_io.rs`
- [Safe filesystem paths](https://github.com/emadgh/windows-shade-editor/blob/main/src/safe_fs.rs): filesystem safety · Validates paths and supports atomic file operations and relinking. · `src/safe_fs.rs`
- [Adjustment recipes](https://github.com/emadgh/windows-shade-editor/blob/main/src/adjustment_tools.rs): non-destructive processing · Applies Levels, N×N mixer, then Curve. · `src/adjustment_tools.rs`
- [Preview rendering](https://github.com/emadgh/windows-shade-editor/blob/main/src/render.rs): viewport renderer · Renders previews without modifying source pixels. · `src/render.rs`
- [Preview color management](https://github.com/emadgh/windows-shade-editor/blob/main/src/color_management.rs): ICC transform · Uses embedded or assigned profiles, sRGB transforms, and soft proofing. · `src/color_management.rs`

### Production output

- [Conversion preflight](https://github.com/emadgh/windows-shade-editor/blob/main/src/conversion_preflight.rs): production validation · Validates profiles, topology, precision, and destination safety. · `src/conversion_preflight.rs`
- [Conversion recipe](https://github.com/emadgh/windows-shade-editor/blob/main/src/conversion_recipe.rs): production recipe · Captures hash-verified source and target ICC or DeviceLink setup. · `src/conversion_recipe.rs`
- [Persistent conversion queue](https://github.com/emadgh/windows-shade-editor/blob/main/src/conversion_queue.rs): durable background queue · Supports restart, pause, retry, progress, and pre-commit cancellation. · `src/conversion_queue.rs`
- [Conversion workflow](https://github.com/emadgh/windows-shade-editor/blob/main/src/conversion_workflow.rs): transaction coordinator · Serializes immutable captures and coordinates conversion, commit, and recovery. · `src/conversion_workflow.rs`
- [ICC conversion worker](https://github.com/emadgh/windows-shade-editor/blob/main/src/icc_conversion_worker.rs): disk-backed renderer · Renders saved state to mmap spool and performs ICC conversion. · `src/icc_conversion_worker.rs`
- [Staged TIFF writer](https://github.com/emadgh/windows-shade-editor/blob/main/src/conversion_tiff.rs): production encoder · Writes bounded strips with separated inks and authoritative names. · `src/conversion_tiff.rs`
- [Atomic output commit](https://github.com/emadgh/windows-shade-editor/blob/main/src/conversion_transaction.rs): file transaction · Retains recovery payloads when post-commit linking fails. · `src/conversion_transaction.rs`
- [Production acceptance](https://github.com/emadgh/windows-shade-editor/blob/main/src/production_acceptance.rs): output validation · Checks TIFF transport, metadata retention, profiles, and round trips. · `src/production_acceptance.rs`
- [Export queue](https://github.com/emadgh/windows-shade-editor/blob/main/src/export_queue.rs): parallel export queue · Runs normal full-resolution TIFF exports and batches. · `src/export_queue.rs`

### Windows integration

- [Windows ICC and shell support](https://github.com/emadgh/windows-shade-editor/blob/main/shell/ShadeEditorShell.cpp): Windows integration · Provides ICC catalog and optional Explorer Shell extension. · `shell/ShadeEditorShell.cpp`

## Connections

- Application entry → egui UI and input: starts
- Application entry → Project lifecycle: initializes
- egui UI and input → Controllers and features: user actions
- Controllers and features → Project lifecycle: project commands
- Project lifecycle → Project model: loads and updates
- Project lifecycle → Autosave and recovery: persists recovery state
- Project lifecycle → TIFF ingest and inspection: ingests faces
- TIFF ingest and inspection → Project model: source metadata and channels
- Safe filesystem paths → Project lifecycle: safe paths and relinking
- Project model → Adjustment recipes: stores recipes
- Adjustment recipes → Preview rendering: applies recipe
- TIFF ingest and inspection → Preview rendering: immutable source pixels
- Preview color management → Preview rendering: display transform
- Controllers and features → Conversion preflight: requests production setup
- Project model → Conversion recipe: saved conversion state
- Conversion preflight → Conversion recipe: validates
- Conversion recipe → Persistent conversion queue: immutable capture
- Persistent conversion queue → Conversion workflow: scheduled job
- Conversion workflow → ICC conversion worker: renders and converts
- Adjustment recipes → ICC conversion worker: production-order state
- ICC conversion worker → Staged TIFF writer: converted strips
- Staged TIFF writer → Production acceptance: staged output
- Production acceptance → Atomic output commit: accepted TIFF
- Atomic output commit → Project model: committed output link
- Conversion workflow → Autosave and recovery: failure recovery payload
- Controllers and features → Export queue: export requests
- Windows ICC and shell support → Conversion preflight: installed ICC catalog
