LedgerGemma:自由工作者的開源本機 AI 財務工作空間
LedgerGemma
LedgerGemma 是一款以 Google Gemma 2 驅動、可在本機運行的開源 AI 財務工作空間,協助自由工作者解析收據及發票,並將開支對應至 IRS Schedule C 扣税項目。系統透過 Ollama 執行 Gemma 2 推理;如沒有本機 Ollama daemon,則改用內置規則引擎,並以 SQLite 在本地儲存資料,毋須外部伺服器。
What I Built:
LedgerGemma is an open-source, on-device AI financial workspace and receipt/invoice intelligence engine for freelancers, independent contractors, and side-hustlers. Powered by Google Gemma 2, it parses messy receipts and invoices, automatically maps expenses to official IRS Schedule C tax write-off lines, and provides a confidential financial AI co-pilot that runs completely on your laptop with zero cloud data leakage.
Who Would Pay for It?
Tech Freelancers & Consultants: Developers, UX designers, and marketers who manage multiple clients and sign strict non-disclosure agreements (NDAs).
Creators & Digital Solopreneurs: YouTubers, writers, and indie hackers with hundreds of micro-SaaS subscriptions who dread quarterly tax prep.
Boutique Bookkeepers: Solo accountants managing 10–20 client books locally without paying expensive per-seat software fees.
The Problem It Solves
Freelancers lose an average of $3,500 every tax season in missed deductions and waste 10+ hours a month wrestling with shoeboxes of digital receipts. Existing cloud SaaS solutions (QuickBooks, Expensify) fail them:
The Privacy Breach: Uploading client invoices containing confidential rates, contract terms, and banking routing numbers to third-party cloud AI APIs violates client NDAs.
Subscription Fatigue: QuickBooks charges $35 to $90 every month ($420–$1,080/year) plus per-receipt scanning surcharges for software freelancers only check quarterly.
No Offline Support: Cloud accounting tools are completely useless when traveling, on flights, or working from cafes without stable Wi-Fi.
The Offer: A $49 lifetime license (or free community self-hosted CLI) replaces a $420/year SaaS bill with 100% local privacy and zero recurring costs.
Demo
The application runs locally as a sleek, dark-mode glassmorphic financial terminal:
Key UI Capabilities:
Real-Time Financial KPIs: Live tracking of Gross Spend, Deductible Amount, Estimated Tax Savings (calculated at a 30% combined self-employment + income tax bracket), and Client Reimbursables.
Local Dropzone Ingestion: Drag and drop any PDF, PNG, JPG, or TXT receipt. Ingestion runs on-device in milliseconds.
Itemized Inspection Modal: Click any transaction to review vendor, invoice number, line items, OCR text, and Gemma 2's step-by-step tax rationale with confidence scoring.
Interactive Schedule C Analytics: Dynamic Chart.js visualizations showing deduction percentages across Part II Line 8 (Advertising), Line 11 (Contract Labor), Line 13 (Section 179 Hardware), Line 18 (Office Expense & SaaS), Line 24a (Travel), and Line 24b (50% Business Meals).
Client Expense Isolator: Groups billable project expenses by client (Fintech Client App, Horizon Media, etc.) so reimbursable expenses can be invoiced without exposing other client rates.
1-Click CPA Export Pack: Downloads a clean, formatted CSV and printable audit report formatted for TurboTax, H&R Block, or certified CPAs.
Quick Local Setup:
bash
# Clone the repository
git clone https://github.com/sanchitagarwal/LedgerGemma.git
cd LedgerGemma
# Launch with one command
./run.sh
Tested on Python 3.10+ (macOS, Linux, Windows) and Docker.
How I Built It
LedgerGemma is engineered around a local-first, dual-engine open-source AI architecture:
- Google Gemma 2 Open-Weight Intelligence
The core intelligence engine uses Google Gemma 2 (gemma2:2b / gemma2:9b). Gemma 2 was chosen for its exceptional reasoning, compact parameter footprint, and strict instruction adherence on consumer laptops.
I implemented Gemma 2's native turn formatting (user ... \nmodel\n) with a specialized accounting system prompt that enforces structured JSON schema extraction:
python
system_prompt = (
"You are LedgerGemma, an expert local accountant AI specializing in freelance bookkeeping and IRS Schedule C tax deductions.\n"
"Extract vendor_name, total_amount, issue_date, tax_category, schedule_c_line, gemma_explanation, and line_items.\n"
"Respond ONLY with valid JSON."
)
gemma_prompt = (
f"<start_of_turn>user\n{system_prompt}\n\n{document_text}<end_of_turn>\n"
f"<start_of_turn>model\n"
)
- Dual-Engine Zero-Friction Fallback
To ensure the project runs out of the box for anyone without requiring a 5GB model download or GPU setup:
When a local Ollama daemon is active, it runs live Gemma 2 model inference.
If no daemon is present, it seamlessly falls back to an embedded heuristic rule engine that applies identical Schedule C accounting logic.
- Local Document Parsing & ACID Storage Document Ingestion: Uses pypdf for digital PDF text extraction and Pillow for local image parsing. Database: Local SQLite database (data/ledger.db) storing transaction records, JSON line items, and audit trails without external server dependencies. Why Does Open Innovation Matter?
Open innovation isn't just an implementation detail for LedgerGemma — it is the entire reason the product can exist:
- Zero Cloud Data Leakage for Client NDAs
Freelancers handle client contracts, proprietary billing rates, banking details, and NDA-protected deliverables. Using closed AI APIs (like OpenAI GPT-4o) requires transmitting customer data over the wire to servers they don't control. Open-weight Gemma 2 ensures client financial data never leaves the physical laptop.
- 100% Gross Margins & No Token API Tax
Closed AI wrappers are crushed by per-token margins: processing 500 multi-page receipts per user per quarter with cloud APIs would cost $10–$25 in token fees, forcing high monthly subscriptions. Because Gemma 2 executes on the customer's own Apple Silicon or CPU, our marginal server cost per user is $0.00.
- Full Offline Portability
Freelancers work on airplanes, trains, and in cafes with unreliable Wi-Fi. Closed APIs immediately stop working the moment you lose internet connection. LedgerGemma parses and categorizes receipts on a flight with airplane mode enabled.
- Independence from Vendor Lock-in & Deprecation
Closed AI providers regularly deprecate model checkpoints, change pricing tiers, and impose rate limits. Open weights mean the software you buy today will function reliably 5 years from now.
My Agent Session
This project was pair-programmed using Google DeepMind's Antigravity agentic coding environment. The full development transcript — including architecture design, schema modeling, local SQLite implementation, and automated test suite execution — is preserved locally and available in the repository.
My First User
To validate the side hustle concept, I gave LedgerGemma to a freelance frontend engineer friend who had been dreading sorting through his 2026 expenses.
His Feedback:
"Wait, it categorized my AWS bill and Figma subscription under Line 18 automatically? And it split out my client dinner at 50% without me having to look up the tax rule? I would pay $50 for this right now just so I don't have to touch QuickBooks ever again."
The Result:
Did he use it? Yes, he ingested 14 receipts spanning hosting, software, travel, and meals.
Would he pay? Absolutely. He validated that a $49 one-time purchase is an instant buy compared to paying Intuit $35 every month.
What did he ask for next? A 1-click feature to generate a PDF invoice for reimbursable client expenses (Uber rides and client flights), which is now prioritized for v1.1!
來源:DEV Community · dev.to


