How arc42/pdfminion works
Project type and purpose
• PDFminion is a cross-platform command-line tool (written in Go) for PDF manipulations (add page numbers, headers/footers, merging).
• It also includes a static website (Jekyll-based) under docs/, architectural decision records in documentation/adr/, and CI/CD workflows in .github/workflows/.
File structure
Top-level:
• .github/workflows/: CI jobs (linting, testing, FOSSA security scan).
• go-app/: the CLI application.
– cmd/: entry points for each subcommand (e.g. detectSystemLanguage).
– internal/config/: flag & YAML config parsing and wiring.
– internal/domain/: core commands, types, validation, language logic.
– internal/pdf/: PDF processing pipelines (single file or batch).
– internal/util/: helper routines.
– sample-files-for-testing/: test fixtures.
– Dockerfile.linux-test, Makefile: build/test scripts.
• docs/: static site (Jekyll) source for user documentation.
README
• Confirms it’s a CLI “minion” for mundane PDF tasks, built in Go, tested on macOS/Linux/Windows.
• Points to a publicly hosted Jekyll site.
Main components & relationships
A. User Interface
– “Terminal / CLI” – user invokes commands (e.g. pdfminion --add-page-numbers …).
B. Configuration Layer (internal/config)
– Parses flags, reads myconfig.yaml (layered config).
– Supplies structured config to Domain layer.
C. Command Dispatcher (internal/domain)
– Selects one of the basic commands (add headers, merge PDFs, etc.).
– Performs validation (via validate.go).
D. PDF Processing Layer (internal/pdf)
– processSingleFile.go / processFiles.go pipelines.
– Invokes external PDF library (e.g. pdfcpu).
– Reads from file system (input PDFs), writes new PDFs.
E. Utility Layer (internal/util)
– Provides shared helpers (logging, file ops).
– Called by both Config and PDF Processing.
F. External Dependencies
– Third-party Go modules: xuanwo-go-locale, flag package, pdfcpu.
– OS file system.
G. CI/CD & Build
– GitHub Actions workflows: lint (golangci-lint), test (go-test), FOSSA security scan.
– Makefile / Dockerfile.linux-test – for local builds and tests.
H. Documentation Site
– Jekyll source in docs/ → static HTML.
Architectural patterns & design principles
• Layered architecture: CLI → Config → Domain → Processing → External libs
• Dependency inversion: Domain code is free of I/O; injected services handle I/O.
• Single-responsibility: each internal/ package has a clear concern.
• ADR-driven design: documented trade-offs in documentation/adr.