Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Invoice Processing System

An AI-powered invoice processing workflow built with n8n, Ollama, and PostgreSQL.

This project automatically extracts structured information from PDF invoices using OCR and a local Large Language Model (LLM), stores the extracted data in PostgreSQL, and returns structured JSON through an HTTP webhook.

100% Local AI — No cloud AI APIs required.


Preview

Workflow


Overview

This project demonstrates how to build an end-to-end AI document processing workflow using only local components.

The workflow receives a PDF invoice through an HTTP webhook, extracts its text, sends the extracted content to a locally hosted Ollama model (Qwen2.5:3B), converts the invoice into structured JSON, stores the data in PostgreSQL, and finally returns the parsed result through the webhook response.

Because every component runs locally, the workflow can be deployed without sending documents to external AI services.


Features

  • PDF invoice upload through HTTP Webhook
  • PDF text extraction
  • AI-powered invoice understanding using Ollama
  • Structured JSON generation
  • PostgreSQL data storage
  • HTTP JSON response
  • Local AI deployment
  • Docker-based PostgreSQL

Tech Stack

Technology Purpose
n8n Workflow Automation
Ollama Local LLM Runtime
Qwen2.5:3B Invoice Information Extraction
PostgreSQL Database
Docker Containerization
Extract from File PDF Text Extraction

Workflow

The invoice processing pipeline consists of the following steps:

  1. Receive a PDF invoice via Webhook.
  2. Extract text from the uploaded PDF.
  3. Send the extracted text to Ollama.
  4. Convert invoice text into structured JSON.
  5. Store invoice information in PostgreSQL.
  6. Return JSON to the client.

Workflow Screenshot

Workflow


Architecture

                PDF Invoice
                     │
                     ▼
               n8n Webhook
                     │
                     ▼
          Extract Text from PDF
                     │
                     ▼
           Ollama (Qwen2.5:3B)
                     │
                     ▼
          Structured Invoice JSON
              │               │
              ▼               ▼
       PostgreSQL       Webhook Response

Example JSON Output

JSON Output

Example:

{
  "vendor": "Nova Tech",
  "invoice_number": "#INV-2026-0842",
  "invoice_date": "2026-08-03",
  "currency": "USD",
  "total": 271.11,
  "items": [
    {
      "description": "Wireless Noise-Canceling Headphones",
      "quantity": 1,
      "unit_price": 149.99,
      "amount": 149.99
    }
  ]
}

PostgreSQL Storage

PostgreSQL

Each processed invoice is automatically stored in PostgreSQL.

Current table schema:

Column Type
id SERIAL
vendor TEXT
invoice_number TEXT
invoice_date DATE
currency TEXT
total NUMERIC
items JSONB
created_at TIMESTAMP

Project Structure

ai-invoice-processing/
├── docker-compose.yml
├── README.md
├── .gitignore
├── workflow/
│   └── workflow.json
├── sql/
│   └── schema.sql
├── invoices/
│   └── invoice.pdf
├── examples/
│   ├── invoice.json
│   └── response.json
├── screenshots/
│   ├── workflow.png
│   ├── json-output.png
│   └── postgres.png
└── docs/

Installation

Clone the repository

git clone https://github.com/ibam28/ai-invoice-processing.git
cd ai-invoice-processing

Start PostgreSQL

docker compose up -d

Import the database schema

psql -U n8n -d invoices -f sql/schema.sql

Import the workflow

Open n8n and import:

workflow/workflow.json

API

Endpoint

POST /webhook/invoice-upload

Content-Type

multipart/form-data

Form Field

data

Sample Files

Input PDF

invoices/invoice.pdf

Expected JSON

examples/invoice.json

Webhook Response

examples/response.json

Roadmap

  • PDF Upload
  • PDF Text Extraction
  • Ollama Integration
  • Structured JSON Extraction
  • PostgreSQL Storage
  • Google Sheets Export
  • Discord Notification
  • Slack Notification
  • Multi-page Invoice Support

License

This project is licensed under the MIT License.

About

AI-powered invoice processing workflow using n8n, Ollama, OCR, and PostgreSQL for automated structured data extraction.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors