# eddyxorb/fotobuch architecture

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

- Interactive diagram: https://gitdiagram.com/eddyxorb/fotobuch
- Repository: https://github.com/eddyxorb/fotobuch

## Overview

fotobuch turns photo collections into print-ready photobooks through either a GUI or CLI, sharing a Rust project engine. The main workflow imports and organizes photos, assigns and optimizes page layouts, then renders a PDF; users can refine pages, configure projects, and undo changes. The README documents the product capabilities and shared workflow; sampled source and the SOURCE INDEX support selected internal relationships. Some GUI and command internals were not sampled, so those connections are shown only where documented.

Main entry points: [`src/commands.rs`](https://github.com/eddyxorb/fotobuch/blob/main/src/commands.rs) (Project Commands), [`gui/app.rs`](https://github.com/eddyxorb/fotobuch/blob/main/gui/app.rs) (Desktop App), [`src/input/scan.rs`](https://github.com/eddyxorb/fotobuch/blob/main/src/input/scan.rs) (Photo Import), [`cli/cli.rs`](https://github.com/eddyxorb/fotobuch/blob/main/cli/cli.rs) (Command Line)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontends["User Interfaces"]
  node_cli["Command Line<br/>[cli.rs]"]
  node_gui["Desktop App<br/>[app.rs]"]
  node_manual["Page Editing<br/>[drag.rs]"]
end

subgraph group_project["Project Management"]
  node_models["Project Models<br/>[models.rs]"]
  node_state["Project State<br/>[state_manager.rs]"]
  node_history["Git History<br/>[git.rs]"]
  node_commands["Project Commands<br/>[commands.rs]"]
  node_config["Project Configuration<br/>[config.rs]"]
end

subgraph group_layout["Layout Engine"]
  node_solver["Book Layout Solver<br/>[local_search.rs]"]
  node_assignment["Page Assignment<br/>[bellman_dp.rs]"]
  node_page_solver["Page Layout Solver"]
  node_genetic["Genetic Search<br/>[engine.rs]"]
end

subgraph group_media["Media Pipeline"]
  node_input["Photo Import<br/>[scan.rs]"]
  node_metadata["Photo Metadata<br/>[exif.rs]"]
  node_preview_cache[("Preview Cache<br/>[preview_cache.rs]")]
  node_release_cache[("Release Cache<br/>[final_cache.rs]")]
end

subgraph group_output["Rendering"]
  node_typst["Typst Document<br/>[typst.rs]"]
  node_pdf["Print PDF<br/>[render.rs]"]
end

node_photographer(("Photographer"))
node_printing(("Print Service"))

node_photographer -->|"uses app"| node_gui
node_photographer -->|"runs commands"| node_cli
node_gui -->|"imports photos"| node_input
node_cli -->|"adds photos"| node_input
node_input -->|"reads metadata"| node_metadata
node_input -->|"creates photo groups"| node_models
node_gui -->|"dispatches actions"| node_commands
node_cli -->|"dispatches commands"| node_commands
node_commands -->|"updates project"| node_state
node_state -->|"loads and saves"| node_models
node_state -->|"tracks commits"| node_history
node_photographer -->|"sets preferences"| node_config
node_commands -->|"rebuilds layout"| node_solver
node_solver -->|"assigns pages"| node_assignment
node_solver -->|"optimizes pages"| node_page_solver
node_page_solver -->|"evolves layouts"| node_genetic
node_gui -->|"handles gestures"| node_manual
node_manual -->|"saves refinements"| node_commands
node_commands -->|"builds preview"| node_preview_cache
node_commands -->|"builds release cache"| node_release_cache
node_preview_cache -->|"uses metadata"| node_metadata
node_commands -->|"generates document"| node_typst
node_typst -->|"compiles PDF"| node_pdf
node_pdf -->|"provides print file"| node_printing

click node_cli "https://github.com/eddyxorb/fotobuch/blob/main/cli/cli.rs"
click node_gui "https://github.com/eddyxorb/fotobuch/blob/main/gui/app.rs"
click node_input "https://github.com/eddyxorb/fotobuch/blob/main/src/input/scan.rs"
click node_metadata "https://github.com/eddyxorb/fotobuch/blob/main/src/input/exif.rs"
click node_models "https://github.com/eddyxorb/fotobuch/blob/main/src/models.rs"
click node_state "https://github.com/eddyxorb/fotobuch/blob/main/src/state_manager.rs"
click node_history "https://github.com/eddyxorb/fotobuch/blob/main/src/git.rs"
click node_commands "https://github.com/eddyxorb/fotobuch/blob/main/src/commands.rs"
click node_config "https://github.com/eddyxorb/fotobuch/blob/main/src/models/config.rs"
click node_solver "https://github.com/eddyxorb/fotobuch/blob/main/src/solver/book_layout_solver/local_search.rs"
click node_assignment "https://github.com/eddyxorb/fotobuch/blob/main/src/solver/algorithms/bellman_dp.rs"
click node_page_solver "https://github.com/eddyxorb/fotobuch/blob/main/src/solver/page_layout_solver.rs"
click node_genetic "https://github.com/eddyxorb/fotobuch/blob/main/src/solver/algorithms/genetic_algorithm/engine.rs"
click node_manual "https://github.com/eddyxorb/fotobuch/blob/main/gui/app/input_handler/drag.rs"
click node_preview_cache "https://github.com/eddyxorb/fotobuch/blob/main/src/cache/preview_cache.rs"
click node_release_cache "https://github.com/eddyxorb/fotobuch/blob/main/src/cache/final_cache.rs"
click node_typst "https://github.com/eddyxorb/fotobuch/blob/main/src/output/typst.rs"
click node_pdf "https://github.com/eddyxorb/fotobuch/blob/main/src/output/render.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_cli,node_gui,node_manual toneBlue
class node_models,node_state,node_history,node_commands,node_config toneAmber
class node_solver,node_assignment,node_page_solver,node_genetic toneMint
class node_input,node_metadata,node_preview_cache,node_release_cache toneRose
class node_typst,node_pdf,node_photographer,node_printing toneIndigo
```

## Components

### User Interfaces

- [Command Line](https://github.com/eddyxorb/fotobuch/blob/main/cli/cli.rs): `cli/cli.rs`
- [Desktop App](https://github.com/eddyxorb/fotobuch/blob/main/gui/app.rs): `gui/app.rs`
- [Page Editing](https://github.com/eddyxorb/fotobuch/blob/main/gui/app/input_handler/drag.rs): `gui/app/input_handler/drag.rs`

### Project Management

- [Project Models](https://github.com/eddyxorb/fotobuch/blob/main/src/models.rs): `src/models.rs`
- [Project State](https://github.com/eddyxorb/fotobuch/blob/main/src/state_manager.rs): `src/state_manager.rs`
- [Git History](https://github.com/eddyxorb/fotobuch/blob/main/src/git.rs): `src/git.rs`
- [Project Commands](https://github.com/eddyxorb/fotobuch/blob/main/src/commands.rs): `src/commands.rs`
- [Project Configuration](https://github.com/eddyxorb/fotobuch/blob/main/src/models/config.rs): `src/models/config.rs`

### Layout Engine

- [Book Layout Solver](https://github.com/eddyxorb/fotobuch/blob/main/src/solver/book_layout_solver/local_search.rs): `src/solver/book_layout_solver/local_search.rs`
- [Page Assignment](https://github.com/eddyxorb/fotobuch/blob/main/src/solver/algorithms/bellman_dp.rs): `src/solver/algorithms/bellman_dp.rs`
- [Page Layout Solver](https://github.com/eddyxorb/fotobuch/blob/main/src/solver/page_layout_solver.rs): `src/solver/page_layout_solver.rs`
- [Genetic Search](https://github.com/eddyxorb/fotobuch/blob/main/src/solver/algorithms/genetic_algorithm/engine.rs): `src/solver/algorithms/genetic_algorithm/engine.rs`

### Media Pipeline

- [Photo Import](https://github.com/eddyxorb/fotobuch/blob/main/src/input/scan.rs): `src/input/scan.rs`
- [Photo Metadata](https://github.com/eddyxorb/fotobuch/blob/main/src/input/exif.rs): `src/input/exif.rs`
- [Preview Cache](https://github.com/eddyxorb/fotobuch/blob/main/src/cache/preview_cache.rs): `src/cache/preview_cache.rs`
- [Release Cache](https://github.com/eddyxorb/fotobuch/blob/main/src/cache/final_cache.rs): `src/cache/final_cache.rs`

### Rendering

- [Typst Document](https://github.com/eddyxorb/fotobuch/blob/main/src/output/typst.rs): `src/output/typst.rs`
- [Print PDF](https://github.com/eddyxorb/fotobuch/blob/main/src/output/render.rs): `src/output/render.rs`

### Other components

- **Photographer**
- **Print Service**

## Connections

- Photographer → Desktop App: uses app
- Photographer → Command Line: runs commands
- Desktop App → Photo Import: imports photos
- Command Line → Photo Import: adds photos
- Photo Import → Photo Metadata: reads metadata (evidence: `src/input/scan.rs`)
- Photo Import → Project Models: creates photo groups (evidence: `src/input/scan.rs`)
- Desktop App → Project Commands: dispatches actions
- Command Line → Project Commands: dispatches commands (evidence: `cli/cli.rs`)
- Project Commands → Project State: updates project (evidence: `src/commands.rs`)
- Project State → Project Models: loads and saves (evidence: `src/state_manager.rs`)
- Project State → Git History: tracks commits (evidence: `src/state_manager.rs`)
- Photographer → Project Configuration: sets preferences
- Project Commands → Book Layout Solver: rebuilds layout
- Book Layout Solver → Page Assignment: assigns pages
- Book Layout Solver → Page Layout Solver: optimizes pages (evidence: `src/solver/book_layout_solver/local_search.rs`)
- Page Layout Solver → Genetic Search: evolves layouts
- Desktop App → Page Editing: handles gestures
- Page Editing → Project Commands: saves refinements
- Project Commands → Preview Cache: builds preview
- Project Commands → Release Cache: builds release cache
- Preview Cache → Photo Metadata: uses metadata (evidence: `src/cache/preview_cache.rs`)
- Project Commands → Typst Document: generates document
- Typst Document → Print PDF: compiles PDF (evidence: `src/output/typst.rs`)
- Print PDF → Print Service: provides print file
