
Engineering case study
ManaDuit: an Expense Tracker with Receipt Scanning
Personal project
Reads merchant, total and date correctly on all 8 real receipt fixtures; about 950 automated tests run before every deploy.
An expense and income tracker that reads receipts for you. Photograph a receipt or drop in a PDF and it finds the merchant, total and date, suggests a category from your own history, and warns about duplicates. Budgets, offline entry, CSV import and a Telegram bot are built in. Live as an installable web app. Formerly called VinExpenses; it was renamed ManaDuit when it was published at manaduit.com.
The problem
ManaDuit was built under the name VinExpenses and took its current name when it was published at manaduit.com. It is the same app.
Most people stop tracking expenses because typing each one in is tedious. The useful version of an expense tracker is one where a receipt photo or an e-wallet PDF becomes a correct entry with almost no typing, and where a wrong guess is never saved silently.
Malaysian receipts make that harder than it sounds: they mix English, Malay and Chinese labels, print several amounts (subtotal, service charge, SST, rounding, cash tendered, change), and sometimes show a foreign-currency price beside the ringgit one.
My contribution
Designed and built solo: the web app, the receipt pipeline, the database and its security rules, the Telegram bot, the tests and the deployment.
How it works
Receipt scanning is the core of the app, and it works in three stages.
1. Getting the text. A PDF with a text layer is read in the browser and never uploaded. A photo or scanned PDF is compressed on the device and sent to a private server function that calls an OCR service, so the OCR key never reaches the browser.
2. Finding the facts. A rule-based parser with no dependencies scores every amount on the receipt by the label beside it ("Total", "Jumlah", "Anda bayar", "总计"), ignores subtotal, tax and discount lines, penalises foreign-currency amounts, and adds confidence when several total labels agree or when subtotal plus tax and fees minus discounts adds up to the candidate. The merchant is scored on legal suffix, capital letters, position near the top and a match with the receipt's web address.
3. Deciding how sure it is. Each result is rated high, medium or low. When the parser is unsure, the app shows the candidate amounts as chips to tap and fills in nothing by itself.
Around that: category suggestions learned from the user's own merchant history with a list of Malaysian brands as a fallback, a duplicate warning (same amount, within a day, matching merchant), budgets with 80% and 100% alerts and a "safe to spend today" figure, recurring items, an offline queue that syncs later, CSV import of the app's export or a bank statement, a monthly report, and a Telegram bot in English, Malay and Chinese that accepts receipt photos and sends charts and a weekly digest.
Engineering decisions
Rules, not a language model. A total on a receipt is a fact that can be checked by arithmetic, so a transparent scoring parser handles the common case for free, instantly and with a reason for every choice. When the rules are unsure, the app asks the user instead of guessing.
Never save a wrong guess. Low confidence produces a choice for the user, not a filled field. For a money app, a wrong number that looks right is worse than asking.
Privacy by design. Text PDFs stay on the device, and the server function does not log or store images or text.
Rebuilt without changing the answers. The first version was plain HTML, CSS and JavaScript with no build step. As the app grew it was rebuilt in React and TypeScript, and the receipt reader, the category rules and the deposit and loan maths were compared with the original code on random inputs, so the numbers stayed the same. The first download is kept under 200 KB, so it still opens fast on a phone.
Security treated as a feature. Every table has row level security, so one user can never read another's data. Each server function checks the calling site, then that a real user is signed in, then a daily quota that refuses when in doubt (30 scans a day by default). The browser runs under a strict content security policy with self-hosted, integrity-checked libraries, and exported CSV files are protected against spreadsheet formula injection.
Evidence and evaluation
The receipt parser is tested against 8 anonymised real receipts. For each one it must return the exact amount, merchant and date, in ringgit, with high confidence, and all 8 pass.
The whole project has about 950 automated tests (136 unit and component, 263 browser, 553 backend and parity), covering the parser, category suggestions, duplicate detection, CSV import and the server-side checks. They run on every push, and a failing test blocks both the site deploy and the server-function deploy.
Limitations and next steps
Eight receipts is a regression suite, not an accuracy benchmark: it proves the parser keeps working on formats it has seen, not how often it is right on new ones. The next step is a larger labelled set with a reported hit rate for amount, merchant and date.
The app works in ringgit only. Recurring items are posted when the app is opened, not by a background job. Editing or deleting a saved entry needs a connection. Free OCR limits a photo to 1 MB after compression. The browser tests run in Chromium against a local stand-in for the database and the outside services, not the live ones.