DEV Community

arjav patni
arjav patni

Posted on

Receipt Sorter Pro: My Hacktoberfest AI Side Hustle Built with Gemma 2B

Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle Submission đź’¸

Receipt & Invoice Sorter Pro: Local AI Bookkeeping for Freelancers

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

(Targeting Prize Categories: Best Use of Gemma)

What I Built

Receipt & Invoice Sorter Pro is a privacy-first, 100% local micro-SaaS utility designed for freelancers and small businesses. It parses multi-vendor PDF, CSV, and JSON invoices into structured, itemized tables with automatic tax categorization—all running completely offline on a local Gemma 2B instance.

Who Would Pay For It & Why

Freelancers and small business owners spend hours manually sorting receipts for quarterly tax filing or client expense billing. Existing cloud solutions pose significant data security and compliance risks by uploading sensitive financial telemetry, bank statements, and client information to cloud servers.

Receipt & Invoice Sorter Pro operates as a paid local utility tool. Freelancers and small businesses get an instant bookkeeping assistant with zero risk of client data leaking to third-party servers.

How I Built It

  • Local AI Inference Engine: Powered by Gemma 2B running locally via Ollama, ensuring zero cloud latency and complete offline capability.
  • Deterministic Python Backend: Built with FastAPI. To overcome small-model limits like attention bleed across dense documents, the backend uses regex chunking to isolate individual invoices, sanitizes broken OCR line breaks, and enforces strict mathematical guardrails on line-item math.
  • Frontend Dashboard: Built using Next.js, TypeScript, and Tailwind CSS, featuring document staging, raw text parsing, and nested itemized breakdown cards.

Why Does Open Innovation Matter?

  1. Zero Marginal Cost: SaaS accounting tools charge per invoice processed. Running open-weight models locally allows freelancers to process thousands of heavy invoices with zero per-token API charges.
  2. Absolute Privacy Guarantee: Financial and tax data never touches a remote server, offering complete privacy compliance by design.

Code Highlight: Deterministic Chunker & Math Guardrails

Here is how the Python backend isolates multi-invoice documents and corrects column shifts:


python
# 1. Deterministic Chunking to prevent 2B Attention Bleed
chunks = re.split(r'(?i)Invoice\s*\d+\s*[:\-]', raw_text)

# 2. Python Math Guardrails on AI JSON Output
for item in inv.get("line_items", []):
    qty = float(item.get("quantity", 1))
    unit = float(item.get("unit_price", 0))
    total = float(item.get("total", 0))

    # Correct column shifting (where total was placed in unit price)
    if qty > 0 and total != 0 and unit == 0:
        item["unit_price"] = round(total / qty, 2)
    elif qty > 0 and unit != 0 and total == 0:
        item["total"] = round(qty * unit, 2)


My First User & Feedback
I tested the application with a freelance web developer who manages multiple software and hosting vendor receipts monthly.

Feedback: They loved that it handles discount lines and multi-invoice PDFs automatically without uploading files to an external API.

Next Request: They asked for a direct export button to download the structured table as an Excel (.xlsx) file!

GitHub Repository


Enter fullscreen mode Exit fullscreen mode

Top comments (0)