LedgerLens

ACTIVE

Document Vision & Validation

AI document intelligence for extracting and validating financial records from receipts and invoices.

Core Proposition

AI document intelligence platform that extracts structured financial records from receipt and invoice images, executes deterministic rule-based arithmetic validation, applies PII masking and cryptographic provenance watermarking, and routes low-confidence records to human-in-the-loop review.

PROBLEM CONTEXT

Brittle OCR & Silent Financial Extraction Errors

Standard OCR and raw LLM vision extractions frequently suffer from brittle layout handling, incorrect field values, arithmetic discrepancies (e.g. Subtotal + Tax != Total), silent hallucinations, and lack of audit-ready provenance verification for sensitive invoices and receipts.

•Raw LLM vision outputs can hallucinate line items or misread decimal places.
•Traditional OCR engines fail when receipt layouts deviate from standard templates.
•Financial data requires strict mathematical reconciliation before downstream ERP ingestion.
•LedgerLens adds deterministic software validation and human review around AI-assisted extraction.
SYSTEM DESIGN

Three-Tier Validation Architecture

LedgerLens strictly isolates generative AI inference from deterministic validation rules and human decision-making, ensuring mathematical consistency and provenance before committing data.

Tier 1: AI Vision Extraction

Multi-provider vision models (OpenAI, Gemini, Groq) interpret unstructured receipt and invoice images guided by dynamic Pydantic schema contracts.

Tier 2: Deterministic Rule Engine

Deterministic Python validation engine evaluates 10+ mathematical rules (Subtotal + Tax == Total, Unit Price * Qty == Line Total, ISO currency verification) and recalibrates AI confidence scores.

Tier 3: Human-in-the-Loop Review

Interactive split-pane review workspace where operators visually inspect watermarked provenance images, adjust flagged fields, and commit verified records.

RELATIONAL PROVENANCE CHAINTraceable Pipeline
Document Image Ingestion→Fail-Closed Moderation & PII Redaction→Multi-Provider Vision Extraction→Structured Schema Validation→Deterministic Arithmetic Engine→Confidence Recalibration→Split-Pane Human Review→Provenance Watermarking & Persistence
OPERATIONAL SEQUENCE

Document Validation Pipeline

1

Document Image Ingestion

Accepts receipt and invoice image uploads (PNG, JPEG) and generates cryptographic file hashes for provenance tracking.

2

Fail-Closed Moderation & PII Redaction

Evaluates safety screening gates and automatically masks sensitive PII (SSNs, tax IDs, credit card numbers, phone numbers) prior to logging.

3

Multi-Provider Vision Extraction

Dispatches document images to configured vision models (OpenAI, Google Gemini, Groq) with embedded JSON schema prompting.

4

Structured Schema Normalization

Enforces dynamic Pydantic models (InvoiceSchema), standardizes field aliases, and validates date and currency ISO formatting.

5

Deterministic Financial Validation

Executes 10+ deterministic rule checks verifying arithmetic integrity (Subtotal + Tax == Total) and flagging discrepancies.

6

Confidence Recalibration & Human Review

Computes combined confidence metrics; extractions falling below threshold (< 75%) are automatically queued for split-pane manual review.

7

Provenance Watermarking & Persistence

Applies tamper-evident watermark stamps and persists structured records to Supabase PostgreSQL (public.cevondocs_documents) and dedicated object storage.

CAPABILITIES

Verified System Capabilities

Multi-Provider Vision AI

Modular provider architecture with hot-swapping across OpenAI, Google Gemini, and Groq vision backends.

Dynamic Pydantic Schema Prompting

Embeds strict Pydantic JSON schemas directly into model prompts to enforce type-safe extraction contracts.

Deterministic Arithmetic Engine

Evaluates 10+ mathematical rules to detect arithmetic mismatches between line items, taxes, and totals.

Automated PII Redaction

Identifies and masks sensitive personally identifiable information (tax IDs, SSNs, phone numbers) before logging.

Split-Pane Review Workspace

Side-by-side verification interface comparing raw source images with editable financial schemas.

Telemetry & Observability

Prometheus metrics endpoint (/metrics) and Grafana dashboard tracking extraction latencies, token costs, and queue status.

ENGINEERING ATTRIBUTES

Technical Specification & Stack

Domain CategoryDocument Vision & Validation
Product StatusActive / Verified Codebase (57 Passing Tests)
Canonical Slugledgerlens
Primary RuntimeFastAPI / Uvicorn + Next.js + Docker Containerization
Core ArchitectureNext.js 14 App Router (Frontend) + FastAPI / Python 3.11+ (Backend)
Persistence ModelSupabase PostgreSQL (public.cevondocs_documents) + Storage Bucket (cevondocs)
Verified Technology Tags
FastAPIPython 3.11+Next.js 14Pydantic v2Pillow (PIL)OpenAI VisionGoogle GeminiGroqSupabasePrometheus
STUDIO PROVENANCE

Origin & Operational Context

Developed under the CevonX product studio to solve financial receipt and invoice validation. Validated with a 57-test automated verification suite.

Internal database identifier: cevondocs. Public open-source repository available at https://github.com/Sahil2430/CevonDocs.