I Stopped Asking AI to Split the Bill: SettleSloth Extracts Group-Chat Expenses with Gemma 4, and Deterministic Code Audits Every Rupee
This is a submission for the Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady What I Built Every group trip, flatmate bill split, or midnight hackathon food run ends with the same procrastinated
This is a submission for the Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady
What I Built
Every group trip, flatmate bill split, or midnight hackathon food run ends with the same procrastinated chore: scrolling through a chaotic WhatsApp or Telegram thread to figure out who owes whom.
Nobody writes clean accounting entries in a group chat. People type messages like:
"Rahul: Paid 2.4k for beach shack dinner last night""Priya: Paid 4800 for scuba package, don't count Aman he didn't do watersports""Aman: I sent Rahul 500 on GPay yesterday for breakfast""Neha: Maybe 350 for scooter petrol? Need to check receipt"
If you paste a transcript like that into a general-purpose chatbot and ask it to settle the tab, it frequently fails in subtle, frustrating ways. Language models can miscalculate splits with exclusions, double-count direct GPay repayments as fresh shared expenses, silently fold uncertain guesses ("Maybe 350?") into binding debts, or produce net balances that do not sum to zero.
SettleSloth π¦₯ solves this chore by enforcing a strict architectural boundary: the open-weight model extracts structured claims and verbatim quotes, while deterministic JavaScript verifies the evidence and computes the math.
Instead of spending Sunday night building a spreadsheet, you paste the raw chat dump and click Let the Sloth Settle It. SettleSloth extracts each claim using Google's open-weight gemma-4-26b-a4b-it, verifies every rupee against the exact source text via QuoteGuard, quarantines uncertain expenses in amber until a human confirms them, and computes a deterministic settlement plan.
Demo
- Live Deployed Application (Render): https://settlesloth.onrender.com/
- Live Service Health & Model Config Check: https://settlesloth.onrender.com/api/health
Walkthrough of a Real Hosted Run (Goa Weekend Trip Preset)
In our verified run on the live Render deployment using the 12-message Goa Trip preset:
-
Hosted Open-Weight Extraction: The backend called
gemma-4-26b-a4b-itvia Google AI Studio (completing the extraction pass in22,978 mson that hosted run). Out of 12 conversational messagesβincluding casual chatter like "Goa sunsets are amazing guys"βthe pipeline identified 9 financial messages. -
Verified Ledger (8 Confirmed Entries, βΉ14,850.00 Total Spend):
- Shorthand notation (
"Paid 2.4k for beach shack dinner") was parsed and verified against the source quote asβΉ2,400.00. - Participant exclusions (
"Paid 4800 for scuba package, don't count Aman") split the βΉ4,800 charge exclusively across Priya, Rahul, and Neha (βΉ1,600 each). - Direct peer-to-peer transfers (
"I sent Rahul 500 on GPay yesterday") were classified as arepaymentfrom Aman to Rahul rather than a new group expense.
- Shorthand notation (
-
Ambiguity Quarantine (1 Item Isolated):
- Neha's messageβ
"Maybe 350 for scooter petrol? Need to check receipt"βwas flagged by the deterministic quarantine rules because of the uncertainty markers ("Maybe","?","Need to check receipt"). It was kept out of the active balance math and placed in the amber Needs Checking (Quarantined Claims) card.
- Neha's messageβ
-
Zero-Sum Net Balances & Settlement Plan:
- Using integer paise arithmetic, the solver verified that all final net balances summed to exact zero (
Priya +βΉ4,854.17,Rahul +βΉ554.17,Aman -βΉ2,212.50,Neha -βΉ3,195.84). - The deterministic greedy settlement solver reduced the 8 verified transactions into 3 transfers:
-
Neha β Priya:
βΉ3,195.84 -
Aman β Priya:
βΉ1,658.33 -
Aman β Rahul:
βΉ554.17
-
Neha β Priya:
- Using integer paise arithmetic, the solver verified that all final net balances summed to exact zero (
-
Instant Human-in-the-Loop Recalculation (
POST /api/solve):- Checking Confirm & Include on Neha's quarantined βΉ350 petrol claim recalculates the entire ledger and transfer plan deterministically in memory (
0ms Math Update) without making another 23-second model call.
- Checking Confirm & Include on Neha's quarantined βΉ350 petrol claim recalculates the entire ledger and transfer plan deterministically in memory (
Code
YashK2003
/
settlesloth
Open-weight AI expense reconciler
SettleSloth π¦₯
"The Open Model Extracts, Deterministic Code Guarantees."
A neuro-symbolic group expense reconciler that turns chaotic group-chat dumps into audit-verified debt settlements. Built with Google Gemma open-weight models (hosted Gemma 4 via Google AI Studio or local Ollama), a deterministic verification engine, and zero external build tooling.
The Problem: Group Expense Procrastination & Chatbot Hallucination
Reconciling group expenses after weekend trips, hackathons, or month-end flatmate bills is notorious for causing procrastination:
-
Chaotic chat reality: Friends don't write structured ledgers; they send conversational Hinglish/slang text dumps
"Rahul: paid 2.4k for dinner. Aman didn't drink so don't count him." "Priya: Aman sent Rahul 500 for petrol. Petrol was maybe βΉ350?"
-
Shorthand, exclusions, and repayments: Expenses use
knotation (2.4k = 2400), complex participant exclusions (don't count Aman), direct repayments (Aman sent Rahul 500), and fuzzy, uncertain estimates. - Why pure LLM chatbots fail: When general-purpose LLMsβ¦
How I Built It
SettleSloth is built as a lightweight, zero-bundler Node.js (v20+) and Express 5 web application with only two runtime dependencies (express and dotenv) and a Vanilla HTML/CSS/JavaScript frontend styled with Tailwind CSS.
Raw Chat Dump βββΊ Open-Weight Extraction (Gemma 4 / Ollama / Fallback)
β
βΌ Structured JSON Claims + Verbatim Quotes
Deterministic Verification Engine (JavaScript)
βββ 1. QuoteGuard: Verifies substring & numeric match in source text
βββ 2. ParticipantGuard: Blocks unestablished names & self-repayments
βββ 3. Ambiguity Quarantine: Isolates "maybe" / "?" / "check" claims
β
βΌ Verified Claims Only
Deterministic Settlement Solver (POST /api/reconcile & /api/solve)
βββ Integer Paise Math (βΉ1.00 = 100 paise) + Remainder Distribution
βββ Zero-Sum Invariant Check: β NetBalance β‘ 0.00
βββ Greedy Cash-Flow Solver βββΊ Fewest Peer-to-Peer Transfers
1. The Open-Weight AI Layer (gemma-4-26b-a4b-it)
The model's only job is translating messy conversational text into a strict JSON schema containing payer, amount, excluded, type (expense vs. repayment), status (confirmed vs. ambiguous), and an exact_quote copied from the chat.
-
Hosted Mode (Demonstrated Live): Calls
gemma-4-26b-a4b-it(with support forgemma-4-31b-it) through the Google AI Studio REST API via nativefetch. -
Optional Local Mode (Implemented in Code): Includes an Ollama provider (
gemma3:4b/gemma3:1bathttp://localhost:11434) for offline local setups. (Note: On our public Render cloud instance,/api/healthreportsgoogle: true, ollama: false, so the live hosted demo runs via Google AI Studio rather than local Ollama). -
Deterministic Fallback Engine: Earlier in development, when a hosted API call hit a timeout, the system's automatic failover routed the request to our local regex heuristic parser (
fallbackParser.js), keeping the app responsive. After tuningGEMINI_TIMEOUT_MSfor the 26B model, hosted Gemma 4 inference succeeded cleanlyβwhile retaining the fallback parser for zero-key local runs or network outages.
2. The Deterministic Guardrail & Math Layer
Once Gemma returns candidate claims, deterministic JavaScript takes over:
-
QuoteGuard: Normalizes whitespace and casing to verify that every item'sexact_quoteactually exists in the raw chat text, and independently parses numerical tokens inside that quote (2.4k$\rightarrow$2400) to confirm the extracted amount is grounded in evidence. The UI also includes a Simulate Hallucination toggle to testQuoteGuardrejecting unbacked claims on demand. -
ParticipantGuard: Ensures no invented names accumulate debt and blocks invalid self-repayments. -
Integer Paise Arithmetic & Greedy Settlement: All splits are computed in integer paise (
βΉ1.00 = 100 paise) with deterministic remainder distribution to avoid IEEE 754 floating-point drift, followed by a greedy cash-flow solver that matches maximum debtors with maximum creditors.
3. Automated Testing & CI Verification
The repository includes 88 automated tests across 19 test suites using Node's native node --test runner, verifying QuoteGuard, ParticipantGuard, ambiguity quarantine, paise remainder distribution, zero-sum balance invariants, and API contracts. A GitHub Actions CI pipeline executes the full test suite on Node.js 24 on every push and pull request.
Why Does Open Innovation Matter?
Building SettleSloth around open-weight models and inspectable verification code matters for three concrete engineering reasons:
-
Auditable Trust Boundaries Instead of Black-Box Math: Financial reconciliation requires knowing why a number is on the screen. By pairing an open-weight Gemma model with open-source verification guards (
QuoteGuardandParticipantGuard), every balance is traceable back to a highlighted substring in the original conversation. -
Deployment Portability and Honest Privacy Trade-Offs: Using the hosted Render demo (
gemma-4-26b-a4b-itvia Google AI Studio) makes SettleSloth immediately testable in any browser with zero setup, though it sends the chat text to Google's API for inference. Because the model layer is built on the open-weight Gemma family and a unified adapter, anyone who wants strict on-device privacy for personal financial chats can clone the MIT-licensed repository and point.envat a local Ollama model (gemma3:4b) or run the offline deterministic fallback without rewriting the application. - Resilience Against API Failures: Open architectures allow developers to design graceful degradation. Coupling an open-weight model adapter with a deterministic local fallback means a group can still settle their tab even when an API key is missing or an external endpoint times out.
The Lazy Payoff
The real friction of settling group expenses isn't paying your friendsβit's the cognitive drudgery of reading 30 chat messages, mentally subtracting someone who skipped watersports, remembering a βΉ500 GPay transfer from Tuesday, and arguing over an unconfirmed petrol receipt.
In the Goa Trip scenario, SettleSloth turns 12 messy chat messages into 3 ready-to-send payment lines and a one-click Copy WhatsApp Summary card. While the UI displays an illustrative estimate of ~27 mins saved (modeled as a simple product heuristic of roughly 3 minutes of manual spreadsheet checking saved per financial message, rather than a clinical user study), the practical payoff is immediate: when Neha eventually finds her βΉ350 petrol receipt, confirming it takes one checkbox click and 0ms of local math instead of rebuilding a spreadsheet from scratch.
Prize Categories
-
Best Use of Gemma: SettleSloth uses Google's open-weight
gemma-4-26b-a4b-itmodel as its natural-language extraction core to parse messy Hinglish chat dumps, shorthand figures (2.4k), participant exclusions, direct repayments, and verbatim quotes before passing them to the deterministic verification engine. -
Best Use of Render: Both the Node.js/Express API runtime and the interactive frontend workbench are deployed on Render (https://settlesloth.onrender.com/) using a declarative
render.yamlBlueprint and a live/api/healthreadiness endpoint. - Best Use of GitHub Copilot: The project automates repository verification and regression testing using a GitHub Actions CI workflow (qualifying under the official category criteria to "automate your project with GitHub Actions"), running all 88 unit and integration tests on Node.js 24 across pushes and pull requests.
Conclusion
Language models are remarkably good at understanding messy human conversation, but they should never be the final authority on a financial ledger. By letting open-weight Gemma 4 extract the claims while deterministic code demands verbatim evidence and computes the paise math, SettleSloth lets everyone in the group chat be a little lazierβwithout getting shortchanged.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.
