# rok-git/print_with_stamp architecture

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

- Interactive diagram: https://gitdiagram.com/rok-git/print_with_stamp
- Repository: https://github.com/rok-git/print_with_stamp

## Overview

Print With Stamp is a small macOS CLI that accepts a PDF and stamp/print options, generates a stamped PDF, and optionally submits it to `lp`. Its runtime is concentrated in one Swift source file, so the CLI, page-selection, rendering, PDF-output, and print responsibilities share that path. The README documents a separate Finder Quick Action script that reads configuration and invokes the CLI. The source excerpt is partial, so internal call details are limited; documented workflow links cite the README.

Main entry points: [`Sources/PrintWithStamp/main.swift`](https://github.com/rok-git/print_with_stamp/blob/main/Sources/PrintWithStamp/main.swift) (CLI options), [`scripts/print-with-stamp-finder.sh`](https://github.com/rok-git/print_with_stamp/blob/main/scripts/print-with-stamp-finder.sh) (Finder helper)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflow"]
  node_cli_entry["CLI options<br/>[main.swift]"]
end

subgraph group_pdf["PDF stamping"]
  node_page_selection["Page selection<br/>[main.swift]"]
  node_stamp_render["Stamp rendering<br/>[main.swift]"]
  node_pdf_output["Stamped PDF<br/>[main.swift]"]
end

subgraph group_finder["Finder integration"]
  node_finder_script["Finder helper"]
  node_finder_config["Options config"]
end

node_user(("CLI user"))
node_input_pdf["Input PDF"]
node_output_pdf["Saved PDF"]
node_lp["macOS lp"]

node_user -->|"supplies options"| node_cli_entry
node_input_pdf -->|"provides PDF"| node_cli_entry
node_cli_entry -->|"selects pages"| node_page_selection
node_cli_entry -->|"configures stamp"| node_stamp_render
node_cli_entry -->|"creates PDF"| node_pdf_output
node_pdf_output -->|"saves as"| node_output_pdf
node_cli_entry -->|"submits when enabled"| node_lp
node_finder_config -->|"provides options"| node_finder_script
node_finder_script -->|"invokes"| node_cli_entry

click node_cli_entry "https://github.com/rok-git/print_with_stamp/blob/main/Sources/PrintWithStamp/main.swift"
click node_page_selection "https://github.com/rok-git/print_with_stamp/blob/main/Sources/PrintWithStamp/main.swift"
click node_stamp_render "https://github.com/rok-git/print_with_stamp/blob/main/Sources/PrintWithStamp/main.swift"
click node_pdf_output "https://github.com/rok-git/print_with_stamp/blob/main/Sources/PrintWithStamp/main.swift"
click node_finder_script "https://github.com/rok-git/print_with_stamp/blob/main/scripts/print-with-stamp-finder.sh"

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_entry,node_user toneBlue
class node_page_selection,node_stamp_render,node_pdf_output toneAmber
class node_finder_script,node_finder_config toneMint
class node_input_pdf,node_output_pdf,node_lp toneIndigo
```

## Components

### CLI workflow

- [CLI options](https://github.com/rok-git/print_with_stamp/blob/main/Sources/PrintWithStamp/main.swift): `Sources/PrintWithStamp/main.swift`

### PDF stamping

- [Page selection](https://github.com/rok-git/print_with_stamp/blob/main/Sources/PrintWithStamp/main.swift): `Sources/PrintWithStamp/main.swift`
- [Stamp rendering](https://github.com/rok-git/print_with_stamp/blob/main/Sources/PrintWithStamp/main.swift): `Sources/PrintWithStamp/main.swift`
- [Stamped PDF](https://github.com/rok-git/print_with_stamp/blob/main/Sources/PrintWithStamp/main.swift): `Sources/PrintWithStamp/main.swift`

### Finder integration

- [Finder helper](https://github.com/rok-git/print_with_stamp/blob/main/scripts/print-with-stamp-finder.sh): `scripts/print-with-stamp-finder.sh`
- **Options config**

### Other components

- **CLI user**
- **Input PDF**
- **Saved PDF**
- **macOS lp**

## Connections

- CLI user → CLI options: supplies options (evidence: `README.md`)
- Input PDF → CLI options: provides PDF (evidence: `README.md`)
- CLI options → Page selection: selects pages (evidence: `README.md`)
- CLI options → Stamp rendering: configures stamp (evidence: `README.md`)
- CLI options → Stamped PDF: creates PDF (evidence: `README.md`)
- Stamped PDF → Saved PDF: saves as (evidence: `README.md`)
- CLI options → macOS lp: submits when enabled (evidence: `README.md`)
- Options config → Finder helper: provides options (evidence: `README.md`)
- Finder helper → CLI options: invokes (evidence: `README.md`)
