Skip to main content

Engineering case study

DocuFlow AP

An invoice-processing workflow combining OCR, structured extraction, validation and human review.

01

Business problem

The workflow before automation.

Invoice processing requires information to be read from documents, converted into structured fields, checked for errors or duplicates and routed for review. The simulated DocuFlow AP scenario explores how those repetitive steps can be automated while preserving human control when document confidence is insufficient.

  1. 01

    Receive invoice documents from incoming channels.

  2. 02

    Read invoice fields manually.

  3. 03

    Enter structured values into operational systems.

  4. 04

    Check totals, fields and duplicate submissions.

  5. 05

    Investigate uncertain or mismatched documents.

  6. 06

    Record review decisions and processing status.

02

Automated solution

A controlled system around the business process.

DocuFlow AP processes incoming invoice documents through preprocessing, OCR, structured extraction and validation before determining whether the result can progress or requires human review.

Reduce repetitive invoice data entry.

Create structured information from document inputs.

Detect validation and duplicate issues earlier.

Route uncertain results into an explicit review workflow.

03

Architecture

System architecture at a glance.

This structured view establishes the architecture narrative. Final portfolio-safe diagrams are added during the evidence pass.

  1. 01

    Next.js operations workspace

    Authenticated operations dashboard and review interface for invoice search, evidence inspection, human decisions, exports, delivery, and audit history.

  2. 02

    FastAPI API

    Owns secure intake, validation, extraction coordination, matching, review actions, exports, delivery controls, and audit-facing APIs.

  3. 03

    Supabase PostgreSQL + Auth

    Canonical operational state, application roles, decisions, review history, configuration, and audit records.

  4. 04

    Celery + Redis

    Asynchronous document preprocessing and OCR execution outside the request path.

  5. 05

    Tesseract + image processing

    Local OCR with preprocessing and canonical header and line-item extraction while preserving source evidence.

  6. 06

    MinIO

    S3-compatible object storage for source documents and generated artifacts.

  7. 07

    Export + delivery layer

    Idempotent JSON and CSV accounting exports with HMAC-signed webhook or email delivery and retry history.

04

Workflow

How information moves through the system.

01

Receive

Accept an invoice into the document-processing workflow.

02

Read

Preprocess the document and use OCR to recover machine-readable content.

03

Extract

Convert document content into structured invoice fields.

04

Validate

Evaluate field consistency, confidence and duplicate conditions.

05

Review

Route documents that require judgment into a controlled human-review path.

05

Engineering

The parts that make the automation dependable.

Document preprocessing

Input preparation is treated as part of OCR quality rather than assuming every document is clean.

Structured extraction

OCR output is transformed into business fields instead of stopping at raw text recognition.

Confidence-aware processing

Uncertainty influences workflow decisions rather than being hidden from the operator.

Validation workflow

Extracted values pass through business validation and duplicate checks before progressing.

06

Controls

Security, reliability and human control.

01

Confidence handling

Low-confidence document results can be prevented from silently progressing.

02

Duplicate detection

Repeated invoice submissions are treated as an explicit processing condition.

03

Human review

Cases requiring judgment remain inside a controlled review workflow.

04

Review traceability

Document and review state is designed to remain inspectable after processing.

07

Evidence

Proof will come from the completed repository.

Automated tests

73 / 73

Full Pytest suite passed in the captured release-candidate environment.

OCR pipeline

4.45 s

Single synthetic smoke-test invoice completed preprocessing and local Tesseract OCR.

Validation controls

8

Deterministic rules executed in the seeded passing-control scenario with zero blocking issues.

Final release-candidate evidence was captured from commit 6d20204. Pytest completed with 73 passing tests and one Starlette deprecation warning. The smoke workflow also verified intake idempotency, local OCR, canonical header and line extraction, deterministic validation, business duplicate detection, vendor and purchase-order matching, authoritative decisions, role enforcement, human review, exports, retry-safe delivery, dashboard APIs, browser authentication, and the interactive operations workspace. The 4.45 second OCR-pipeline result is one synthetic smoke-test execution, not a production latency SLA.

01

Live operations overview showing invoice volume, automated outcomes, review backlog, export activity, and current exception signals in the synthetic portfolio environment.

02

Invoice workspace showing canonical header fields, extracted line items, control outcomes, and human-review status for a synthetic invoice.

03

Deterministic controls remain authoritative after OCR: validation, duplicate, vendor, and purchase-order results are shown separately before a decision is allowed.

04

Prioritized human-review queue with ownership, exception reasons, filters, and synthetic cases that cannot safely proceed automatically.

05

Human correction applied to the purchase-order field, followed by control rerun, approved resolution, export readiness, delivery state, and immutable audit events.

06

Approved invoice export workflow with deterministic JSON or CSV generation, reusable export state, download control, and downstream delivery selection.

07

Retry-safe downstream delivery showing a generated export, selected delivery channel, synthetic destination, and a successful final state after multiple attempts.

08

Immutable audit timeline preserving review resolution, control reruns, corrections, notes, ownership events, and actor attribution.

08

Implementation

Technology and current boundaries.

Technology

Next.js 16React 19TypeScriptFastAPIPython 3.12SQLAlchemySupabase PostgreSQLSupabase AuthCeleryRedisTesseract 5.5OpenCVPillowMinIODocker Compose

Limitations

DocuFlow AP is a portfolio implementation, not a deployed accounting production system. It does not post transactions to a live ERP, execute payments, or process real financial records. Production rollout would still require organization-specific accounting and approval policy, tax and currency rules, ERP mappings, malware scanning, managed secrets and HTTPS, hosted monitoring, backups and disaster recovery, retention enforcement, privacy and compliance review, provider capacity planning, and named operational ownership.

09

Client relevance

What this project proves.

This project demonstrates document automation beyond basic OCR by combining extraction, validation, confidence handling, duplicate protection and human review into one operational workflow.

Project resources

View GitHub repositoryDemo video coming before portfolio launch.