Hazem Aboelnaga

Hazem Aboelnaga

Full Stack developer in Egypt. I build apps and the servers behind them.

01

Wi-Fi package control system

Metering, packages and billing, in use on my own network.

A system that meters Wi-Fi data on each subscriber's phone and bills by the GB. Every number on every screen is money, so none of them can be "close enough". I built the whole chain: the app on each phone, a second app that is my admin tool and controls the routers, a desktop client, and the server between them.

The decision everything follows

The phone counts, the server asks. Each device reads Android's own per-app network records and keeps its own ledger. The server does not poll continuously. It pulls a reading when the admin presses refresh, and on a 30-minute schedule as a safety net. That keeps a free server tier from being the bottleneck, and it means the figure on the user's screen is the figure the bill is built on.

Parts

User appAndroid, Kotlin. Counts usage per network, shows remaining quota, takes top-ups with a receipt, renews packages, pairs to the admin with a QR code.minSdk 26, target 33
Guard appAndroid, Kotlin. The admin tool I use day to day. Every subscriber with quota, used and remaining, per-device readings and health, top-up requests to approve or reject, payments and voids, renewals, per-network packages, alerts. It also adds and removes devices on two router models.router login stored encrypted on the device
Desktop clientWindows, written in Go, serves its own local page. One person's own usage, settings and disconnect.
ServerCloudflare Worker in JavaScript with a D1 database, a 30-minute cron and 18 SQL migrations. It also serves a browser admin page with users, history by date, payments, top-up requests and alerts, as a fallback to the guard app.

Rules the ledger enforces

  1. Usage is counted per network. A subscriber can hold a package on each network, and the app switches when the phone joins another.
  2. A renewal starts counting at the exact minute it happens. Usage earlier the same day is not charged to the new package.
  3. What is left of the old package carries into the new one.
  4. If a package runs out, the remaining figure goes negative, and the debt is taken from the next renewal.

Screens

Guard app admin overview: totals for users, alerts and consumed GB, shortcuts,
Guard app, admin overview (Arabic interface).
User app account screen: profile, remaining and package quota in GB, renewal date, progress bar, and buttons for top-up, renewal and other networks
User app, account (Arabic interface). Network name blurred.

What it does not claim

Android keeps its usage records in roughly one-hour buckets, so figures are accurate to about an hour at the edges. A phone's owner can always stop the app or revoke its permissions. The numbers are the phone's estimate, not a router-side measurement.

Checks

Over 450 unit tests across the two apps cover the counter, renewals, debt, offline behaviour and the permission flow.

© 2026 Hazem Aboelnaga