Demonstration

AI document intelligence with human review

A demonstration of a document-processing workflow for supplier invoices: fields are extracted with citations back to the source text, confidence decides what is accepted automatically and what goes to review, and reviewer corrections become evaluation data.
Demonstration · fictional data
PythonFastAPIPostgreSQL + pgvectorOCR & layout parsingHosted LLM APIReactOpenTelemetry
Type
Demonstration · fictional data
Domain
AI & data, ERP & operations
Problems
Manual data entry, Trustworthy AI output, Auditability
Year
2026

This is a demonstration, not client work. It was built for this portfolio with fictional companies and data to show how I approach this kind of system. Outcomes below are illustrative targets, not achieved results.

01Interactive preview

Try it. Everything here works.

A working product preview with fictional data. State changes, events and edge cases are simulated in your browser; nothing is sent anywhere.
Demodocintel · Invoice extraction & review

7 auto-accepted · 3 need review · 0 corrected

Brightwater Industrial Supply GmbH

Musterweg 12 · 20095 Hamburg · Germany

VAT ID DE999999999

INVOICE

No. BW-2026-04817

Date 14 Sep 2026

BILL TO

Fenwick Instruments Ltd

4 Example Road · Cambridge CB1 0XX · United Kingdom

YOUR REFERENCE

PO-4821l

DescriptionQtyUnitAmount
Precision torque driver set (TS-40)4189.00756.00
Calibration service, annual1 × 1,240.00 = 1,240.00
ESD-safe workbench mat 1200×600658.50351.00
Subtotal
2,347.00
VAT 19%
445.93
Total EUR
2,792.93

Payment terms: 30 days net from invoice date.

IBAN DE89 3704 0044 0532 0130 01 · BIC DEMODEHHXXX

Fictional document for demonstration purposes.

Extracted fields · click to see the source

  • ✓ Due date after invoice date

    Derived from “payment terms: 30 days net”, not printed directly.

  • ✓ Line items sum to subtotal

  • ✓ VAT is 19% of subtotal

  • ✓ Subtotal + VAT = total

  • ✗ IBAN checksum (mod 97)

    Checksum fails: possible OCR error or a changed bank detail. Verify against supplier master data.

  • Last character is ambiguous (“l” or “1”). PO-48211 is the likely match.

Ask the document

Precomputed answers · citations link to the source

Pick a question. Answers use only text from this document and cite where it came from.

02Context & constraints

The situation

A fictional finance team receives several hundred supplier invoices a month as PDFs and scans. Staff re-key supplier, amounts, dates and bank details into the ERP, then answer supplier questions by searching through email.

The workflow automates extraction where the model is demonstrably reliable, keeps people in control where it isn't, and lets staff ask questions about documents and get answers that cite their sources.

Role

A self-initiated demonstration, not client work. In a real engagement I would own the ingestion pipeline, extraction and validation, the evaluation set, the review interface and the ERP integration.

  1. Document ingestion, OCR and layout parsing
  2. Schema-constrained extraction with citations
  3. Validation rules and confidence scoring
  4. Review queue and correction capture
  5. Retrieval for document questions
  6. Evaluation set, metrics and regression checks

Constraints

  • Every value must be traceable

    An extracted amount without a pointer to where it came from is not acceptable to finance or to auditors.

  • Errors are expensive

    A wrong bank account or total can cause a misdirected payment, so low-confidence values must never flow straight through.

  • Careful data handling

    Invoices contain personal and commercial data. The model provider must not train on it, and retention must be limited.

  • Measurable quality

    The team needs accuracy per field, and to know whether it changes when the model or prompts change.

03Architecture & data flow

Follow the data, one step at a time.

Pick a flow and step through it, or press play. Each step highlights the connection involved and explains what happens there and why.

Step 1 / 6

Scroll sideways to see the whole diagram →

Architecture diagram: AI document intelligence with human reviewComponents: Inbox / upload, Ingestion worker, Object storage, Extraction, LLM provider, Validation, Review queue, PostgreSQL + pgvector, Evaluation set, Finance user, Question answering. Highlighted path: Ingest and extract, step 1 of 6: Invoice arrives.EXTRACTION PIPELINE · UNTRUSTED INPUTInbox / uploadPDF · scans · emailUIIngestion workerOCR · layout parsingJOBObject storageEncrypted originalsDATAExtractionSchema + citationsAILLM providerNo training on dataEXTValidationRules · confidenceSVCReview queuePeople decideUIPostgreSQL + pgvectorFields · spans · vectorsDATAEvaluation setCorrections → testsJOBFinance userAsks questionsUIQuestion answeringRetrieval · citationsSVC

