DEV Community

Magatam Yogesh
Magatam Yogesh

Posted on

Weekly Challenge 2

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

LocalLedger is a 100% private, on-device receipt and invoice sorter for freelancers, solopreneurs, and tiny agencies preparing for tax season.

What it does: Drop in photos (PNG, JPG, WEBP) or PDFs of receipts and invoices. The app extracts the vendor, invoice number, date, GSTIN, combined GST (CGST + SGST or IGST), total amount, and tax category into an in-place editable spreadsheet, and exports a tidy CSV or JSON.
Who would pay for it: Freelance developers, designers, and boutique agencies who manage dozens of monthly expenses (cloud subscriptions, software licenses, travel, coworking, hardware) and want tax preparation without paying recurring SaaS subscription fees.
The problem it solves: Commercial expense apps require uploading sensitive financial documentsβ€”revealing client names, billing rates, PAN/GSTIN IDs, and bank detailsβ€”to third-party cloud servers, violating client NDAs and financial privacy. LocalLedger runs optical character recognition (OCR) inside the browser via WebAssembly and runs an open-weight language model locally on the user's laptop through Ollama. Financial documents never touch the internet.

Demo

LocalLedger runs locally on any modern laptop (tested on 8 GB RAM, CPU only).
Run Locally:
bash

1. Pull the 1 GB open-weight model

ollama pull qwen2.5:1.5b

2. Allow browser CORS

Windows (PowerShell): setx OLLAMA_ORIGINS "" | macOS/Linux: OLLAMA_ORIGINS="" ollama serve

3. Serve and open

py -m http.server 8080

Open http://localhost:8080 in your browserHighlights:

1-Click Instant Demo: Built-in "Load 3 Sample Invoices" button instantly loads sample Swiggy, Uber, and Hardware receipts into the live OCR + AI pipeline without needing to find files. Side-by-Side Verification: Click the icon on any row to inspect the original receipt canvas side-by-side with extracted values and raw OCR text.
Financial Metric Cards: Live tallies of Total Spend, Claimable GST (Input Tax Credit), and document review warnings.
One-Click Export: Download tidy CSV formatted with Excel UTF-8 BOM or export clean JSON.

Code

GitHub logo yogeshmagatam / Local-Ledger-local-receipt-and-invoice-sorter

Private receipt and invoice sorter. OCR in the browser plus a local open-source AI model. Nothing leaves your laptop.

LocalLedger πŸ›‘οΈ

Private On-Device Invoice & Receipt Sorter for Freelancers and Tiny Agencies

Built October 13-18, 2026 for the DEV Hacktoberfest Open-Source AI Challenge, Week 2 (Side Hustle)

Drop in photos or PDFs of receipts and invoices. LocalLedger reads them directly on your machine and generates a clean, editable ledger with Vendor, Invoice Number, Date, GSTIN, GST (CGST+SGST/IGST), Total, and Category, ready to download as a tidy CSV or JSON for tax season.

100% On-Device Privacy: Financial documents never leave your laptop. OCR runs inside your browser via WebAssembly (Tesseract.js & PDF.js), and local AI inference runs on your own machine through Ollama. Zero telemetry, zero cloud uploads.

DEV Hacktoberfest Open-Source AI Challenge, Week 2 (Side Hustle Track).


Architecture & How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   YOUR LAPTOP ONLY                     β”‚
β”‚                                                        β”‚
β”‚  [ Receipts / Invoices ] (PDF, PNG, JPG, WEBP)         β”‚
β”‚          β”‚                                             β”‚
β”‚          β–Ό                                             β”‚
…



Repository: https://github.com/yogeshmagatam/Local-Ledger-local-receipt-and-invoice-sorter

License: MIT License

Core files:

index.html: Accessible dashboard UI with drag-and-drop zone, metrics, and verification modal.

style.css: Modern financial dark/light theme, glassmorphic cards, and responsive tables.

app.js: In-browser PDF text layer extractor, Tesseract.js WASM runner, Ollama caller, and safe merge engine.

extract.js: Isomorphic rule-based extractor for dates, GSTINs, and combined taxes.

