DEV Community

Cover image for InvoicePilot: a private AI invoice sorter for freelancers that runs offline with Gemma 4
Aman Kumar
Aman Kumar

Posted on AI-assisted

InvoicePilot: a private AI invoice sorter for freelancers that runs offline with Gemma 4

Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle Submission 💸

This is my submission for the Hacktoberfest Open-Source AI Challenge: Week 2 (Side Hustle).

The problem

Every freelancer I know has the same quarterly ritual: dig through email attachments, download folders and photos of paper receipts, then retype everything into a spreadsheet.

The "AI receipt scanners" that promise to fix this share two problems. They upload your client's invoices to someone else's API, which can break an NDA, and they add yet another monthly subscription.

What I built

InvoicePilot is a local-first invoice and receipt assistant. Drop in a PDF, PNG or JPG and it:

  1. Reads the text, using the PDF text layer or Tesseract OCR for scans and photos
  2. Sends it to Gemma 4 E2B running locally through Ollama, to extract vendor, dates, line items, tax and total
  3. Validates the result and flags anything suspicious
  4. Shows the original document next to the extracted fields so you can review it
  5. Exports approved records to CSV and charts spending by month, category and vendor

Everything runs on localhost. No document text, price or client name leaves the machine.

Demo video:

Why open models matter here

An invoice is one of the most sensitive documents a freelancer holds: client names, rates, bank details, tax IDs. Open weights change what's possible:

  • Privacy: the model runs on my laptop, so none of that data goes to a server I don't control.
  • Cost: there is no per-document fee and no subscription, which matters for a tool whose users watch every rupee or dollar.
  • Swappable: the model is one line in .env (OLLAMA_MODEL). I run Gemma 4 E2B by default, and I can try Llama 3.2 or Qwen without touching any code.
  • Offline: after the one-time model download, it works with no internet connection.

A small model like Gemma 4 E2B is what makes this realistic on an ordinary laptop (mine has 16 GB RAM and an RTX 3050).

Small models make mistakes, so I don't trust them blindly

Small on-device models can invent a zero tax line when a tax breakdown exists, confuse MM/DD with DD/MM dates, or return totals that don't add up. I treat the model's output as untrusted input:

  • Schema validation (Zod) rejects malformed output
  • One bounded repair attempt sends the exact validation error back to the model. If that fails, the record goes to human review instead of crashing
  • A deterministic math check: the backend verifies subtotal + tax - discount = total itself, in integer minor units, and warns on any mismatch
  • A human approves everything: nothing reaches the CSV export until you click approve

Who would pay

Freelancers, consultants and small business owners who handle client documents under confidentiality. The open core stays free (MIT). A paid one-time desktop build with extras such as separate client books is the way I'd make money from it.

Try it

Code (MIT): https://github.com/AMAN240310/invoicepilot

Stack: React + Vite, Express, SQLite, Tesseract.js, Ollama with Gemma 4 E2B.

Setup: ollama pull gemma4:e2b-it-qat, copy .env.example to server/.env, then run the server and the client.

Top comments (0)