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.
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.
- 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
| 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 |
The invoice processing pipeline consists of the following steps:
- Receive a PDF invoice via Webhook.
- Extract text from the uploaded PDF.
- Send the extracted text to Ollama.
- Convert invoice text into structured JSON.
- Store invoice information in PostgreSQL.
- Return JSON to the client.
PDF Invoice
│
▼
n8n Webhook
│
▼
Extract Text from PDF
│
▼
Ollama (Qwen2.5:3B)
│
▼
Structured Invoice JSON
│ │
▼ ▼
PostgreSQL Webhook Response
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
}
]
}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 |
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/
git clone https://github.com/ibam28/ai-invoice-processing.git
cd ai-invoice-processingdocker compose up -dpsql -U n8n -d invoices -f sql/schema.sqlOpen n8n and import:
workflow/workflow.json
Endpoint
POST /webhook/invoice-upload
Content-Type
multipart/form-data
Form Field
data
Input PDF
invoices/invoice.pdf
Expected JSON
examples/invoice.json
Webhook Response
examples/response.json
- PDF Upload
- PDF Text Extraction
- Ollama Integration
- Structured JSON Extraction
- PostgreSQL Storage
- Google Sheets Export
- Discord Notification
- Slack Notification
- Multi-page Invoice Support
This project is licensed under the MIT License.


