DEV Community

Samarth Murade
Samarth Murade

Posted on

Local Receipt Sorter: Gemma 4 turns freelancers' receipts into spreadsheets, offline

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

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle

What I Built

Local Receipt Sorter turns a pile of receipt photos and PDFs into a clean, categorized CSV. An open-weight vision model (Gemma 4) runs on the user's own laptop through Ollama, reads each receipt, and returns the vendor, date, total, currency and category. There's an editable review table, totals per category, and a one-click CSV export that opens straight in Excel or Google Sheets.

It's built for freelancers and tiny agencies. They handle financial documents that belong to their clients, and at tax time someone has to type every receipt into a spreadsheet by hand. Cloud tools can do this job, but they mean uploading those documents to someone else's server. I haven't tested whether people would pay for this yet, but the pain it targets is real and recurring.

Demo

In the video I switch off Wi-Fi before extracting, to show that everything runs locally.

Code

Local Receipt Sorter

Turn a pile of receipt photos and PDFs into a clean, categorized CSV, using an open-weight vision model (Gemma 4) that runs entirely on your own computer.

Built for the DEV Hacktoberfest Open-Source AI Challenge, Week 2 (Side Hustle).

Why local?

Freelancers handle financial documents that belong to their clients. Sending them to a cloud API means that data leaves their control. Here the model runs on the laptop through Ollama, so no receipt is uploaded, there is no per-receipt cost, and it works offline.

How it works

  1. Upload receipt images (PNG, JPG, WEBP) or PDFs.
  2. Each file is resized and sent to a local vision model through Ollama.
  3. The model must answer in a fixed JSON schema: vendor, date, total, currency, category, notes.
  4. You review and fix any cell in an editable table, then download the CSV.

Run it

ollama pull gemma4:e4b
python3 -m venv .venv
…

How I Built It

  • Model: Gemma 4 (gemma4:e4b), an open-weight vision model, served locally by Ollama.
  • Structured output: every call passes a JSON schema (defined with Pydantic), so the model has to return vendor, date, total, currency, category and notes in a fixed shape. Temperature is 0, and thinking is switched off because receipt reading doesn't need it and it made responses slower.
  • Preprocessing: photos are resized to 1280 px on the longest side so a laptop can process them quickly, and PDFs are rendered to images with PyMuPDF.
  • Interface: a small Streamlit app with drag-and-drop upload, an editable results table, category totals and CSV download.

How I tested it: I generated synthetic receipts with known correct answers and compared the model's output against them. In my first test run I fed it 3 receipts, and the model read all 3 completely correctly: vendor, date, total and category. Each receipt took about 5 to 6 seconds on a MacBook Air. That's a very small sample of clean, synthetic receipts, so it shows the pipeline works but says little about how it handles messy real-world receipts. I haven't yet measured accuracy on blurry, crumpled or handwritten ones.

Why Does Open Innovation Matter?

  • Privacy: a freelancer's receipts include client names and amounts. Because the model runs locally, none of it leaves the laptop. I turned off Wi-Fi in the demo to prove it.
  • Cost: there's no per-receipt API fee, so processing 10 receipts or 10,000 costs the same: nothing beyond electricity.
  • No lock-in: the model name is a setting in the sidebar. Any vision-capable model in Ollama works, so I can swap a bigger or smaller one in without changing the code.

Where a closed model would probably do better: large cloud models are likely more accurate on crumpled or handwritten receipts, and they'd be faster than a laptop. For a paid product I'd keep the local model as the default and offer an optional high-accuracy mode, but the privacy-first default is what makes this tool different.

Limitations: only the first page of a PDF is read, categories are the model's best guess, and PyMuPDF is AGPL-licensed, so I'd swap it for a permissively licensed alternative before selling this commercially.

Prize Categories

  • Best Use of Gemma: Gemma 4 runs locally through Ollama and does all the receipt reading.

Top comments (0)