# sha5b/photo-focus-stacker architecture

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

- Interactive diagram: https://gitdiagram.com/sha5b/photo-focus-stacker
- Repository: https://github.com/sha5b/photo-focus-stacker

## Overview

Photo Focus Stacker is a desktop and command-line application for combining images captured at different focus distances. Users load images, group them into stacks, choose processing and output settings, run alignment and focus analysis, then save a fused image and optional depth, confidence, and alignment reports. The graph distinguishes UI orchestration from the core processing pipeline and image I/O. Some capabilities, including cache behavior and RAW support, are documented but their implementation details were not sampled.

Main entry points: [`src/ui/main_window.py`](https://github.com/sha5b/photo-focus-stacker/blob/main/src/ui/main_window.py) (Main window), [`src/core/focus_stacker.py`](https://github.com/sha5b/photo-focus-stacker/blob/main/src/core/focus_stacker.py) (Pipeline orchestrator), [`src/config/settings_store.py`](https://github.com/sha5b/photo-focus-stacker/blob/main/src/config/settings_store.py) (Settings persistence), [`src/cli.py`](https://github.com/sha5b/photo-focus-stacker/blob/main/src/cli.py) (CLI workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and UI"]
  node_cli["CLI workflow<br/>[cli.py]"]
  node_window["Main window<br/>[main_window.py]"]
  node_worker["Stack worker<br/>[stacking_worker.py]"]
end

subgraph group_settings["Settings and grouping"]
  node_settings_store[("Settings persistence<br/>[settings_store.py]")]
  node_stack_settings["Stack settings"]
  node_detection_settings["Detection settings"]
  node_output_settings["Output settings<br/>[output_settings.py]"]
end

subgraph group_services["Stack services"]
  node_stack_detection["Stack detection<br/>[stack_detection.py]"]
  node_auto_tune["Auto tune<br/>[auto_tune.py]"]
end

subgraph group_pipeline["Focus pipeline"]
  node_stacker["Pipeline orchestrator<br/>[focus_stacker.py]"]
  node_alignment["Frame alignment<br/>[alignment.py]"]
  node_focus_measure["Focus measures<br/>[focus_measure.py]"]
  node_depth_blend["Depth and fusion<br/>[blending.py]"]
  node_postprocessing["Postprocessing<br/>[postprocessing.py]"]
end

subgraph group_output["Image output"]
  node_image_io["Image I/O<br/>[utils.py]"]
end

node_user(("Photographer"))
node_rawpy["RAW decoder"]

node_user -->|"runs batch"| node_cli
node_user -->|"uses GUI"| node_window
node_cli -->|"runs pipeline"| node_stacker
node_cli -->|"exports maps"| node_image_io
node_window -->|"loads and saves"| node_settings_store
node_window -->|"groups images"| node_stack_detection
node_window -->|"requests tuning"| node_auto_tune
node_window -->|"starts worker"| node_worker
node_window -->|"configures processing"| node_stack_settings
node_window -->|"configures grouping"| node_detection_settings
node_window -->|"configures output"| node_output_settings
node_settings_store -->|"persists"| node_stack_settings
node_settings_store -->|"persists"| node_detection_settings
node_settings_store -->|"persists"| node_output_settings
node_worker -->|"runs stack"| node_stacker
node_stacker -->|"aligns frames"| node_alignment
node_stacker -->|"computes focus maps"| node_focus_measure
node_stacker -->|"selects depth and fuses"| node_depth_blend
node_stacker -->|"postprocesses result"| node_postprocessing
node_stacker -->|"loads and saves images"| node_image_io
node_image_io -.->|"develops RAW files"| node_rawpy

click node_cli "https://github.com/sha5b/photo-focus-stacker/blob/main/src/cli.py"
click node_window "https://github.com/sha5b/photo-focus-stacker/blob/main/src/ui/main_window.py"
click node_worker "https://github.com/sha5b/photo-focus-stacker/blob/main/src/ui/stacking_worker.py"
click node_settings_store "https://github.com/sha5b/photo-focus-stacker/blob/main/src/config/settings_store.py"
click node_stack_settings "https://github.com/sha5b/photo-focus-stacker/blob/main/src/config/stacking_settings.py"
click node_detection_settings "https://github.com/sha5b/photo-focus-stacker/blob/main/src/config/stack_detection_settings.py"
click node_output_settings "https://github.com/sha5b/photo-focus-stacker/blob/main/src/config/output_settings.py"
click node_stack_detection "https://github.com/sha5b/photo-focus-stacker/blob/main/src/services/stack_detection.py"
click node_auto_tune "https://github.com/sha5b/photo-focus-stacker/blob/main/src/services/auto_tune.py"
click node_stacker "https://github.com/sha5b/photo-focus-stacker/blob/main/src/core/focus_stacker.py"
click node_alignment "https://github.com/sha5b/photo-focus-stacker/blob/main/src/core/alignment.py"
click node_focus_measure "https://github.com/sha5b/photo-focus-stacker/blob/main/src/core/focus_measure.py"
click node_depth_blend "https://github.com/sha5b/photo-focus-stacker/blob/main/src/core/blending.py"
click node_postprocessing "https://github.com/sha5b/photo-focus-stacker/blob/main/src/core/postprocessing.py"
click node_image_io "https://github.com/sha5b/photo-focus-stacker/blob/main/src/core/utils.py"

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_cli,node_window,node_worker toneBlue
class node_settings_store,node_stack_settings,node_detection_settings,node_output_settings toneAmber
class node_stack_detection,node_auto_tune toneMint
class node_stacker,node_alignment,node_focus_measure,node_depth_blend,node_postprocessing toneRose
class node_image_io,node_user,node_rawpy toneIndigo
```

## Components

### Entry and UI

- [CLI workflow](https://github.com/sha5b/photo-focus-stacker/blob/main/src/cli.py): `src/cli.py`
- [Main window](https://github.com/sha5b/photo-focus-stacker/blob/main/src/ui/main_window.py): `src/ui/main_window.py`
- [Stack worker](https://github.com/sha5b/photo-focus-stacker/blob/main/src/ui/stacking_worker.py): `src/ui/stacking_worker.py`

### Settings and grouping

- [Settings persistence](https://github.com/sha5b/photo-focus-stacker/blob/main/src/config/settings_store.py): `src/config/settings_store.py`
- [Stack settings](https://github.com/sha5b/photo-focus-stacker/blob/main/src/config/stacking_settings.py): `src/config/stacking_settings.py`
- [Detection settings](https://github.com/sha5b/photo-focus-stacker/blob/main/src/config/stack_detection_settings.py): `src/config/stack_detection_settings.py`
- [Output settings](https://github.com/sha5b/photo-focus-stacker/blob/main/src/config/output_settings.py): `src/config/output_settings.py`

### Stack services

- [Stack detection](https://github.com/sha5b/photo-focus-stacker/blob/main/src/services/stack_detection.py): `src/services/stack_detection.py`
- [Auto tune](https://github.com/sha5b/photo-focus-stacker/blob/main/src/services/auto_tune.py): `src/services/auto_tune.py`

### Focus pipeline

- [Pipeline orchestrator](https://github.com/sha5b/photo-focus-stacker/blob/main/src/core/focus_stacker.py): `src/core/focus_stacker.py`
- [Frame alignment](https://github.com/sha5b/photo-focus-stacker/blob/main/src/core/alignment.py): `src/core/alignment.py`
- [Focus measures](https://github.com/sha5b/photo-focus-stacker/blob/main/src/core/focus_measure.py): `src/core/focus_measure.py`
- [Depth and fusion](https://github.com/sha5b/photo-focus-stacker/blob/main/src/core/blending.py): `src/core/blending.py`
- [Postprocessing](https://github.com/sha5b/photo-focus-stacker/blob/main/src/core/postprocessing.py): `src/core/postprocessing.py`

### Image output

- [Image I/O](https://github.com/sha5b/photo-focus-stacker/blob/main/src/core/utils.py): `src/core/utils.py`

### Other components

- **Photographer**
- **RAW decoder**

## Connections

- Photographer → CLI workflow: runs batch (evidence: `README.md`)
- Photographer → Main window: uses GUI (evidence: `README.md`)
- CLI workflow → Pipeline orchestrator: runs pipeline (evidence: `src/cli.py`)
- CLI workflow → Image I/O: exports maps (evidence: `src/cli.py`)
- Main window → Settings persistence: loads and saves (evidence: `src/ui/main_window.py`)
- Main window → Stack detection: groups images (evidence: `src/ui/main_window.py`)
- Main window → Auto tune: requests tuning (evidence: `src/ui/main_window.py`)
- Main window → Stack worker: starts worker (evidence: `src/ui/main_window.py`)
- Main window → Stack settings: configures processing (evidence: `src/ui/main_window.py`)
- Main window → Detection settings: configures grouping (evidence: `src/ui/main_window.py`)
- Main window → Output settings: configures output (evidence: `src/ui/main_window.py`)
- Settings persistence → Stack settings: persists (evidence: `src/config/settings_store.py`)
- Settings persistence → Detection settings: persists (evidence: `src/config/settings_store.py`)
- Settings persistence → Output settings: persists (evidence: `src/config/settings_store.py`)
- Stack worker → Pipeline orchestrator: runs stack (evidence: `src/ui/stacking_worker.py`)
- Pipeline orchestrator → Frame alignment: aligns frames (evidence: `src/core/focus_stacker.py`)
- Pipeline orchestrator → Focus measures: computes focus maps (evidence: `src/core/focus_stacker.py`)
- Pipeline orchestrator → Depth and fusion: selects depth and fuses (evidence: `src/core/focus_stacker.py`)
- Pipeline orchestrator → Postprocessing: postprocesses result (evidence: `src/core/focus_stacker.py`)
- Pipeline orchestrator → Image I/O: loads and saves images (evidence: `src/core/focus_stacker.py`)
- Image I/O → RAW decoder: develops RAW files (evidence: `README.md`)
