Skip to content

About

Invoice Data Extraction and Validation Pipeline

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Invoice Data Extraction and Validation Pipeline

An intelligent invoice processing system that automatically extracts structured information from PDF/image invoices and validates the extracted data before storing it in the database.

The system is designed to reduce manual invoice processing, identify calculation and data-entry errors, and provide a reliable workflow for invoice review and approval.


๐Ÿš€ Features

  • ๐Ÿ“„ Upload PDF and image invoices
  • ๐Ÿค– Automatic invoice data extraction using OCR / Google Document AI
  • ๐Ÿข Extract vendor information
  • ๐Ÿ”ข Extract invoice number and purchase order number
  • ๐Ÿ“… Extract invoice date
  • ๐Ÿ“ฆ Extract item details
  • ๐Ÿ”ข Extract quantity and unit price
  • ๐Ÿ’ฐ Extract subtotal, tax/GST and grand total
  • โœ… Automatic invoice validation
  • ๐Ÿงฎ Line-item calculation validation
  • ๐Ÿงพ Subtotal and grand-total verification
  • ๐Ÿงฎ GST/tax validation
  • ๐Ÿ” Duplicate invoice detection
  • ๐Ÿ“… Invoice date validation
  • โš ๏ธ Missing-field detection
  • ๐Ÿšซ Invalid/non-invoice document detection
  • ๐Ÿ“Š Dashboard for invoice monitoring
  • ๐Ÿ”Ž Invoice search and filtering
  • ๐Ÿ”„ Invoice refresh functionality
  • ๐Ÿ—„๏ธ MySQL database storage
  • ๐Ÿ‘ค Human review for invalid or low-confidence invoices
  • ๐Ÿ“‘ Invoice report generation
  • ๐Ÿ” Environment variables for sensitive configuration

๐Ÿ—๏ธ System Workflow

                Invoice Upload
                      โ”‚
                      โ–ผ
              PDF / Image File
                      โ”‚
                      โ–ผ
              OCR / Document AI
                      โ”‚
                      โ–ผ
             Data Extraction
                      โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚                           โ”‚
        โ–ผ                           โ–ผ
   Invoice Fields              Line Items
        โ”‚                           โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                      โ–ผ
               Data Validation
                      โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚             โ”‚             โ”‚
        โ–ผ             โ–ผ             โ–ผ
   Required       Calculation    Duplicate
    Fields          Check         Check
        โ”‚             โ”‚             โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                      โ–ผ
                Validation Result
                 /           \
                /             \
               โ–ผ               โ–ผ
             Valid           Invalid
               โ”‚               โ”‚
               โ–ผ               โ–ผ
            Database       Human Review
               โ”‚
               โ–ผ
          Dashboard / Report

๐Ÿง  Validation Checks

The system performs multiple validation checks after extracting invoice information.

Required Field Validation

Checks whether important invoice fields are available:

  • Vendor Name
  • Invoice Number
  • Invoice Date
  • Invoice Items
  • Quantity
  • Unit Price
  • Tax/GST
  • Total Amount

Calculation Validation

The system verifies:

Quantity ร— Unit Price = Line Item Amount

Then:

Sum of Line Items = Subtotal

And finally:

Subtotal + Tax/GST = Grand Total

If the calculated amount differs from the invoice amount, the invoice is marked as invalid and sent for review.

Duplicate Invoice Detection

The system checks whether the same invoice has already been uploaded or stored.

Document Validation

Documents that do not contain recognizable invoice information are rejected instead of generating random invoice calculations.


๐Ÿ› ๏ธ Technology Stack

Frontend

  • React.js
  • Vite
  • JavaScript
  • Lucide React
  • Recharts
  • HTML5
  • CSS3

Backend

  • Node.js
  • Express.js
  • REST API
  • Multer
  • CORS
  • UUID
  • dotenv

AI / Document Processing

  • Google Cloud Document AI
  • Invoice Parser
  • OCR-based document processing

Database

  • MySQL

Development Tools

  • Git
  • GitHub
  • Visual Studio Code
  • PowerShell
  • Postman / cURL

๐Ÿ“‚ Project Structure

invoice-data-extraction-validation/
โ”‚
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ routes/
โ”‚   โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ”œโ”€โ”€ controllers/
โ”‚   โ”‚   โ”œโ”€โ”€ middleware/
โ”‚   โ”‚   โ””โ”€โ”€ server.js
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ uploads/
โ”‚   โ”œโ”€โ”€ credentials/
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ””โ”€โ”€ .env
โ”‚
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ App.jsx
โ”‚   โ”‚   โ””โ”€โ”€ InvoiceDashboard.jsx
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ””โ”€โ”€ vite.config.js
โ”‚
โ”œโ”€โ”€ .gitignore
โ””โ”€โ”€ README.md