samples/: Bundled sample test receipts.

How I Built It

LocalLedger is built around a dual-layer extraction architecture that pairs deterministic client-side parsing with local open-weight AI:

[ Receipts / Invoices (PDF, PNG, JPG) ]
β”‚
β–Ό
[ In-Browser OCR Layer ]
β€’ PDF.js (Digital PDF text layer)
β€’ Tesseract.js (WASM client-side optical scan)
β”‚
β–Ό
[ Deterministic Rule Engine (extract.js) ]
β€’ Day-first dates (DD/MM/YYYY)
β€’ 15-character GSTIN & OIDAR formats
β€’ Combined CGST + SGST + IGST tax calculation
β”‚
β–Ό
[ Local AI Layer (Ollama: qwen2.5:1.5b) ]
β€’ Structured JSON extraction (format: "json")
β€’ Merchant name normalization & category sorting
β”‚
β–Ό
[ Anti-Hallucination Guardrail ]
β€’ Rejects model amounts unless they appear in raw OCR text
β”‚
β–Ό
[ Interactive Ledger & CSV / JSON Export ]

Key Technical Decisions:
Open-Source AI Model: qwen2.5:1.5b (~986 MB footprint) hosted locally via Ollama. It delivers structured JSON parsing (format: "json", temperature: 0) with zero cloud latency and no per-token costs.
Client-Side OCR: Tesseract.js (WebAssembly OCR) and PDF.js handle text extraction entirely in browser memory.
Anti-Hallucination Guardrail: Small 1.5B models can invent numbers if prompted loosely. LocalLedger strictly rejects any amount returned by the model unless that exact number appears in the raw OCR scan. If the model strays, the deterministic rule engine acts as the ground truth.
GST Tax Preservation: In Indian tax invoices, CGST and SGST are listed as separate line items. The rule engine calculates the sum (CGST + SGST), while the merge logic prevents the AI from overwriting the combined sum with a single tax component, protecting the freelancer's Input Tax Credit.

Why Does Open Innovation Matter?

Financial documents are deeply personal and legally sensitive.
If LocalLedger were built with closed APIs (such as OpenAI, Anthropic, or cloud document OCR endpoints):
Privacy is Compromised: Sensitive client names, invoice values, bank account details, and government tax IDs would be transmitted across the wire to cloud data centers.
Unsustainable for Side Hustles: Metered API fees make personal financial tools expensive to run for solo builders.
Vendor Lock-In & Offline Failure: Cloud document APIs break the moment you are offline or an endpoint changes terms.
Open innovation made it possible to combine open-weight models (Qwen 2.5), local runtime engines (Ollama), and browser-compiled tools (Tesseract.js WASM). Together, they prove that enterprise-grade financial extraction can run completely inside an 8 GB consumer laptop with zero telemetry and zero ongoing costs.
My Agent Session
This application was developed and debugged with Antigravity. During the pair programming session, the agent:
Tested local Ollama inference and validated CORS connectivity from the browser.
Identified and fixed a regex tokenization bug in extract.js where 4-digit unformatted numbers (like 7194.92) were being split into 719 and 4.92.
Solved an Input Tax Credit bug in app.js to prevent combined CGST + SGST sums from being replaced by single-component AI outputs.
Built automated end-to-end integration test runners in Node.js verifying 100% extraction accuracy across realistic test receipts.
Crafted the modern financial dark/light UI, live ITC metric cards, and the side-by-side document preview modal.

My First User
I shared LocalLedger with a freelance UI/UX designer who normally spends hours every quarter sorting PDF invoices and receipts for her chartered accountant.
Her feedback:
"Every tax season I end up with dozens of PDFs from Figma, Google Workspace, client cafes, and cab rides. I tested LocalLedger by dropping 15 invoices into the dropzone. It extracted the dates, GST amounts, and totals in seconds. Being able to preview the original PDF alongside the extracted numbers made verification effortlessβ€”and knowing my receipts never left my machine gave me total peace of mind."

My Agent Session

My First User

Prize Categories

Top comments (0)