DEV Community

Yagna Vyas
Yagna Vyas

Posted on

Receipt Sorter Pro: A Private Expense Tracker Powered by Local Qwen3

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

Receipt Sorter Pro is a private expense tracker for freelancers and small business owners. You upload receipts (.txt or text-based PDF) or paste the text, and a local open-weight model extracts the vendor, date, currency, tax, total, payment method, category, and line items.

Who would pay for it: a freelancer or shop owner who dreads sorting receipts at tax time but doesn't want to upload financial records to a cloud service.

What it gives them:

  • A dashboard with spending by category and month, plus top vendors
  • An editable review table to fix mistakes
  • A ⚠️ flag when the extracted total doesn't appear in the receipt
  • Vendor rules (for example, "uber" is always travel)
  • Duplicate detection
  • CSV and Excel export with summary sheets

Demo

I kept it local on purpose, because its main selling point is that your data never leaves your computer.

Code

Local Receipt Sorter

This small Python tool reads .txt receipts from receipts/, asks a local Ollama model to extract the vendor, date, total, and category, then writes the results to output.csv and prints spending totals for each category.

Requirements

  • Python 3.9 or newer
  • Ollama installed and running locally
  • The qwen3:4b model pulled into Ollama (or another model selected in sorter.py)

Install the Python dependency:

python -m pip install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode

Download the default model if needed:

ollama pull qwen3:4b
Enter fullscreen mode Exit fullscreen mode

Ollama must be running locally when you execute the sorter. If its service is not already running, start it in a separate terminal:

ollama serve
Enter fullscreen mode Exit fullscreen mode

Run

Put one plain-text receipt per .txt file in the receipts/ folder, then run:

python sorter.py
Enter fullscreen mode Exit fullscreen mode

The script uses Ollama's JSON response format and disables model thinking. It removes any <think>...</think> block if one appears and retries once when the response is invalid. The…

How I Built It

  • Model: Qwen3 4B, an open-weight model, running locally through Ollama. The app lets you switch to any model you have installed (I also have qwen3:8b).
  • Structured output: the model is given a JSON schema, so it can only return valid fields and allowed categories. Thinking mode is turned off and the temperature is 0, and there is one automatic retry on bad output.
  • Safety checks:each extracted total must appear in the original receipt text, otherwise the receipt is flagged for review. Dates are normalised to YYYY-MM-DD, and currency codes are cleaned up (Rs. becomes INR).
  • App: Python, Streamlit for the web interface, SQLite for saved history, and pandas for the dashboard and exports.
  • Tools: I started with GitHub Copilot, which generated the first command-line version (sorter.py) from one detailed prompt. I then extended it into the web app with a database, dashboard, and editing features.

I tested it on 10 receipts in different formats, including rupee bills with GST, a USD cloud invoice, and two deliberately messy receipts. The testing found a real bug: 5/10/26 was read as May instead of October. I fixed it by parsing ambiguous dates day-first, and I added the editable table because small models will always make some mistakes.

Why Does Open Innovation Matter?

-Privacy: receipts are financial records. Because Qwen3 runs on the user's own laptop, nothing goes to a third-party server. For this audience, that's the whole point.

  • Cost: there are no per-receipt API fees. Processing 10 receipts or 10,000 costs the same, which is what makes this viable as an affordable tool for a small business.
  • Offline: it works with no internet connection.
  • Control: I can swap models, change the prompt, add vendor rules, and tune the categories for a specific niche. With a closed API, I'd be tied to someone else's pricing, model changes, and data policies. Where it was weaker: a 4B model is slower than a cloud API and makes more mistakes, especially with ambiguous dates. I handled that with validation, a review flag, and manual editing, rather than hiding the problem.

My Agent Session

My First User

Prize Categories

Top comments (0)