DEV Community

Abdullah Bin Altaf
Abdullah Bin Altaf

Posted on AI-assisted

ChatLedger: Turning messy WhatsApp DMs into an order book for home businesses

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

A lot of small businesses near me don't have a website. Their whole shop is a WhatsApp number and an Instagram page: home bakers, tailors, thrift resellers, people who sew plushies and sell them to friends of friends.

Every order comes in as a conversation like this:

Ayesha: can i get the choc fudge cake for saturday? 1kg
Ayesha: oh and add a box of brownies too
Sara:   Done! 50% advance to confirm pls
Ayesha: <Media omitted>
Ayesha: sent 30 ๐Ÿ‘
        ...next day...
Ayesha: sorry can u make it 2 boxes of brownies instead of 1??
Enter fullscreen mode Exit fullscreen mode

Now imagine 20 of those a week, mixed in with "is this still available?" messages, voice notes and family group chats. What did Ayesha finally order? How much does she still owe? Did Bilal say Thursday or Friday? The seller ends up scrolling back through weeks of messages, or forgets, and forgetting costs real money.

ChatLedger fixes that. You paste the chat (or upload a WhatsApp export), and it gives you back:

  • ๐Ÿ“‹ A clean order list: who ordered what, how many, when it's due, where it goes
  • ๐Ÿ” The final version of every order. "Make it 2 boxes instead" updates the order instead of creating a second one, and cancelled orders are marked cancelled.
  • ๐Ÿ’ฐ Correct totals and balances, using the seller's price list, including special prices agreed in the chat ("ok since it's 10, 5 each ๐Ÿ˜„")
  • โœ… Who has paid, who has partly paid and who still owes, plus one number at the top: still to collect
  • ๐Ÿงพ A printable invoice for each order
  • ๐Ÿ’ฌ A one-tap WhatsApp reminder with the order summary, the balance and payment details
  • ๐Ÿ” "Why the AI thinks this": every order quotes the exact chat lines it came from, so the seller can check it in seconds instead of trusting a black box

Who would pay for it? Any seller doing 10+ DM orders a week. One forgotten balance on a cake order costs more than a month of a $5 subscription, so the value is easy to explain.

Demo

(It runs on Render's free tier, so if the page takes ~50 seconds to load the first time, it's waking up.)

Code

ChatLedger

Paste your DMs. Get your orders.

Home bakers, tailors and resellers take orders in WhatsApp and Instagram DMs. Orders get changed ("make it 2 boxes instead"), cancelled, half-paid with a screenshot, and buried under 200 other messages. ChatLedger reads the messy chat and gives back:

  • a clean order list with items, quantity, due date, address and phone number
  • totals and balances, computed from your price list (including prices you negotiated in the chat)
  • what's paid, what's partly paid and what's still owed
  • a printable invoice for each order
  • a one-tap WhatsApp confirmation or payment reminder
  • a CSV export for your spreadsheet

Each order shows the exact chat lines it came from ("Why the AI thinks this"), so you can check it in seconds.

How it works

chat text โ”€โ”€โ–บ clean-up (drop "<Media omitted>", system lines)
          โ”€โ”€โ–บ open-weight LLM (Gemma via any OpenAI-compatible API) โ”€โ”€โ–บ JSON
          โ”€โ”€โ–บ Python:
โ€ฆ

How I Built It

The stack is deliberately small: FastAPI on the back end, plain HTML/CSS/JS on the front end (no build step), and an open-weight LLM doing the reading.

chat โ”€โ–บ clean-up โ”€โ–บ open-weight LLM โ”€โ–บ JSON โ”€โ–บ Python does the math โ”€โ–บ order cards
Enter fullscreen mode Exit fullscreen mode

1. Clean the chat first. WhatsApp exports are full of noise: <Media omitted>, "This message was deleted", encryption notices. I strip those before calling the model. It saves tokens, which matters on free-tier rate limits.

2. The model reads, and only reads. The open-weight model gets the chat, the seller's price list and a strict set of rules:

  • output only the final version of each order
  • never invent an address, phone number or price
  • return null when something isn't stated
  • include 1โ€“3 verbatim quotes as evidence for every order

It returns structured JSON.

3. The code does all the math. This was the most important design decision. LLMs are great at understanding "can u make it 2 boxes instead of 1??" and unreliable at multiplying 2 ร— 18. A wrong balance is the one mistake a seller won't forgive, so the model never produces a total. Python takes the extracted items and:

  • matches them to the price list (the customer says "elephant play toy," the catalog says "Elephant plushie," and it still matches)
  • computes every line total, order total and balance
  • works out paid / partial / unpaid from the amounts
  • validates everything the model returned

4. A provider-agnostic client. ChatLedger talks to any OpenAI-compatible endpoint and falls back automatically if one fails:

Provider Model
Google AI Studio Gemma
Groq gpt-oss-120b
OpenRouter free open-weight models
Custom Ollama / vLLM on your own machine

The live demo runs on gpt-oss-120b via Groq's free tier. It extracted all five orders in the sample chat correctly in about 6 seconds, including the changed order, the cancellation and the negotiated price.

5. Small things for real use:

  • It's mobile-first, because sellers live on their phones.
  • Orders stay in the browser, so there's no account to create.
  • A per-visitor rate limit stops the public demo from draining the free API quota.

Why Does Open Innovation Matter?

This project only makes sense as a business because of open-weight models.

๐Ÿ’ธ The margins work. Extracting a week of chats with an open-weight model on a cheap provider costs a fraction of a cent. That means a $5/month tool for a home baker can be profitable. On premium closed-model pricing, the cost per seller would eat most of that margin.

๐Ÿ”“ No lock-in, and I found that out for real. Halfway through building, the model I'd picked was retired by the provider and my requests started returning 404s. Because everything speaks the same OpenAI-compatible API and the models are open, I switched to another open-weight model by changing one line of config. The extraction got better, not worse. Building on a single closed vendor, that would have been a scramble.

๐Ÿ” Privacy can be offered. These chats are full of customers' names, home addresses and phone numbers. Because the models are open-weight, a seller who doesn't want that data on anyone else's server can run the exact same app against a model on their own machine with Ollama, by setting three environment variables and changing no code. My own laptop can't run models locally, which is why the demo uses hosted endpoints, but the option exists only because the weights are open.

๐ŸŒ Room to specialize. Real order chats near me are rarely in pure English. They switch between Urdu and English mid-sentence, use local slang, and say "pls" and "bro" a lot. Open weights mean this can eventually be fine-tuned on real order chats, a niche that a general-purpose closed API will never prioritize.

Prize Categories

  • Best Use of Render: ChatLedger is deployed as a Render web service from a render.yaml Blueprint, and it's the live demo judges can use.

Top comments (0)