# aviaviaviwtf/totp-reference-book architecture

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

- Interactive diagram: https://gitdiagram.com/aviaviaviwtf/totp-reference-book
- Repository: https://github.com/aviaviaviwtf/totp-reference-book

## Overview

TOTP Reference Book is a standalone browser app that accepts an authenticator setup, lets users choose edition and time-zone options, generates TOTP reference-book PDFs and a cover, then previews and downloads them. Processing is local to the browser; there is no upload service or persistent session store. The graph preserves the documented workflow and major cover/template capabilities. Some Studio orchestration and download wiring is not shown in the excerpts, so those links are omitted or marked unverified.

Main entry points: [`src/workbench/Studio.tsx`](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/src/workbench/Studio.tsx) (Studio workflow), [`src/pdf.worker.ts`](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/src/pdf.worker.ts) (Interior PDF generator), [`src/print-assets.ts`](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/src/print-assets.ts) (Worker and preview assets), [`lib/cover.ts`](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/cover.ts) (Cover PDF)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Book Workbench"]
  node_app["App entry<br/>[main.tsx]"]
  node_studio["Studio workflow<br/>[Studio.tsx]"]
end

subgraph group_setup["Setup and Options"]
  node_camera["Camera scanner<br/>[CameraScanner.tsx]"]
  node_qr["QR reader<br/>[qr.ts]"]
  node_totp["TOTP setup and codes<br/>[totp.ts]"]
  node_timezones["Time-zone options"]
  node_edition["Edition model<br/>[edition.ts]"]
  node_workbenchmodel["Book options model<br/>[model.ts]"]
end

subgraph group_generation["Book Generation"]
  node_request["PDF request validation<br/>[pdf-request.ts]"]
  node_worker["Interior PDF generator<br/>[pdf.worker.ts]"]
  node_runs["Timetable runs<br/>[timetable-runs.ts]"]
  node_header["Page headers<br/>[page-header.ts]"]
  node_memory["PDF page memory<br/>[pdf-memory.ts]"]
  node_fonts["Print fonts<br/>[print-fonts.ts]"]
end

subgraph group_preview["Preview and Assets"]
  node_assets["Worker and preview assets<br/>[print-assets.ts]"]
  node_pdfpreview["Interior preview<br/>[PdfPreview.tsx]"]
  node_selection["Preview page selection"]
  node_coverpreview["Cover preview<br/>[CoverPreview.tsx]"]
end

subgraph group_cover["Cover Design"]
  node_cover["Cover PDF<br/>[cover.ts]"]
  node_template["Cover PNG template<br/>[template.ts]"]
  node_title["Title handling<br/>[title.ts]"]
end

node_user(("Book creator"))

node_user -->|"opens"| node_app
node_app -->|"renders"| node_studio
node_user -->|"enters setup"| node_studio
node_studio -->|"offers scanning"| node_camera
node_camera -->|"reads image"| node_qr
node_studio -->|"imports setup"| node_qr
node_qr -->|"validates setup"| node_totp
node_studio -->|"parses and generates"| node_totp
node_studio -->|"uses options"| node_timezones
node_studio -->|"uses editions"| node_edition
node_studio -->|"uses model"| node_workbenchmodel
node_studio -.->|"requests PDF"| node_worker
node_worker -->|"validates request"| node_request
node_worker -->|"builds code rows"| node_totp
node_worker -->|"groups timetable"| node_runs
node_worker -->|"labels transitions"| node_header
node_worker -->|"compacts pages"| node_memory
node_worker -->|"loads fonts"| node_fonts
node_request -->|"checks edition"| node_edition
node_request -->|"checks title"| node_title
node_studio -->|"generates cover"| node_cover
node_studio -->|"exports template"| node_template
node_template -->|"uses geometry"| node_cover
node_template -->|"loads font"| node_fonts
node_cover -->|"loads font"| node_fonts
node_studio -->|"prepares print assets"| node_assets
node_assets -->|"loads print fonts"| node_fonts
node_assets -->|"loads cover tools"| node_cover
node_studio -->|"shows review"| node_pdfpreview
node_pdfpreview -->|"prepares renderer"| node_assets
node_pdfpreview -->|"selects pages"| node_selection
node_selection -->|"checks date starts"| node_totp
node_studio -.->|"shows cover"| node_coverpreview
node_coverpreview -->|"generates cover preview"| node_cover
node_coverpreview -->|"loads renderer"| node_assets
node_user -->|"downloads PDFs"| node_studio

