How code84/invoice-ai works
InvoiceAI is an Accounts Payable application: an AP user uploads a PDF, the backend processes it into an explainable approval/review/rejection decision, and the frontend exposes progress, history, and invoice details. The graph preserves documented extraction, matching, rules, audit, and dashboard capabilities. Some subsystem links rely on README statements or the source index; unsampled implementation details are not inferred.
Main entry points: pipeline.py Processing Orchestrator · main.py FastAPI Application · api.ts Frontend API Client · database.py SQLAlchemy Database
Components 31
User Interface
- Product Overview
frontend_updated/app/page.tsx - Invoice Upload
frontend_updated/app/upload/page.tsx - Live Run Progress
frontend_updated/app/runs/[id]/page.tsx - Dashboard
frontend_updated/app/dashboard/page.tsx - Invoice History
frontend_updated/app/invoices/page.tsx - Invoice Detail
frontend_updated/app/invoices/[id]/page.tsx - Frontend API Client
frontend_updated/lib/api.ts
API and Data
- FastAPI Application
backend/app/main.py - Invoice Routes
backend/app/routers/invoices.py - Dashboard Routes
backend/app/routers/dashboard.py - Vendor Routes
backend/app/routers/vendors.py - Purchase Order Routes
backend/app/routers/purchase_orders.py - API Schemas
backend/app/schemas/schemas.py - SQLAlchemy Database
backend/app/database.py - Invoice and Run Models
backend/app/models/models.py
Invoice Processing
- Processing Orchestrator
backend/app/services/pipeline.py - PDF and OCR Extraction
backend/app/services/pdf_extractor.py - AI Field Extraction
backend/app/services/ai_extractor.py - Normalization and Validation
backend/app/services/normalizer.py - Vendor Verification
backend/app/services/vendor_verifier.py - PO Matching
backend/app/services/po_matcher.py - Duplicate Detection
backend/app/services/duplicate_detector.py - Business Rules
backend/app/services/rules_engine.py - Decision and Explanation
backend/app/services/decision_engine.py - Run and Audit Tracking
backend/app/services/run_manager.py
AP Reference Data
- Vendor Master
backend/app/models/models.py - Purchase Orders
backend/app/models/models.py
Other components
- AP User
- Gemini or OpenAI
- Tesseract OCR
- Uploaded PDFs
Connections 36
- AP User → Product Overview: visits
- AP User → Invoice Upload: submits PDF
- Invoice Upload → Frontend API Client: requests upload
- Frontend API Client → FastAPI Application: REST requests
- FastAPI Application → Invoice Routes: registers routes
backend/app/main.py - FastAPI Application → Dashboard Routes: registers routes
backend/app/main.py - FastAPI Application → Vendor Routes: registers routes
backend/app/main.py - FastAPI Application → Purchase Order Routes: registers routes
backend/app/main.py - FastAPI Application → SQLAlchemy Database: creates tables
backend/app/main.py - Invoice Routes → Processing Orchestrator: starts processing
backend/app/routers/invoices.py - Invoice Routes → Run and Audit Tracking: creates run
backend/app/routers/invoices.py - Invoice Routes → SQLAlchemy Database: reads and writes
backend/app/routers/invoices.py - Dashboard Routes → SQLAlchemy Database: queries stats
backend/app/routers/dashboard.py - Vendor Routes → SQLAlchemy Database: queries vendors
backend/app/routers/vendors.py - Purchase Order Routes → SQLAlchemy Database: queries orders
backend/app/routers/purchase_orders.py - Processing Orchestrator → PDF and OCR Extraction: extracts PDF text
backend/app/services/pipeline.py - Processing Orchestrator → AI Field Extraction: extracts fields
backend/app/services/pipeline.py - Processing Orchestrator → Normalization and Validation: normalizes fields
backend/app/services/pipeline.py - Processing Orchestrator → Vendor Verification: verifies vendor
backend/app/services/pipeline.py - Processing Orchestrator → PO Matching: matches PO
backend/app/services/pipeline.py - Processing Orchestrator → Duplicate Detection: checks duplicates
backend/app/services/pipeline.py - Processing Orchestrator → Business Rules: evaluates evidence
backend/app/services/pipeline.py - Processing Orchestrator → Decision and Explanation: requests decision
backend/app/services/pipeline.py - Processing Orchestrator → Run and Audit Tracking: records stages
backend/app/services/pipeline.py - AI Field Extraction → Gemini or OpenAI: requests extraction
- PDF and OCR Extraction → Tesseract OCR: OCR fallback
- Processing Orchestrator → Uploaded PDFs: stores uploaded PDF
- Live Run Progress → Frontend API Client: requests run status
- Dashboard → Frontend API Client: requests dashboard data
- Invoice History → Frontend API Client: requests invoice history
- Invoice Detail → Frontend API Client: requests invoice detail
- Run and Audit Tracking → Invoice and Run Models: persists run records
backend/app/services/run_manager.py - Processing Orchestrator → Invoice and Run Models: updates invoice
backend/app/services/pipeline.py - Vendor Verification → Vendor Master: checks vendor master
backend/app/services/pipeline.py - PO Matching → Purchase Orders: checks PO data
backend/app/services/pipeline.py - Business Rules → Decision and Explanation: supplies rule results
backend/app/services/decision_engine.py