# kar-ton/flatstitch architecture

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

- Interactive diagram: https://gitdiagram.com/kar-ton/flatstitch
- Repository: https://github.com/kar-ton/flatstitch

## Overview

flatstitch is a Linux CLI and desktop application for stitching flatbed scans into a TIFF. Users provide scan files through the CLI or a desktop interface, choose stitching settings, and receive one or more stitched outputs. The shared pipeline loads images, extracts features, registers scan pairs with rigid transforms, computes a layout, composites tiles, and writes TIFFs. GUI options include Tk, GTK, and Qt; native frontends dispatch work through shared subprocess helpers. The graph follows the sampled pipeline and source-index references; some GUI and output details are documented rather than fully excerpted.

Main entry points: [`flatstitch/pipeline.py`](https://github.com/kar-ton/flatstitch/blob/main/flatstitch/pipeline.py) (Stitch pipeline), [`flatstitch/i18n.py`](https://github.com/kar-ton/flatstitch/blob/main/flatstitch/i18n.py) (Translations), [`flatstitch_launcher.py`](https://github.com/kar-ton/flatstitch/blob/main/flatstitch_launcher.py) (GUI launcher), [`flatstitch_gui.py`](https://github.com/kar-ton/flatstitch/blob/main/flatstitch_gui.py) (Tk interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_cli["CLI<br/>[cli.py]"]
  node_launcher["GUI launcher"]
  node_tk["Tk interface<br/>[flatstitch_gui.py]"]
  node_gtk["GTK interface<br/>[flatstitch_gtk.py]"]
  node_qt["Qt interface<br/>[flatstitch_qt.py]"]
  node_native["Native helpers"]
end

subgraph group_workflow["Stitch workflow"]
  node_pipeline["Stitch pipeline<br/>[pipeline.py]"]
end

subgraph group_imaging["Image processing"]
  node_features["Feature extraction<br/>[features.py]"]
  node_registration["Pair registration<br/>[registration.py]"]
  node_compositor["Tile compositor<br/>[compositor.py]"]
  node_imageio["Image I/O<br/>[io_utils.py]"]
  node_preview["Image preview<br/>[preview.py]"]
end

subgraph group_support["Shared support"]
  node_translations["Translations<br/>[i18n.py]"]
  node_locales["Locale catalogs"]
  node_config["GUI settings"]
end

node_user(("Scan user"))
node_result["Stitched TIFF"]

node_user -->|"supplies scans"| node_cli
node_user -->|"opens GUI"| node_launcher
node_launcher -->|"selects fallback"| node_tk
node_launcher -->|"selects toolkit"| node_gtk
node_launcher -->|"selects toolkit"| node_qt
node_tk -->|"runs stitching"| node_pipeline
node_gtk -->|"dispatches work"| node_native
node_qt -->|"dispatches work"| node_native
node_native -->|"starts subprocess"| node_cli
node_cli -->|"calls stitch"| node_pipeline
node_pipeline -->|"loads images"| node_imageio
node_pipeline -->|"extracts features"| node_features
node_pipeline -->|"registers pairs"| node_registration
node_pipeline -->|"composites tiles"| node_compositor
node_pipeline -->|"writes TIFF"| node_imageio
node_registration -->|"matches descriptors"| node_features
node_preview -->|"loads source"| node_imageio
node_pipeline -->|"produces"| node_result
node_cli -->|"localizes messages"| node_translations
node_features -->|"localizes messages"| node_translations
node_imageio -->|"localizes errors"| node_translations
node_pipeline -->|"localizes progress"| node_translations
node_translations -->|"loads catalogs"| node_locales
node_tk -->|"uses language"| node_translations
node_gtk -->|"uses language"| node_translations
node_qt -->|"uses language"| node_translations
node_native -->|"loads settings"| node_config
node_tk -.->|"shares settings"| node_config
node_gtk -.->|"shares settings"| node_config
node_qt -.->|"shares settings"| node_config

click node_cli "https://github.com/kar-ton/flatstitch/blob/main/flatstitch/cli.py"
click node_launcher "https://github.com/kar-ton/flatstitch/blob/main/flatstitch_launcher.py"
click node_tk "https://github.com/kar-ton/flatstitch/blob/main/flatstitch_gui.py"
click node_gtk "https://github.com/kar-ton/flatstitch/blob/main/flatstitch_gtk.py"
click node_qt "https://github.com/kar-ton/flatstitch/blob/main/flatstitch_qt.py"
click node_native "https://github.com/kar-ton/flatstitch/blob/main/flatstitch_native_common.py"
click node_pipeline "https://github.com/kar-ton/flatstitch/blob/main/flatstitch/pipeline.py"
click node_features "https://github.com/kar-ton/flatstitch/blob/main/flatstitch/features.py"
click node_registration "https://github.com/kar-ton/flatstitch/blob/main/flatstitch/registration.py"
click node_compositor "https://github.com/kar-ton/flatstitch/blob/main/flatstitch/compositor.py"
click node_imageio "https://github.com/kar-ton/flatstitch/blob/main/flatstitch/io_utils.py"
click node_preview "https://github.com/kar-ton/flatstitch/blob/main/flatstitch/preview.py"
click node_translations "https://github.com/kar-ton/flatstitch/blob/main/flatstitch/i18n.py"
click node_locales "https://github.com/kar-ton/flatstitch/tree/main/flatstitch/locales"
click node_config "https://github.com/kar-ton/flatstitch/blob/main/flatstitch_native_common.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_launcher,node_tk,node_gtk,node_qt,node_native,node_user toneBlue
class node_pipeline toneAmber
class node_features,node_registration,node_compositor,node_imageio,node_preview toneMint
class node_translations,node_locales,node_config toneRose
class node_result toneIndigo
```

## Components

### User interfaces

- [CLI](https://github.com/kar-ton/flatstitch/blob/main/flatstitch/cli.py): `flatstitch/cli.py`
- [GUI launcher](https://github.com/kar-ton/flatstitch/blob/main/flatstitch_launcher.py): `flatstitch_launcher.py`
- [Tk interface](https://github.com/kar-ton/flatstitch/blob/main/flatstitch_gui.py): `flatstitch_gui.py`
- [GTK interface](https://github.com/kar-ton/flatstitch/blob/main/flatstitch_gtk.py): `flatstitch_gtk.py`
- [Qt interface](https://github.com/kar-ton/flatstitch/blob/main/flatstitch_qt.py): `flatstitch_qt.py`
- [Native helpers](https://github.com/kar-ton/flatstitch/blob/main/flatstitch_native_common.py): `flatstitch_native_common.py`

### Stitch workflow

- [Stitch pipeline](https://github.com/kar-ton/flatstitch/blob/main/flatstitch/pipeline.py): `flatstitch/pipeline.py`

### Image processing

- [Feature extraction](https://github.com/kar-ton/flatstitch/blob/main/flatstitch/features.py): `flatstitch/features.py`
- [Pair registration](https://github.com/kar-ton/flatstitch/blob/main/flatstitch/registration.py): `flatstitch/registration.py`
- [Tile compositor](https://github.com/kar-ton/flatstitch/blob/main/flatstitch/compositor.py): `flatstitch/compositor.py`
- [Image I/O](https://github.com/kar-ton/flatstitch/blob/main/flatstitch/io_utils.py): `flatstitch/io_utils.py`
- [Image preview](https://github.com/kar-ton/flatstitch/blob/main/flatstitch/preview.py): `flatstitch/preview.py`

### Shared support

- [Translations](https://github.com/kar-ton/flatstitch/blob/main/flatstitch/i18n.py): `flatstitch/i18n.py`
- [Locale catalogs](https://github.com/kar-ton/flatstitch/tree/main/flatstitch/locales): `flatstitch/locales`
- [GUI settings](https://github.com/kar-ton/flatstitch/blob/main/flatstitch_native_common.py): `flatstitch_native_common.py`

### Other components

- **Scan user**
- **Stitched TIFF**

## Connections

- Scan user → CLI: supplies scans (evidence: `README.md`)
- Scan user → GUI launcher: opens GUI (evidence: `README.md`)
- GUI launcher → Tk interface: selects fallback (evidence: `flatstitch_launcher.py`)
- GUI launcher → GTK interface: selects toolkit (evidence: `flatstitch_launcher.py`)
- GUI launcher → Qt interface: selects toolkit (evidence: `flatstitch_launcher.py`)
- Tk interface → Stitch pipeline: runs stitching (evidence: `flatstitch_gui.py`)
- GTK interface → Native helpers: dispatches work (evidence: `flatstitch_gtk.py`)
- Qt interface → Native helpers: dispatches work (evidence: `flatstitch_qt.py`)
- Native helpers → CLI: starts subprocess (evidence: `flatstitch_native_common.py`)
- CLI → Stitch pipeline: calls stitch (evidence: `flatstitch/cli.py`)
- Stitch pipeline → Image I/O: loads images (evidence: `flatstitch/pipeline.py`)
- Stitch pipeline → Feature extraction: extracts features (evidence: `flatstitch/pipeline.py`)
- Stitch pipeline → Pair registration: registers pairs (evidence: `flatstitch/pipeline.py`)
- Stitch pipeline → Tile compositor: composites tiles (evidence: `flatstitch/pipeline.py`)
- Stitch pipeline → Image I/O: writes TIFF (evidence: `flatstitch/pipeline.py`)
- Pair registration → Feature extraction: matches descriptors (evidence: `flatstitch/registration.py`)
- Image preview → Image I/O: loads source (evidence: `flatstitch/preview.py`)
- Stitch pipeline → Stitched TIFF: produces (evidence: `README.md`)
- CLI → Translations: localizes messages (evidence: `flatstitch/cli.py`)
- Feature extraction → Translations: localizes messages (evidence: `flatstitch/features.py`)
- Image I/O → Translations: localizes errors (evidence: `flatstitch/io_utils.py`)
- Stitch pipeline → Translations: localizes progress (evidence: `flatstitch/pipeline.py`)
- Translations → Locale catalogs: loads catalogs (evidence: `flatstitch/i18n.py`)
- Tk interface → Translations: uses language (evidence: `flatstitch_gui.py`)
- GTK interface → Translations: uses language (evidence: `flatstitch_gtk.py`)
- Qt interface → Translations: uses language (evidence: `flatstitch_qt.py`)
- Native helpers → GUI settings: loads settings (evidence: `flatstitch_native_common.py`)
- Tk interface → GUI settings: shares settings (evidence: `README.md`)
- GTK interface → GUI settings: shares settings (evidence: `README.md`)
- Qt interface → GUI settings: shares settings (evidence: `README.md`)