click node_app "https://github.com/aviaviaviwtf/totp-reference-book/blob/main/src/main.tsx"
click node_studio "https://github.com/aviaviaviwtf/totp-reference-book/blob/main/src/workbench/Studio.tsx"
click node_camera "https://github.com/aviaviaviwtf/totp-reference-book/blob/main/src/workbench/CameraScanner.tsx"
click node_qr "https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/qr.ts"
click node_totp "https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/totp.ts"
click node_timezones "https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/time-zone-options.ts"
click node_edition "https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/edition.ts"
click node_workbenchmodel "https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/workbench/model.ts"
click node_request "https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/pdf-request.ts"
click node_worker "https://github.com/aviaviaviwtf/totp-reference-book/blob/main/src/pdf.worker.ts"
click node_runs "https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/timetable-runs.ts"
click node_header "https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/page-header.ts"
click node_memory "https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/pdf-memory.ts"
click node_fonts "https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/print-fonts.ts"
click node_assets "https://github.com/aviaviaviwtf/totp-reference-book/blob/main/src/print-assets.ts"
click node_pdfpreview "https://github.com/aviaviaviwtf/totp-reference-book/blob/main/src/workbench/PdfPreview.tsx"
click node_selection "https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/workbench/preview-selection.ts"
click node_coverpreview "https://github.com/aviaviaviwtf/totp-reference-book/blob/main/src/workbench/CoverPreview.tsx"
click node_cover "https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/cover.ts"
click node_template "https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/workbench/template.ts"
click node_title "https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/workbench/title.ts"

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_app,node_studio toneBlue
class node_camera,node_qr,node_totp,node_timezones,node_edition,node_workbenchmodel toneAmber
class node_request,node_worker,node_runs,node_header,node_memory,node_fonts toneMint
class node_assets,node_pdfpreview,node_selection,node_coverpreview toneRose
class node_cover,node_template,node_title,node_user toneIndigo
```

## Components

### Book Workbench

- [App entry](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/src/main.tsx): `src/main.tsx`
- [Studio workflow](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/src/workbench/Studio.tsx): `src/workbench/Studio.tsx`

### Setup and Options

- [Camera scanner](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/src/workbench/CameraScanner.tsx): `src/workbench/CameraScanner.tsx`
- [QR reader](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/qr.ts): `lib/qr.ts`
- [TOTP setup and codes](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/totp.ts): `lib/totp.ts`
- [Time-zone options](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/time-zone-options.ts): `lib/time-zone-options.ts`
- [Edition model](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/edition.ts): `lib/edition.ts`
- [Book options model](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/workbench/model.ts): `lib/workbench/model.ts`

### Book Generation

- [PDF request validation](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/pdf-request.ts): `lib/pdf-request.ts`
- [Interior PDF generator](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/src/pdf.worker.ts): `src/pdf.worker.ts`
- [Timetable runs](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/timetable-runs.ts): `lib/timetable-runs.ts`
- [Page headers](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/page-header.ts): `lib/page-header.ts`
- [PDF page memory](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/pdf-memory.ts): `lib/pdf-memory.ts`
- [Print fonts](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/print-fonts.ts): `lib/print-fonts.ts`

### Preview and Assets

- [Worker and preview assets](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/src/print-assets.ts): `src/print-assets.ts`
- [Interior preview](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/src/workbench/PdfPreview.tsx): `src/workbench/PdfPreview.tsx`
- [Preview page selection](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/workbench/preview-selection.ts): `lib/workbench/preview-selection.ts`
- [Cover preview](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/src/workbench/CoverPreview.tsx): `src/workbench/CoverPreview.tsx`

### Cover Design

- [Cover PDF](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/cover.ts): `lib/cover.ts`
- [Cover PNG template](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/workbench/template.ts): `lib/workbench/template.ts`
- [Title handling](https://github.com/aviaviaviwtf/totp-reference-book/blob/main/lib/workbench/title.ts): `lib/workbench/title.ts`

### Other components

- **Book creator**

## Connections

- Book creator → App entry: opens (evidence: `README.md`)
- App entry → Studio workflow: renders (evidence: `src/main.tsx`)
- Book creator → Studio workflow: enters setup (evidence: `README.md`)
- Studio workflow → Camera scanner: offers scanning (evidence: `src/workbench/Studio.tsx`)
- Camera scanner → QR reader: reads image (evidence: `src/workbench/CameraScanner.tsx`)
- Studio workflow → QR reader: imports setup (evidence: `src/workbench/Studio.tsx`)
- QR reader → TOTP setup and codes: validates setup (evidence: `lib/qr.ts`)
- Studio workflow → TOTP setup and codes: parses and generates (evidence: `src/workbench/Studio.tsx`)
- Studio workflow → Time-zone options: uses options (evidence: `src/workbench/Studio.tsx`)
- Studio workflow → Edition model: uses editions (evidence: `src/workbench/Studio.tsx`)
- Studio workflow → Book options model: uses model (evidence: `src/workbench/Studio.tsx`)
- Studio workflow → Interior PDF generator: requests PDF
- Interior PDF generator → PDF request validation: validates request (evidence: `src/pdf.worker.ts`)
- Interior PDF generator → TOTP setup and codes: builds code rows (evidence: `src/pdf.worker.ts`)
- Interior PDF generator → Timetable runs: groups timetable (evidence: `src/pdf.worker.ts`)
- Interior PDF generator → Page headers: labels transitions (evidence: `src/pdf.worker.ts`)
- Interior PDF generator → PDF page memory: compacts pages (evidence: `src/pdf.worker.ts`)
- Interior PDF generator → Print fonts: loads fonts (evidence: `src/pdf.worker.ts`)
- PDF request validation → Edition model: checks edition (evidence: `lib/pdf-request.ts`)
- PDF request validation → Title handling: checks title (evidence: `lib/pdf-request.ts`)
- Studio workflow → Cover PDF: generates cover (evidence: `src/workbench/Studio.tsx`)
- Studio workflow → Cover PNG template: exports template (evidence: `src/workbench/Studio.tsx`)
- Cover PNG template → Cover PDF: uses geometry (evidence: `lib/workbench/template.ts`)
- Cover PNG template → Print fonts: loads font (evidence: `lib/workbench/template.ts`)
- Cover PDF → Print fonts: loads font (evidence: `lib/cover.ts`)
- Studio workflow → Worker and preview assets: prepares print assets (evidence: `src/workbench/Studio.tsx`)
- Worker and preview assets → Print fonts: loads print fonts (evidence: `src/print-assets.ts`)
- Worker and preview assets → Cover PDF: loads cover tools (evidence: `src/print-assets.ts`)
- Studio workflow → Interior preview: shows review (evidence: `src/workbench/Studio.tsx`)
- Interior preview → Worker and preview assets: prepares renderer (evidence: `src/workbench/PdfPreview.tsx`)
- Interior preview → Preview page selection: selects pages (evidence: `src/workbench/PdfPreview.tsx`)
- Preview page selection → TOTP setup and codes: checks date starts (evidence: `lib/workbench/preview-selection.ts`)
- Studio workflow → Cover preview: shows cover (evidence: `src/workbench/Studio.tsx`)
- Cover preview → Cover PDF: generates cover preview (evidence: `src/workbench/CoverPreview.tsx`)
- Cover preview → Worker and preview assets: loads renderer (evidence: `src/workbench/CoverPreview.tsx`)
- Book creator → Studio workflow: downloads PDFs (evidence: `README.md`)
