Skip to content

Repository files navigation

🧾 Invoice Extractor

Python 3.11+ MIT License Gemma 4 Privacy-First Ollama

Extract structured data from invoices and receipts using a local LLM β€” no cloud, no API keys, 100% private.

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         Invoice Input (text / file)          β”‚
β”‚                    β”‚                          β”‚
β”‚            β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”                  β”‚
β”‚            β”‚   Invoice    β”‚                  β”‚
β”‚            β”‚   Parser     β”‚                  β”‚
β”‚            β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜                  β”‚
β”‚                   β”‚                          β”‚
β”‚            β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”                  β”‚
β”‚            β”‚   Ollama     β”‚                  β”‚
β”‚            β”‚  (Gemma 4)   β”‚                  β”‚
β”‚            β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜                  β”‚
β”‚     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”‚
β”‚ β”Œβ”€β”€β”€β–½β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β–½β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β–½β”€β”€β”€β”€β”€β”     β”‚
β”‚ β”‚Vendor  β”‚  β”‚  Line    β”‚  β”‚Category  β”‚     β”‚
β”‚ β”‚Details β”‚  β”‚  Items   β”‚  β”‚Classifierβ”‚     β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
β”‚                   β”‚                          β”‚
β”‚     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”‚
β”‚ β”Œβ”€β”€β”€β–½β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β–½β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β–½β”€β”€β”€β”€β”€β”     β”‚
β”‚ β”‚  JSON  β”‚  β”‚   CSV    β”‚  β”‚ Batch    β”‚     β”‚
β”‚ β”‚ Export β”‚  β”‚  Export  β”‚  β”‚ Report   β”‚     β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Features

  1. Structured Data Extraction β€” Parses vendor details, line items, totals, tax, and payment terms from raw invoice text
  2. Automatic Categorization β€” Classifies line items into categories like Software, Hardware, Travel, and Consulting
  3. Batch Processing β€” Process multiple invoices in one run with configurable batch sizes
  4. Duplicate Detection β€” Identifies near-duplicate invoices using configurable similarity thresholds
  5. Multi-Format Export β€” Output extracted data as JSON or CSV for downstream accounting systems
  6. Rich CLI Interface β€” Beautiful terminal output with color-coded tables and progress indicators
  7. Streamlit Web UI β€” Browser-based dashboard for uploading invoices and reviewing extracted data
  8. FastAPI REST Endpoint β€” Programmatic API access for integrating into automated AP workflows
  9. Docker Ready β€” Full Docker and Docker Compose support for containerized deployment
  10. 100% Local & Private β€” All inference runs through Ollama locally; sensitive financial data never leaves your machine

Quick Start

Prerequisites

  • Python 3.11 or higher
  • Ollama installed and running
  • Gemma 4 model pulled: ollama pull gemma4

Installation

git clone https://github.com/kennedyraju55/invoice-extractor.git
cd invoice-extractor
pip install -r requirements.txt

Running the Application

CLI:

python -m src.invoice_extractor.cli extract --file invoice.txt

Web UI:

streamlit run src/invoice_extractor/web_ui.py

Docker:

docker-compose up

Tech Stack

Technology Purpose
Gemma 4 + Ollama Local LLM inference for invoice parsing and categorization
Click + Rich CLI framework with formatted tables and progress bars
Streamlit Interactive web dashboard for invoice uploads

Project Structure

  • src/invoice_extractor/ β€” Core application: parsing engine, categorizer, CLI, web UI, API
  • common/ β€” Shared LLM client utilities for Ollama integration
  • tests/ β€” Unit and integration test suite
  • docs/ β€” Documentation and architecture diagrams
  • examples/ β€” Sample invoices and expected extraction outputs

Author

Nrk Raju Guthikonda β€” GitHub: kennedyraju55 Β· Dev.to Β· LinkedIn

About

πŸ“„ AI-powered invoice data extractor using local Gemma 4 LLM via Ollama - 100% private

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages