Back to Projects
OCR & Document Automation

DocuExtract

Automatically extracts key tax data from invoices and receipts.

The Problem

Manually capturing invoice data for accounting is slow and error-prone, and businesses need a reliable flow even when OCR isn't confident about the result.

The Solution

DocuExtract lets you upload an invoice or receipt and uses OCR to extract the key tax data, ready for accounting. When recognition confidence is low, the document is routed to a human review flow instead of saving unreliable data.

Architecture / Engineering

  • Designed the processing pipeline (upload → OCR/extraction → parsing → persistence), separating server-side processing from the UI.
  • Integrated Tesseract.js (Spanish + English) for OCR on images, plus native text-layer extraction from PDFs with pdf-parse.
  • Built a confidence system combining OCR reliability and detected tax fields, which automatically routes to human review below a configurable threshold.
  • Implemented specialized regex to identify tax IDs (NIT/RIF/CUIT/RFC/RUC), dates (numeric and written), and amounts based on accounting keywords.
  • Isolated data per company with Supabase Row Level Security, and served original documents via short-lived signed URLs from a private Storage bucket.
  • Kept the Supabase `service_role key` exclusively in server Route Handlers, never exposed to the browser.

Key Features

  • Invoice/receipt upload with file type and size validation.
  • OCR on images (Tesseract.js) and native text extraction from PDFs.
  • Extraction and normalization of tax fields: tax ID, dates, amounts, and line items.
  • Confidence scoring with automatic routing to human review.
  • Manual review and validation of the document before marking it complete.
  • CSV export of invoices.

Engineering Challenges

  • Separating server-side processing (OCR, parsing, Storage access) from the UI, so the `service_role key` never reaches the client.
  • Designing the confidence calculation by combining OCR reliability with the number of key fields detected, instead of a single arbitrary threshold.
  • Isolating data per company with RLS so no user can read or write another company's invoices even knowing its ID.

Result / Current State

Deployed on Vercel. The full flow — upload, OCR/parsing, persistence, and human review — works end to end on images and PDFs with a native text layer.

Known limitation

Scanned PDFs without a native text layer aren't rasterized into an image for OCR, since that conversion usually requires native dependencies (poppler-utils) that complicate serverless deployment. These documents are automatically flagged for manual review; adding a dedicated worker to rasterize them is the documented improvement for a future iteration.

Stack

Next.jsTypeScriptNode.jsTesseract.jsTailwind CSSSupabase
LiveGitHubView all projects →