Note: .env, service-account credentials, and other sensitive files should never be committed to GitHub.


โš™๏ธ Installation

1. Clone the Repository

git clone https://github.com/Aditya1710S/invoice-data-extraction-validation.git
cd invoice-data-extraction-validation

๐Ÿ”ง Backend Setup

Go to the backend folder:

cd backend

Install dependencies:

npm install

Create a .env file:

PORT=4000
NODE_ENV=development

CORS_ORIGIN=http://localhost:5173

DB_NAME=invoiceflow
DB_USER=invoiceflow_app
DB_PASSWORD=YOUR_DATABASE_PASSWORD
DB_HOST=localhost

GOOGLE_CLOUD_PROJECT_ID=YOUR_PROJECT_ID
DOCUMENT_AI_PROCESSOR_ID=YOUR_PROCESSOR_ID
DOCUMENT_AI_LOCATION=us

GOOGLE_APPLICATION_CREDENTIALS=./credentials/invoiceflow-service-account.json

Start the backend:

npm run dev

Backend API:

http://localhost:4000

Health check:

http://localhost:4000/api/health

๐Ÿ’ป Frontend Setup

Open another terminal and go to the frontend folder:

cd frontend

Install dependencies:

npm install

Start the development server:

npm run dev

The frontend will normally run at:

http://localhost:5173

๐Ÿ—„๏ธ Database

The project uses MySQL for storing invoice information.

Create the database:

CREATE DATABASE invoiceflow;

The backend initializes the required tables when configured correctly.

Make sure MySQL is running before starting the backend.


โ˜๏ธ Google Document AI Configuration

The project uses Google Cloud Document AI for invoice processing.

Required configuration:

Google Cloud Project
        โ”‚
        โ–ผ
Document AI API
        โ”‚
        โ–ผ
Invoice Parser
        โ”‚
        โ–ผ
Processor ID
        โ”‚
        โ–ผ
Backend
        โ”‚
        โ–ผ
Invoice Extraction

The Google Cloud service-account JSON file should be stored locally and must not be uploaded to GitHub.


๐Ÿ” Security

Sensitive configuration is intentionally excluded from the repository.

The following should not be committed:

.env
credentials/
service-account JSON files
node_modules/
uploads/

Use .env.example to document required environment variables without exposing passwords or credentials.


๐Ÿ“Š Example Invoice Processing

Valid Invoice

Quantity:       10
Unit Price:     โ‚น100
Subtotal:       โ‚น1000
GST:            โ‚น180
Grand Total:    โ‚น1180

The calculation is consistent, so the invoice can proceed to the next stage.

Invalid Invoice

Quantity:       10
Unit Price:     โ‚น100
Expected:       โ‚น1000
Invoice Amount: โ‚น1100

The system detects the discrepancy and marks the invoice for validation/review.


๐Ÿ” API Endpoints

Method Endpoint Description
GET /api/health Check backend status
POST /api/invoices/upload Upload and process invoice
GET /api/invoices Get invoices
GET /api/invoices/:id Get invoice details
PUT /api/invoices/:id Update invoice
DELETE /api/invoices/:id Delete invoice
GET /api/invoices/:id/file Access invoice file

๐ŸŽฏ Objectives

  1. Automate invoice data extraction.
  2. Reduce manual data entry.
  3. Validate invoice calculations automatically.
  4. Detect duplicate invoices.
  5. Identify missing or invalid invoice information.
  6. Store structured invoice data in a database.
  7. Provide a dashboard for invoice monitoring.
  8. Reduce the need for manual invoice verification.
  9. Route exceptions to human review.

๐ŸŒ Scope

The system can be used for:

  • Accounts Payable departments
  • Small and medium businesses
  • Enterprise invoice processing
  • Vendor invoice management
  • Financial document processing
  • Automated accounting workflows

Future versions can be extended with:

  • Advanced fraud detection
  • Vendor-specific validation rules
  • Email invoice ingestion
  • Cloud deployment
  • ERP integration
  • Multi-language invoice processing
  • Machine-learning based anomaly detection
  • Automated approval workflows

๐Ÿ“ˆ Benefits

  • Faster invoice processing
  • Reduced manual effort
  • Improved data accuracy
  • Automatic calculation verification
  • Duplicate invoice detection
  • Centralized invoice records
  • Better visibility through dashboard
  • Human review only for exceptions

๐Ÿ‘จโ€๐Ÿ’ป Project

Project Title: Invoice Data Extraction and Validation Pipeline

Domain: Artificial Intelligence | Data Extraction | Document Processing | Full Stack Development

Technologies: React.js | Node.js | Express.js | Google Cloud Document AI | MySQL

Repository: https://github.com/Aditya1710S/invoice-data-extraction-validation

About

Invoice Data Extraction and Validation Pipeline

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages