How I Built an AI Invoice Extractor with GPT-4o Vision and Nuxt 3
Traditional OCR and regex parsers break the moment an invoice layout changes. Here is how I built an AI invoice extractor that turns messy PDFs and receipts into structured data with a built-in human feedback loop.
Table Of Contents
Anyone who has worked on document processing knows the pain of traditional OCR. You set up a coordinate-based parser or write dozens of regular expressions for vendor names, tax IDs, and totals. It works smoothly until a vendor changes their invoice template by 20 pixels or sends a tilted phone scan. Suddenly, your parser extracts the invoice date as the balance due.
To solve this, I built a full-stack AI Invoice Extractor using Nuxt 3, Express, and GPT-4o Vision. Instead of rigid bounding boxes, it treats invoices visually—just like a human accountant would—and pairs vision extraction with a real-time human feedback loop.
Here's how it's built and what I learned along the way.
The pipeline: from scan to structured data
The extraction flow runs in five distinct stages:
- Ingestion & Multi-Upload — The Nuxt 3 frontend accepts PDF, PNG, JPG, JPEG, and WebP invoices with instant client-side validation.
- High-Res Rasterization — For PDF files, the backend uses
pdf-popplerto render the primary invoice page into a high-resolution PNG, preserving typography, table lines, and stamp overlays. - Multimodal Extraction — The image is converted to a base64 payload and sent to GPT-4o Vision (
detail: 'high',temperature: 0.1) with a strict schema covering vendor info, dates, payment status, balance due, and line items. - Confidence & Anomaly Scoring — The model assesses document clarity, calculating a
confidenceScore(0–100%) and flagging anyuncertainFields. - MongoDB Persistence — Extracted records and verification metadata are saved directly to MongoDB.
Catching visual nuances: the "PAID" stamp problem
Standard text OCR frequently fails on financial context:
- An invoice with a total of
$1,500might have a diagonal red "PAID" watermark across the center. A plain text parser marks it as an open debt. - A bill might state
$2,000total, with a small note at the bottom:"Deposit: $500. Balance Due: $1,500".
By sending high-resolution images directly to GPT-4o with explicit instructions to inspect stamps, watermarks, and footer balance amounts, the system reliably classifies payment status (paid, unpaid, partially_paid, pending) and calculates the actual balance due.
The Human Feedback Loop
In financial workflows, an undetected mistake is far worse than an explicit error. When image quality is poor or critical fields are smudged, the system doesn't guess silently:
- Uncertainty Alert — If confidence drops below 80% or key fields are missing, the UI raises an amber alert: "AI Confidence is Low — Human Feedback Required", tagging the uncertain fields.
- Inline Editing — The user expands the invoice card to inspect or correct vendor names, amounts, dates, and line items directly in the form.
- One-Click Verification — Clicking "Save Corrections & Verify" updates MongoDB with the human-verified values and sets
isHumanVerified: true, switching the badge to a clean green verified state.
What building this taught us
- Vision beats coordinate OCR for varied templates. Invoices are inherently graphical. Table grids, column spacing, and visual badges provide critical context that text-only scrapers lose.
- Build for uncertainty from day one. Requiring the AI to estimate its own confidence and flagging uncertain fields prevents bad data from slipping into downstream ledgers.
- Server-side rasterization is worth the effort. Rendering PDFs to high-res images before model inference gives the AI full visual fidelity without losing fine print or tabular hierarchy.

Akram Sheikh
Senior AI Engineer
Akram is a Senior AI Engineer at Riverborn, specializing in document intelligence, computer vision, and multimodal AI architectures. He builds production-grade extraction and parsing systems that turn unstructured PDFs, receipts, and complex financial documents into reliable, structured data.