Try it: https://ghost-debts.vercel.app (press Try a sample page: no login, no API call) · Code: https://github.com/ShermaineYap/ghost-debts
Inspiration
Across Malaysia, small sundry shops (kedai runcit) and stalls still sell on credit and write it in a pocket notebook, the buku tiga lima (555). It is usually the only copy. A stall owner in Kelantan once had to appeal publicly for her lost buku 555, because it was her only proof of what she was owed.
The apps that exist ask owners to retype every entry, so they don't, and the notebook stays the record. I wanted to keep the notebook and raise it from the dead instead.
What it does
- Snap a notebook page, or try the sample page.
- Read: a vision model turns each line into date, customer, item, amount, and whether it's a payment.
- Verify: any cell the app isn't sure about haunts the page with a ghost glow and a reason, such as "blurry photo", "amount unclear" or "reader unsure". The owner must confirm or correct it, and nothing unconfirmed is ever saved.
- Reconcile: if the page has a written total (Jumlah), the app checks it and points at the row most likely to be wrong. On the sample page it suggests that Auntie Mei's RM 8.90 is really RM 7.90.
- Ledger: per-customer balances and history, kept only on the phone. Settled customers are laid to rest.
- Remind: a polite reminder in Bahasa Melayu or English opens in WhatsApp. The owner presses send; the app never sends anything itself.
The page photo is sent once to be read and is not stored or logged.
Measured results (live app, synthetic pages)
I made 10 notebook pages with invented names and typed ground truth. A clean set draws them in six handwriting-style fonts on ruled paper, like a phone photo. A degraded set adds low resolution, blur, dim light, smudges and heavy JPEG compression. Every page went through the deployed /api/read-page and was scored by eval/score.ts (npm run eval with EVAL_ENDPOINT).
| Before fix | After fix | |
|---|---|---|
| Wrong cells flagged as haunted (degraded) | 3 / 40 (7.5%) | 34 / 34 (100%) |
| Amounts read exactly (degraded) | 58% | 61% |
| Amounts and names read exactly (clean) | 100% (87 rows) | 100% (35 rows) |
| Right cells haunted anyway (clean) | – | 3 of 70 |
| Average time per page (after fix) | 5.8 s clean, 9.0 s degraded |
What I learned: Gemini reported about 0.9–0.95 confidence on almost every cell, including the wrong ones, so a reader that trusts the model's own confidence is silently wrong. The fix was a Kiro bugfix spec, silent-misreads. The app now scores photo quality itself (sharpness, contrast, resolution). The model also copies each amount exactly as written, and the app checks that against the number it reported. On a poor photo every cell is haunted, by design: that's the cost of never being silently wrong.
How I built it
Next.js (App Router), TypeScript strict, Tailwind and zod, on Vercel. The Gemini Flash vision model is called from one server route. It tries a chain of models (newer ones were often overloaded on the free tier) and returns safe diagnostics that never contain the image, the model output or the key. Money is integer sen; the ledger lives in browser storage. 161 tests (Vitest + fast-check) across 17 files.
How Kiro was used
All application code was written by Kiro's agent in Kiro Web: the commits are authored by kiro-agent. I used an AI assistant (Claude) to help draft the steering files and the prompts I gave Kiro, and to generate the synthetic study pages and run the live study. No app code came from outside Kiro. Everything was done in Kiro Web, which ran each session in a cloud sandbox and pushed straight to GitHub. I didn't use the IDE or CLI, MCP servers, or Kiro powers for this build.
- Steering (4 files): product, tech, structure, and privacy-and-copy. Kiro applied them unprompted: a 5 MB limit, a privacy notice before the first scan, 44 px tap targets, no logging in the read route, and respectful reminder wording.
- Specs (4), with EARS requirements, design and tasks:
page-reader: 12 requirements. The promise "nothing unconfirmed reaches the ledger" became testable: the save function refuses unresolved haunted cells even when called directly.ledger-maths: balances, refusing a page saved twice, and reconcile with a ranked "check first" row.reminders: the customer page and the WhatsApp reminder.silent-misreads: a bugfix spec with current, expected and unchanged behaviour, written from the measured failure.
- Property-based testing found three real bugs:
- WhatsApp link: the standard URL encoder leaves
! ' ( ) *unencoded. The counterexample was our own Malay reminder, which ends in "Terima kasih!" (the final !). - Customer names: some letters change length when upper-cased, so the "same" customer could become two. Fixed by folding case both ways.
- Crash on a lone surrogate: a lone UTF-16 surrogate crashed the encoder. The first test generator never produced one (a false pass); a stricter generator exposed it.
- WhatsApp link: the standard URL encoder leaves
- Hooks:
test-after-task(PostTaskExec: reruns the whole suite and blocks the next task on failure) andrun-eval(manual: reruns the accuracy study). - Custom agent:
accuracy-auditor, allowed to read onlyeval/andlib/, with the steering files as resources. It reports the most-missed fields and any wrong cell that wasn't flagged. - Debugging live: when the first live read failed, Kiro added safe diagnostics, with a property test that the error reason never contains the key or input bytes. The diagnostic showed
upstream_503, then a retired model (404), and Kiro rebuilt the model chain. - Credits: about 40 of the 4,000 (Kiro's per-session estimates).
Challenges
- Free-tier Gemini returned 503 and 429 often, so some study pages failed to read. The tables report how many pages were read.
- The model's confidence isn't calibrated, which led to the bugfix spec.
- I had no real shop notebooks in time, so the study is synthetic.
Limitations (honest)
- The study pages are font-drawn, not real handwriting, so the clean-set numbers are an upper bound.
- No real shop has used it yet.
- On a poor photo every cell needs confirming, which is slow for the owner.
- The photo is sent to a third-party AI service to be read.
- Chinese characters are not reliably read.
- Live reads can be slow or rate-limited on the free tier. Demo mode always works.
What's next
A pilot with one real kedai runcit (with consent) to tune the quality thresholds on real photos; reading offline on the phone; and a shared view so a family member can help keep the books.
Built With
- fast-check
- gemini
- kiro
- next.js
- tailwindcss
- typescript
- vercel
- vitest
- zod