A production-shaped document intelligence service for extracting normalized invoice fields with confidence and source provenance. The API keeps the inference core deterministic and independently testable, fingerprints normalized input for deduplication, and redacts common PII from operational logs.
- FastAPI boundary with typed, bounded requests and OpenAPI docs.
- Extraction of invoice number, date, contact email, and total.
- Decimal-safe monetary normalization.
- Per-field confidence and source evidence.
- PII-aware logging for email, phone, and SSN-shaped values.
- Docker image and GitHub Actions checks.
python -m venv .venv && source .venv/bin/activate
pip install -e '.[dev]'
pytest -q
uvicorn app.main:app --reloadcurl -X POST localhost:8000/v1/extract \
-H 'content-type: application/json' \
-d '{"request_id":"demo-1","text":"INVOICE # AB-1042\nDate: 2026-07-21\nTotal: $149.00"}'Interactive documentation is available at http://localhost:8000/docs.
The extraction engine has no framework dependency, making it cheap to unit test and straightforward to replace with OCR or an LLM provider. The HTTP layer owns validation and observability, while only redacted previews reach logs.
Built a containerized document-intelligence API with FastAPI and Python, implementing typed extraction with confidence/provenance, monetary normalization, input fingerprinting, and PII-safe logging.