
Wi-Fi package control system
Meters Wi-Fi data on each subscriber's phone and bills by the GB. In use on my own network.
Details
The phone counts, the server asks. Each device reads Android's per-app network records and keeps its own ledger. The server pulls a reading when the admin presses refresh, and every 30 minutes as a safety net, so a free server tier is never the bottleneck.
- User app
- Android, Kotlin. Counts usage per network, shows remaining quota, takes top-ups with a receipt, renews packages.
- Guard app
- Android, Kotlin. My daily admin tool: subscribers, quota, top-up requests, payments, renewals, per-network packages, alerts, and routers.
- Desktop client
- Windows, Go. Serves its own local page with one person's usage and settings.
- Server
- Cloudflare Worker (JavaScript), D1, 30-minute cron, 18 SQL migrations, plus a browser admin page as a fallback.
Rules the ledger enforces
- Usage is counted per network, one package per network.
- A renewal starts counting at the exact minute it happens.
- What is left of the old package carries into the new one.
- If a package runs out, the figure goes negative and the debt is taken from the next renewal.


What it does not claim
Android keeps usage in roughly one-hour buckets, so figures are accurate to about an hour at the edges. A phone's owner can stop the app or revoke permissions. The numbers are the phone's estimate, not a router-side measurement.
Over 450 unit tests across the two apps cover the counter, renewals, debt, offline behaviour and permissions.
