# rodyager/rwts-pdfwriter architecture

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

- Interactive diagram: https://gitdiagram.com/rodyager/rwts-pdfwriter
- Repository: https://github.com/rodyager/rwts-pdfwriter

## Overview

RWTS PDFwriter is a macOS print-to-PDF driver with a companion utility for setting a user’s PDF destination. The main workflow is: a user prints through macOS, the CUPS backend checks the incoming PDF, selects a user-specific spool directory, and writes a uniquely named PDF there. The utility creates a user-accessible destination by linking a chosen location to that spool directory and can reveal the uninstall location. Backend behavior is visible in source; printer setup and usage are described in the README, so the system-to-backend relationship is documented rather than traced in sampled code.

Main entry points: [`pdfwriter/main.swift`](https://github.com/rodyager/rwts-pdfwriter/blob/master/pdfwriter/main.swift) (CUPS backend), [`PDFWriter Utility/ContentView.swift`](https://github.com/rodyager/rwts-pdfwriter/blob/master/PDFWriter%20Utility/ContentView.swift) (Utility controls), [`PDFWriter Utility/PDFWriter_UtilityApp.swift`](https://github.com/rodyager/rwts-pdfwriter/blob/master/PDFWriter%20Utility/PDFWriter_UtilityApp.swift) (Utility app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_print["Print workflow"]
  node_backend["CUPS backend<br/>[main.swift]"]
  node_pdf_check["PDF validation<br/>[main.swift]"]
  node_user_resolution["User resolution<br/>[main.swift]"]
  node_spool_dir["User spool folder<br/>[main.swift]"]
  node_pdf_output[("PDF output<br/>[main.swift]")]
end

subgraph group_utility["Destination utility"]
  node_utility_app["Utility app"]
  node_content_view["Utility controls<br/>[ContentView.swift]"]
  node_save_panel["Folder chooser<br/>[ContentView.swift]"]
  node_destination_link["Destination link<br/>[ContentView.swift]"]
end

subgraph group_os["macOS services"]
  node_macos_print["macOS printing"]
  node_uninstall_location["Uninstall location"]
  node_filesystem[("macOS filesystem")]
end

node_user(("Printer user"))

node_user -->|"prints document"| node_macos_print
node_macos_print -->|"dispatches job"| node_backend
node_backend -->|"checks input"| node_pdf_check
node_backend -->|"resolves account"| node_user_resolution
node_backend -->|"creates or selects"| node_spool_dir
node_backend -->|"writes PDF"| node_pdf_output
node_user -->|"opens utility"| node_utility_app
node_utility_app -->|"shows"| node_content_view
node_content_view -->|"opens"| node_save_panel
node_content_view -->|"checks or creates"| node_spool_dir
node_content_view -->|"creates"| node_destination_link
node_destination_link -->|"links folder"| node_filesystem
node_content_view -->|"reveals directory"| node_uninstall_location

click node_backend "https://github.com/rodyager/rwts-pdfwriter/blob/master/pdfwriter/main.swift"
click node_pdf_check "https://github.com/rodyager/rwts-pdfwriter/blob/master/pdfwriter/main.swift"
click node_user_resolution "https://github.com/rodyager/rwts-pdfwriter/blob/master/pdfwriter/main.swift"
click node_spool_dir "https://github.com/rodyager/rwts-pdfwriter/blob/master/pdfwriter/main.swift"
click node_pdf_output "https://github.com/rodyager/rwts-pdfwriter/blob/master/pdfwriter/main.swift"
click node_utility_app "https://github.com/rodyager/rwts-pdfwriter/blob/master/PDFWriter%20Utility/PDFWriter_UtilityApp.swift"
click node_content_view "https://github.com/rodyager/rwts-pdfwriter/blob/master/PDFWriter%20Utility/ContentView.swift"
click node_save_panel "https://github.com/rodyager/rwts-pdfwriter/blob/master/PDFWriter%20Utility/ContentView.swift"
click node_destination_link "https://github.com/rodyager/rwts-pdfwriter/blob/master/PDFWriter%20Utility/ContentView.swift"

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_backend,node_pdf_check,node_user_resolution,node_spool_dir,node_pdf_output,node_user toneBlue
class node_utility_app,node_content_view,node_save_panel,node_destination_link toneAmber
class node_macos_print,node_uninstall_location,node_filesystem toneMint
```

## Components

### Print workflow

- [CUPS backend](https://github.com/rodyager/rwts-pdfwriter/blob/master/pdfwriter/main.swift): `pdfwriter/main.swift`
- [PDF validation](https://github.com/rodyager/rwts-pdfwriter/blob/master/pdfwriter/main.swift): `pdfwriter/main.swift`
- [User resolution](https://github.com/rodyager/rwts-pdfwriter/blob/master/pdfwriter/main.swift): `pdfwriter/main.swift`
- [User spool folder](https://github.com/rodyager/rwts-pdfwriter/blob/master/pdfwriter/main.swift): `pdfwriter/main.swift`
- [PDF output](https://github.com/rodyager/rwts-pdfwriter/blob/master/pdfwriter/main.swift): `pdfwriter/main.swift`

### Destination utility

- [Utility app](https://github.com/rodyager/rwts-pdfwriter/blob/master/PDFWriter%20Utility/PDFWriter_UtilityApp.swift): `PDFWriter Utility/PDFWriter_UtilityApp.swift`
- [Utility controls](https://github.com/rodyager/rwts-pdfwriter/blob/master/PDFWriter%20Utility/ContentView.swift): `PDFWriter Utility/ContentView.swift`
- [Folder chooser](https://github.com/rodyager/rwts-pdfwriter/blob/master/PDFWriter%20Utility/ContentView.swift): `PDFWriter Utility/ContentView.swift`
- [Destination link](https://github.com/rodyager/rwts-pdfwriter/blob/master/PDFWriter%20Utility/ContentView.swift): `PDFWriter Utility/ContentView.swift`

### macOS services

- **macOS printing**
- **Uninstall location**
- **macOS filesystem**

### Other components

- **Printer user**

## Connections

- Printer user → macOS printing: prints document (evidence: `README.md`)
- macOS printing → CUPS backend: dispatches job (evidence: `README.md`)
- CUPS backend → PDF validation: checks input (evidence: `pdfwriter/main.swift`)
- CUPS backend → User resolution: resolves account (evidence: `pdfwriter/main.swift`)
- CUPS backend → User spool folder: creates or selects (evidence: `pdfwriter/main.swift`)
- CUPS backend → PDF output: writes PDF (evidence: `pdfwriter/main.swift`)
- Printer user → Utility app: opens utility (evidence: `README.md`)
- Utility app → Utility controls: shows (evidence: `PDFWriter Utility/PDFWriter_UtilityApp.swift`)
- Utility controls → Folder chooser: opens (evidence: `PDFWriter Utility/ContentView.swift`)
- Utility controls → User spool folder: checks or creates (evidence: `PDFWriter Utility/ContentView.swift`)
- Utility controls → Destination link: creates (evidence: `PDFWriter Utility/ContentView.swift`)
- Destination link → macOS filesystem: links folder (evidence: `PDFWriter Utility/ContentView.swift`)
- Utility controls → Uninstall location: reveals directory (evidence: `PDFWriter Utility/ContentView.swift`)