Ingest and extract

How an invoice becomes structured, cited fields.

Ingest and extract, step 1 of 6: Invoice arrives. Documents arrive by email or upload; file type and size are checked before anything else.

04Engineering decisions

Decisions, with their costs.

Written as short decision records: what was chosen, what it costs, and what else was considered.

ADR-01

Citations at the span level

Decision
Each extracted field stores the page and character span it came from, and the interface highlights the source when a reviewer focuses a field.
Trade-off
Requires layout-aware parsing and careful prompting, but reviewers can verify a value in seconds.
Alternatives considered
Page-level citations (much slower to verify) or no citations at all (impossible to review).

ADR-02

Confidence from several signals

Decision
Confidence combines token probabilities where the provider exposes them, agreement between two extraction passes, and deterministic validation such as totals adding up and checksums passing.
Trade-off
More compute per document, but far fewer silent errors than trusting a single score.
Alternatives considered
The model's self-reported confidence, which is poorly calibrated.

ADR-03

An evaluation set before any tuning

Decision
A labeled set of real, anonymized invoices defines field-level accuracy, and every pipeline change is scored against it in CI.
Trade-off
Labeling takes days up front, but it turns arguments about quality into numbers.
Alternatives considered
Spot-checking outputs by eye, which misses regressions.

ADR-04

The model is a replaceable component

Decision
Extraction goes through an interface with provider adapters, and the evaluation set decides which model to use for which field type.
Trade-off
A thin abstraction to maintain, in exchange for switching providers for cost, quality or data residency.
Alternatives considered
Coupling the whole codebase to one provider's SDK.

05Implementation

Where the details live

Schema-constrained extraction

The model returns JSON validated against a schema that includes a citation for every field. Output that is invalid or uncited is retried once, then routed to review.

Checking extracted fields against their citations (Python, simplified)Python
class Cited(BaseModel):
    value: str
    page: int
    span: tuple[int, int]  # character offsets in the parsed page text

class InvoiceFields(BaseModel):
    supplier: Cited
    invoice_number: Cited
    total: Cited
    due_date: Cited
    iban: Cited | None = None

def check(fields: InvoiceFields, pages: list[str]) -> list[str]:
    issues = []
    for name, field in fields:
        if field is None:
            continue
        start, end = field.span
        if field.value not in pages[field.page][start:end]:
            issues.append(f"{name}: citation does not contain the value")
    if fields.iban and not iban_checksum_ok(fields.iban.value):
        issues.append("iban: checksum failed")
    return issues

Review queue

Documents with any field below threshold, or any failed rule, enter a queue sorted by payment due date. Reviewers work field by field with the keyboard, and every decision is stored next to the model's original value.

Cited answers

Questions are answered only from retrieved passages, with every sentence linked to a source. When retrieval finds nothing relevant, the system says so plainly instead of improvising.

06Deployment

Running it for real

Proposed topology for a production version of this design.
Runtime
FastAPI services and queue-driven workers in containers, scaling with backlog.
Data
Encrypted object storage for originals with lifecycle rules; PostgreSQL with pgvector for fields, spans and embeddings.
Model access
Business API terms with no training on customer data and minimal retention, or a self-hosted open-weight model where required.
Observability
Traces per document, field-level accuracy dashboards fed by review outcomes, and cost per document.

07Outcomes & lessons

What this shows, honestly labeled.

Nothing below is a client result. These are the capabilities the demonstration exercises and how success would be measured in a real engagement.
  • What the demo shows

    Illustrative — not a client result

    A rendered invoice, extracted fields with confidence bars, click-to-highlight citations, a review flow for low-confidence fields, and cited answers to sample questions.

  • How success would be measured

    Illustrative — not a client result

    Field-level accuracy on the evaluation set, share of documents processed without review, reviewer time per document, and cost per document.

  • What is simulated

    Illustrative — not a client result

    Model outputs, confidence scores and answers are precomputed for a fictional invoice; no model is called from the browser.

Design notes

  • Validation rules catch a surprising share of model errors cheaply. Build them before tuning prompts.
  • Reviewers need keyboard-first interfaces: every extra click is multiplied by hundreds of documents.
  • Track corrections per field. They show exactly where the next improvement should go.

Industries

Next

Multi-tenant commerce platform

Next step

Tell me what you’re building. I’ll tell you how I’d approach it.

Send a short brief. You’ll get a written reply from me within two business days — either a few clarifying questions, a suggested first step, or an honest “I’m not the right fit” with a pointer elsewhere.

Parth Patel

Senior full-stack engineer