Skip to content

Project Documentation

Technical reference, guides, and design notes for pdf-anonymizer. The repository is structured as a Python monorepo separating structured extraction, core anonymization logic, the CLI wrapper, and an optional HTTP service.


Monorepo Layout

anonymizer/
├── .github/workflows/          # CI, lint, release, and docs workflows
├── data/                       # Local data directory for sample inputs and outputs
├── docs/                       # MkDocs documentation sources
├── packages/
│   ├── id-extract/             # RE2 + checksum detector (span placements only)
│   ├── pdf-anonymizer-core/    # Core SDK (loaders, recognizers, operators, crypto, eval)
│   ├── pdf-anonymizer-cli/     # Typer CLI wrapper (pdf-anonymizer)
│   └── pdf-anonymizer-api/     # Optional FastAPI service (depends on core only)
├── tests/                      # Pytest suite, fuzz tests, and gold-corpus eval harness
├── Makefile                    # Developer task targets
├── pyproject.toml              # Workspace and dependency configuration
└── mkdocs.yml                  # Documentation site configuration

Packages

  • id-extract — Deterministic RE2 and checksum detector returning character offsets without modifying text. Ships every bundled country; filter at call time via countries= or --countries. See id-extract.
  • pdf-anonymizer-core — Document loaders (PDF via pymupdf4llm or Tesseract OCR, Markdown, plain text, .docx, .csv, .xlsx), hybrid detection (RE2, optional local GLiNER NER, multi-provider LLM router), prompt templates (simple, detailed, hipaa), span-based replacement, per-type operators, optional CSV/Excel \(k\)-anonymity (table_privacy), mapping encryption, residual verification, and linkage-risk reporting.
  • pdf-anonymizer-cli — Typer CLI (run, deanonymize, verify, report, apply, purge) handling .env loading and standard output directories.
  • pdf-anonymizer-api — Optional local FastAPI service depending only on pdf-anonymizer-core.

Guide Index

Guides

  • Installation — Workspace setup, PEP 508 extras, and environment variables.
  • Academic Research & IRB — 100% local workflow for qualitative transcripts, survey tables, IRB protocols, and Open Science archiving.
  • AI & RAG Pipelines — In-memory Python round-trips and local Docker sidecar integration for LLM workflows.
  • id-extract in Pipelines — ReDoS-safe structured PII scanning in logs, CI gates, and Microsoft Presidio.
  • Tool Comparison — Neutral comparison against Textwash, ARX, Microsoft Presidio, spaCy, and MAT2.
  • Recipes & Workflows — End-to-end CLI and SDK examples for common tasks.
  • Troubleshooting — Common failure modes and resolutions.

Reference

  • CLI Reference — Subcommands (run, deanonymize, verify, report, apply, purge), flags, profiles, and model aliases.
  • Python SDK — Programmatic entry points for text, tables, Word documents, and restoration.
  • HTTP Service & Docker — Local FastAPI endpoints, Docker Compose, and AppArmor profile.
  • API Reference (auto) — Signature reference generated from source docstrings.
  • Terminology — Canonical definitions for project terms and recognizer scores.

Design & Evaluation

  • Architecture — Processing pipeline, format-specific paths, and reversal internals.
  • Mapping Security — Argon2id + AES-256-GCM envelope design, AAD binding, 0600 I/O, and memory hygiene.
  • Gold Corpus & Eval — Corpus sources, TAB-style metrics, and CI completeness gates.
  • Evaluation Results — Empirical leftover rates and \(F_1\) scores on 6,761 public documents.