# blankaii/pdf2zh-link-repair architecture

> Architecture diagram of the GitHub repository blankaii/pdf2zh-link-repair, 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/blankaii/pdf2zh-link-repair
- Repository: https://github.com/blankaii/pdf2zh-link-repair

## Overview

A single-file Python CLI repairs links in translated PDFs using separate dual and mono strategies. The graph preserves the documented stages and reporting capabilities, but the excerpt omits key function bodies, so unshown internal calls are not asserted.

Main entry points: [`pdf2zh-link-repair.py`](https://github.com/blankaii/pdf2zh-link-repair/blob/main/pdf2zh-link-repair.py) (Dual-mode reconstruction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Repair workflow"]
  node_cli["CLI and mode selection"]
  node_inputs["Source and translated PDFs"]
end

subgraph group_methods["Repair methods"]
  node_dual["Dual-mode reconstruction"]
  node_features["Text feature matching"]
  node_geometry["Page geometry fitting"]
  node_mono["Mono-mode validation"]
  node_destinations["Destination recovery"]
  node_pymupdf["PyMuPDF PDF API"]
end

subgraph group_results["Validation and reports"]
  node_repaired["Repaired PDF"]
  node_audit["Repair audit"]
  node_coverage["Link coverage report"]
end

node_user(("PDF operator"))
node_viewer(("PDF viewer"))

node_user -->|"runs"| node_cli
node_user -->|"provides"| node_inputs
node_cli -->|"dispatches dual"| node_dual
node_cli -->|"dispatches mono"| node_mono
node_cli -->|"writes output"| node_repaired
node_dual -.->|"matches text"| node_features
node_dual -.->|"fits transform"| node_geometry
node_dual -.->|"repairs targets"| node_destinations
node_mono -.->|"normalizes targets"| node_destinations
node_dual -.->|"edits PDF"| node_pymupdf
node_mono -.->|"edits PDF"| node_pymupdf
node_dual -->|"writes audit"| node_audit
node_mono -->|"writes report"| node_coverage
node_user -->|"checks links"| node_viewer
node_viewer -->|"opens"| node_repaired

click node_cli "https://github.com/blankaii/pdf2zh-link-repair/blob/main/pdf2zh-link-repair.py"
click node_dual "https://github.com/blankaii/pdf2zh-link-repair/blob/main/pdf2zh-link-repair.py"
click node_features "https://github.com/blankaii/pdf2zh-link-repair/blob/main/pdf2zh-link-repair.py"
click node_geometry "https://github.com/blankaii/pdf2zh-link-repair/blob/main/pdf2zh-link-repair.py"
click node_mono "https://github.com/blankaii/pdf2zh-link-repair/blob/main/pdf2zh-link-repair.py"
click node_destinations "https://github.com/blankaii/pdf2zh-link-repair/blob/main/pdf2zh-link-repair.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_inputs,node_viewer toneBlue
class node_dual,node_features,node_geometry,node_mono,node_destinations,node_pymupdf toneAmber
class node_repaired,node_audit,node_coverage toneMint
class node_user toneIndigo
```

## Components

### Repair workflow

- [CLI and mode selection](https://github.com/blankaii/pdf2zh-link-repair/blob/main/pdf2zh-link-repair.py): `pdf2zh-link-repair.py`
- **Source and translated PDFs**

### Repair methods

- [Dual-mode reconstruction](https://github.com/blankaii/pdf2zh-link-repair/blob/main/pdf2zh-link-repair.py): `pdf2zh-link-repair.py`
- [Text feature matching](https://github.com/blankaii/pdf2zh-link-repair/blob/main/pdf2zh-link-repair.py): `pdf2zh-link-repair.py`
- [Page geometry fitting](https://github.com/blankaii/pdf2zh-link-repair/blob/main/pdf2zh-link-repair.py): `pdf2zh-link-repair.py`
- [Mono-mode validation](https://github.com/blankaii/pdf2zh-link-repair/blob/main/pdf2zh-link-repair.py): `pdf2zh-link-repair.py`
- [Destination recovery](https://github.com/blankaii/pdf2zh-link-repair/blob/main/pdf2zh-link-repair.py): `pdf2zh-link-repair.py`
- **PyMuPDF PDF API**

### Validation and reports

- **Repaired PDF**
- **Repair audit**
- **Link coverage report**

### Other components

- **PDF operator**
- **PDF viewer**

## Connections

- PDF operator → CLI and mode selection: runs (evidence: `README.md`)
- PDF operator → Source and translated PDFs: provides (evidence: `README.md`)
- CLI and mode selection → Dual-mode reconstruction: dispatches dual (evidence: `README.md`)
- CLI and mode selection → Mono-mode validation: dispatches mono (evidence: `README.md`)
- CLI and mode selection → Repaired PDF: writes output (evidence: `README.md`)
- Dual-mode reconstruction → Text feature matching: matches text (evidence: `pdf2zh-link-repair.py`)
- Dual-mode reconstruction → Page geometry fitting: fits transform (evidence: `pdf2zh-link-repair.py`)
- Dual-mode reconstruction → Destination recovery: repairs targets (evidence: `pdf2zh-link-repair.py`)
- Mono-mode validation → Destination recovery: normalizes targets (evidence: `pdf2zh-link-repair.py`)
- Dual-mode reconstruction → PyMuPDF PDF API: edits PDF
- Mono-mode validation → PyMuPDF PDF API: edits PDF
- Dual-mode reconstruction → Repair audit: writes audit (evidence: `README.md`)
- Mono-mode validation → Link coverage report: writes report (evidence: `README.md`)
- PDF operator → PDF viewer: checks links (evidence: `README.md`)
- PDF viewer → Repaired PDF: opens (evidence: `README.md`)
