back to the dossier — File 00
File 120 // Flagship Deployment — Live
A BILLING ENGINE
that cannot lie
Most recent build — in production right now, settling real bills every day. The arithmetic you'll meet below is the app's actual engine, running live on this page.
LIVE IN PRODUCTION PWA · v1.3.0 ZERO DEPENDENCIES 20 TESTS PASSING FIREBASE
meal-core · live receipt · same integer engine
▸
Meal Ledger icon
MEAL LEDGERMONTHLY CONTROL CENTER
LIVE
TOTAL MEALS53
MEAL COST৳2,915
ADVANCE PAID৳3,000
REMAINING৳85
SEPTEMBER 202630-day register
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Friday lunch ×2 Tuesday dinner ×2 Sunday dinner ×1.5
LOCKED RULEBOOK
Breakfast · every day0.5 meal
Friday lunch2 meals
Tuesday dinner2 meals
Sunday dinner1.5 meals
FINAL BILL = half-units × ৳27.50 — exact, no floats
↑ the real app — go on, tap "Launch" below
// THE PROBLEM

Hostel meal billing runs on trust and mental math — and it fails the way every unverified system fails: quietly. Special-day exceptions nobody wrote down, arguments at month-end, and tracking apps that store money as floating point — so the bill itself can be wrong by a paisa, and no one would ever know.

// THE APPROACH

I treated a meal bill the way a security engineer treats a hash — something that must be exact and verifiable by construction. Meal Ledger never touches floats: money lives as integer paisa, meals as integer half-units, and every hostel rule is encoded in a locked, tested rulebook. Isolation isn't a UI promise either — each resident's ledger sits under their own UID, enforced server-side by Firestore Security Rules. Even the ৳52 → ৳55 rate change ships with tests that walk every month boundary — and fail the build if a stale rate is ever hardcoded back.

// THE RESULT

A zero-dependency PWA in production: offline-capable, installable, real-time synced, with CSV/JSON exports and a rules-guarded admin workspace. 20 automated tests guard the arithmetic, and the entire app weighs ~250 KB — less than one stock photo. The ledger is now mathematically incapable of being wrong.

TRY THE ENGINE// the exact integer math from core.js, running live
WEEKDAY
MEALS EATEN
the villain of this story was floating-point math. genuinely.
Integer moneyEvery taka stored as paisa integers, every meal as exact half-units. Zero floating-point drift — the bill cannot be off by ৳0.01.
Rules-enforced isolationUID-scoped Firestore paths with allowlisted fields. One resident's data is invisible to another — enforced server-side, not promised in the UI.
Rate-integrity testsThe ৳52 → ৳55 boundary is tested across every month — plus a static-analysis test that fails the build if a hardcoded rate sneaks back.
True PWAVersioned app-shell precache, offline-first, home-screen installable, self-hosted fonts — no frameworks, no dependencies.
Real-time + presenceonSnapshot live sync across devices, heartbeat activity status, and a protected admin monitoring workspace.
Portable by designCSV statements and full JSON backups per month — your data leaves whenever you do. No lock-in, ever.
foysal@kali:~/meal — node --test
▶ core · 15 passing
  ✔ rate schedule preserves ৳52 history → ৳55 from Sep 2026
  ✔ every supported month follows the exact rate boundary
  ✔ calendar handles normal and leap years
  ✔ breakfast is always one half-unit (0.5 meal)
  ✔ Friday lunch ×2 · Tuesday dinner ×2 · Sunday dinner ×1.5
▶ rate-integrity · 5 passing
  ✔ core rate constants are internally exact
  ✔ no stale hard-coded ৳52 multiplier in app.js
Tests 20 · Failures 0 · Math exact ✓
File 120 · Build Notes
Engineering decisions
core.js — pure math

Money lives as integer paisa, meals as exact half-units, and the whole engine is a dependency-free module that knows nothing about the DOM. That is why 15 of the 20 tests can be plain unit tests on node --test — the arithmetic is verifiable without a browser in the room.

Rate integrity

The schedule moved from ৳52 to ৳55, and a test walks every supported month boundary to prove which rate applies. A second, static-analysis test reads app.js and fails the build if a stale ৳52 multiplier ever sneaks back in. Rates are history, not constants.

Rules, not promises

Firestore security rules scope every ledger to its own UID with an allowlisted field set, so one resident's data is invisible to another — enforced server-side. The admin workspace is a separate, guarded surface rather than a hidden flag.

~250 KB, zero dependencies

Versioned app-shell precache, offline-first behaviour, home-screen install and self-hosted fonts. No framework, no build step, no analytics — the entire app is smaller than a single stock photograph.

Portable by design

CSV statements and full JSON backups per month, generated on the device. If a resident ever wants to leave, the data leaves with them — no lock-in and no support ticket required.

Ship

Served from GitHub Pages under /meal/; the test suite runs locally before every deploy. Resident data stays inside Firebase, guarded by the published rules.