An end-to-end full-stack application that automatically processes invoice PDFs and images, extracts structured invoice information using OCR and intelligent parsing, validates the extracted data, detects duplicate invoices, allows manual review and correction, and exports results to JSON, CSV, and Excel.
https://ai-invoice-extraction-system.vercel.app
https://ai-invoice-extraction-api.onrender.com
https://ai-invoice-extraction-api.onrender.com/docs
https://github.com/Boddusai/AI-Invoice-Extraction-System
The objective of this project is to reduce manual invoice data entry by automatically extracting and validating important information from invoice PDFs and images.
The system supports digital PDFs, scanned PDFs, JPG, JPEG, and PNG invoice files.
It provides a complete workflow from invoice upload to structured data export.
- PDF invoice upload
- JPG/JPEG/PNG invoice upload
- Digital PDF text extraction
- OCR for scanned PDFs and invoice images
- Image preprocessing using OpenCV
- Vendor name extraction
- GSTIN extraction
- Invoice number extraction
- Invoice date extraction
- Due date extraction
- Subtotal extraction
- Tax amount extraction
- Grand total extraction
- Currency extraction
- Line-item extraction
- Field-level confidence scores
- Overall invoice confidence score
- Invoice validation engine
- GSTIN format validation
- Amount calculation validation
- Date validation
- Line-item validation
- Exact duplicate detection using SHA-256
- Advanced duplicate detection using invoice data
- OCR-tolerant fuzzy invoice number matching
- Manual invoice review and correction
- Editable line items
- Revalidation after manual correction
- Invoice history
- Search and filtering
- Pagination
- JSON export
- CSV export
- Excel export
- Responsive React dashboard
- Dockerized backend deployment
- Cloud PostgreSQL database
- React
- Vite
- JavaScript
- React Router
- Axios
- Lucide React
- CSS
- Python 3.12
- FastAPI
- SQLAlchemy
- Pydantic
- Uvicorn
- Tesseract OCR
- pytesseract
- OpenCV
- PyMuPDF
- NumPy
- Pillow
- PostgreSQL
- Neon PostgreSQL
- JSON
- CSV
- XlsxWriter
- Vercel — Frontend
- Render — Backend
- Docker
- Neon — PostgreSQL
- GitHub — Source control
USER
│
▼
┌─────────────────┐
│ React + Vite │
│ Vercel │
└────────┬────────┘
│
HTTPS API
│
▼
┌─────────────────┐
│ FastAPI │
│ Render + Docker │
└────────┬────────┘
│
┌─────────────┼─────────────┐
│ │ │
▼ ▼ ▼
PyMuPDF Tesseract OpenCV
PDF Parsing OCR Preprocessing
│ │ │
└─────────────┴─────────────┘
│
▼
Field Extraction
│
▼
Line Item Parsing
│
▼
Confidence Scoring
│
▼
Validation
│
▼
Duplicate Detection
│
▼
┌────────────────┐
│ Neon PostgreSQL│
└────────────────┘
│
▼
Review / Edit
│
┌──────────┼──────────┐
▼ ▼ ▼
JSON CSV Excel
Upload Invoice
│
▼
File Validation
│
▼
Exact Duplicate Check
│
▼
PDF Text Extraction / OCR
│
▼
Structured Field Extraction
│
▼
Line Item Extraction
│
▼
Confidence Scoring
│
▼
Invoice Validation
│
▼
Advanced Duplicate Detection
│
▼
Manual Review / Edit
│
▼
Revalidation
│
▼
JSON / CSV / Excel Export
The system extracts:
| Field | Description |
|---|---|
| Vendor Name | Supplier or company name |
| GSTIN | GST identification number |
| Invoice Number | Unique invoice identifier |
| Invoice Date | Date of invoice |
| Due Date | Payment due date |
| Subtotal | Amount before tax |
| Tax Amount | GST / tax amount |
| Grand Total | Final invoice amount |
| Currency | INR, USD, EUR, etc. |
| Line Items | Products or services in the invoice |
Each extracted field receives a confidence score.
Example:
Vendor Name 96%
GSTIN 99%
Invoice Number 98%
Invoice Date 95%
Subtotal 98%
Tax Amount 98%
Grand Total 99%
Currency 97%
The application also calculates an overall invoice confidence score.
Low-confidence extraction can be manually corrected from the Review page.
The system performs multiple validation checks.
Examples:
Required fields
GSTIN format
Subtotal + Tax = Grand Total
Non-negative amounts
Invoice date validity
Due date validity
Line-item calculations
Line-item totals vs invoice total
The final validation status is:
VALID
WARNING
INVALID
The application uses two duplicate detection methods.
A SHA-256 file hash is generated when an invoice is uploaded.
Same File
│
▼
SHA-256 Match
│
▼
Exact Duplicate
The application compares:
- Invoice number
- GSTIN
- Vendor
- Invoice date
- Grand total
The duplicate scoring system supports OCR errors through fuzzy invoice-number matching.
Example:
Original:
IIC429326F097917
OCR Result:
11C429326F09791
The system can still identify the invoices as likely duplicates.
Users can manually review and correct extracted invoice data.
Editable fields include:
- Vendor
- GSTIN
- Invoice number
- Invoice date
- Due date
- Subtotal
- Tax
- Grand total
- Currency
- Line items
After changes are saved, the invoice can be revalidated.
The application supports:
Contains:
- Invoice information
- Line items
- Confidence scores
- Validation results
Contains:
INVOICE DETAILS
LINE ITEMS
CONFIDENCE SCORES
VALIDATION RESULTS
The Excel workbook contains four sheets:
Invoice Details
Line Items
Confidence Scores
Validation Results
The dashboard displays:
- Total invoices
- Processed invoices
- Duplicate invoices
- Total unique invoice value
- Recent invoices
- Processing status
Duplicate invoices are excluded from the total invoice value.
The dashboard provides a quick overview of uploaded invoices, processed invoices, duplicate invoices, total invoice value, and recent processing activity.
Users can drag and drop or browse PDF, JPG, JPEG, and PNG invoice files. The interface displays upload progress and tracks every processing stage.
The review screen displays extracted fields with confidence scores. Users can manually correct invoice information, edit line items, revalidate data, and export the final result.
The invoice history page provides search, processing-status filters, duplicate filters, pagination, review actions, and export options.
FastAPI automatically provides interactive Swagger documentation for testing all invoice-processing APIs.
The Invoice History page supports:
- Search
- Vendor search
- Invoice-number search
- GSTIN search
- File-name search
- Processing-status filter
- Duplicate filter
- Pagination
- Review action
- JSON export
- CSV export
- Excel export
The application uses PostgreSQL.
Main tables:
invoices
invoice_items
field_confidences
validation_results
Stores:
- File information
- File hash
- Vendor information
- Invoice number
- Dates
- Monetary values
- Currency
- OCR text
- Processing status
- Duplicate information
Stores invoice products/services.
Stores confidence scores for extracted fields.
Stores individual invoice validation results.
POST /api/invoices/uploadGET /api/invoicesGET /api/invoices/{invoice_id}POST /api/invoices/{invoice_id}/extract-textPOST /api/invoices/{invoice_id}/ocrPOST /api/invoices/{invoice_id}/extract-fieldsPOST /api/invoices/{invoice_id}/extract-line-itemsPOST /api/invoices/{invoice_id}/confidence-scoresPOST /api/invoices/{invoice_id}/validatePOST /api/invoices/{invoice_id}/check-duplicateGET /api/invoices/{invoice_id}/reviewPATCH /api/invoices/{invoice_id}/reviewPATCH /api/invoices/{invoice_id}/line-items/{item_id}GET /api/invoices/{invoice_id}/export/json
GET /api/invoices/{invoice_id}/export/csv
GET /api/invoices/{invoice_id}/export/xlsxAI-Invoice-Extraction-System/
│
├── Dockerfile
├── .dockerignore
├── .gitignore
├── README.md
│
├── backend/
│ │
│ ├── app/
│ │ ├── api/
│ │ │ └── invoices.py
│ │ │
│ │ ├── database/
│ │ │ └── database.py
│ │ │
│ │ ├── models/
│ │ │ └── invoice.py
│ │ │
│ │ ├── schemas/
│ │ │ └── invoice.py
│ │ │
│ │ ├── services/
│ │ │ ├── confidence_service.py
│ │ │ ├── duplicate_service.py
│ │ │ ├── export_service.py
│ │ │ ├── invoice_extractor.py
│ │ │ ├── line_item_extractor.py
│ │ │ ├── ocr_service.py
│ │ │ ├── pdf_extractor.py
│ │ │ └── validation_service.py
│ │ │
│ │ ├── config.py
│ │ └── main.py
│ │
│ ├── uploads/
│ ├── requirements.txt
│ ├── smoke_test.py
│ └── init_db.py
│
└── frontend/
│
├── src/
│ ├── components/
│ │ └── Sidebar.jsx
│ │
│ ├── pages/
│ │ ├── Dashboard.jsx
│ │ ├── UploadInvoice.jsx
│ │ ├── Invoices.jsx
│ │ └── ReviewInvoice.jsx
│ │
│ ├── services/
│ │ └── api.js
│ │
│ ├── App.jsx
│ ├── main.jsx
│ └── index.css
│
├── package.json
├── vite.config.js
└── vercel.json
Install:
Python 3.12
Node.js
npm
Tesseract OCR
Git
git clone https://github.com/Boddusai/AI-Invoice-Extraction-System.gitcd AI-Invoice-Extraction-SystemGo to:
cd backendCreate environment:
python -m venv venvWindows:
venv\Scripts\activateInstall dependencies:
pip install -r requirements.txtCreate:
backend/.env
Example:
DATABASE_URL=postgresql+psycopg://USERNAME:PASSWORD@HOST/DATABASE
FRONTEND_URL=http://localhost:5173Do not commit this file.
Start backend:
uvicorn app.main:app --reloadBackend:
http://127.0.0.1:8000
Swagger:
http://127.0.0.1:8000/docs
Open another terminal:
cd frontendInstall packages:
npm installCreate:
frontend/.env
Add:
VITE_API_BASE_URL=http://127.0.0.1:8000Start frontend:
npm run devOpen:
http://localhost:5173
Start the FastAPI backend and run:
python smoke_test.pyExpected:
[PASS] Root API
[PASS] Health
[PASS] Database
[PASS] API Info
[PASS] Invoice List
Passed: 5/5
Backend smoke test completed successfully!
The backend is deployed using Docker.
The Docker image includes:
- Python 3.12
- FastAPI
- Tesseract OCR
- OpenCV
- PyMuPDF
- PostgreSQL client dependencies
Build locally:
docker build -t ai-invoice-api .Run:
docker run -p 8000:8000 ai-invoice-apiVercel
https://ai-invoice-extraction-system.vercel.app
Render
https://ai-invoice-extraction-api.onrender.com
Neon PostgreSQL
Environment variables are used for database credentials and production URLs.
No credentials are stored in the GitHub repository.
GitHub
│
├──────────────┐
│ │
▼ ▼
Vercel Render
React Docker
FastAPI
│
▼
Tesseract
│
▼
Neon PostgreSQL
- Database credentials stored in environment variables
.envexcluded from Git- File-type validation
- File-size validation
- Duplicate file hashing
- CORS configuration
- No credentials committed to GitHub
- OCR accuracy depends on invoice image quality
- Invoice layouts differ between vendors
- Complex tables may require manual review
- Render free instances may have limited CPU/RAM
- Uploaded files on Render are temporary unless persistent storage is configured
Possible future enhancements:
- Transformer-based invoice extraction
- LayoutLM / Donut document models
- Vendor-specific extraction templates
- Cloud object storage
- User authentication
- Role-based access
- Batch invoice processing
- Email invoice ingestion
- Automatic accounting software integration
- GST API verification
- Invoice approval workflow
- Audit logs
- Dashboard analytics
- Multi-language OCR
Example extracted values:
Vendor:
India Central Billing
GSTIN:
06AACCV7324B1ZO
Invoice Number:
IIC429326F097917
Invoice Date:
31/07/2026
Subtotal:
₹422.88
Tax:
₹76.12
Grand Total:
₹499.00
Currency:
INR
Overall Confidence:
97.5%
Validation:
VALID
Sai Pavan
Python Developer / Full-Stack Developer
This project is developed for educational, portfolio, and demonstration purposes.




