FinyxWatt
An operating platform for electricity and water stations: four apps, one backend
A multi-tenant platform that runs electricity and water stations day to day: customers and meters, readings, bills, receipts, cash boxes, monthly billing periods, reports and SMS, built to keep working when the connection drops.
Visit the live sitefinyxwatt.com

- Connected apps
- 4
- Lines of code
- ~332k
- Automated tests
- ~1,980
- Database migrations
- 109
Screens
Marketing site hero for electricity and water stations
Station app dashboard: collected since the last settlement, invoices, balances, customers, zones and staff online
Customers with their meter, number and balance due, searchable by name or phone
A customer’s account: meter arrears, balance, last reading, consumption and every movement
An invoice: previous and current reading, consumption, rate and what remains, sent by WhatsApp or printed
Reports: invoices by status, collection channels and zone performance
Developer console listing companies with their status, service plan and management actions
SMS provider app connected to the company queue with daily send counts and the sending SIM
finyxwatt.com apps page: the station app and the SMS app on one account, one set of permissions and one set of data
Mobile hero with the create-station call to action
Problem / Solution
The problem
A generating station runs on a chain of dependent steps: read the meter, calculate the bill, notify the customer, collect the payment, record the receipt and report it upward. When each step lives in a separate notebook, spreadsheet or phone, the chain breaks quietly and nobody can tell where.
- Readings were collected on paper and re-entered by hand, which is where most billing disputes started.
- Billing and payments lived apart, so “has this customer paid?” had no single trustworthy answer.
- Customer messages went out manually from personal phones: no delivery record, no retry, frequent duplicates.
- Stations often lose connectivity, so a cloud-only system would stop the counter.
- Owners running several stations had no consolidated view of cash and debt.
The solution
I split the product by who uses it, and put an owned backend behind all of it as the single authority.
- A station app for staff covering readings, billing, receipts, cash boxes, zones and reports, usable offline.
- An SMS provider app that turns an Android phone into a reliable message gateway.
- A developer console for onboarding stations, subscriptions and platform billing.
- A subscriber app where customers see their own bills and payments.
- A NestJS API and PostgreSQL database as the source of truth, with tenant isolation enforced in the database.
- A public website, and a water edition of the same platform.
Architecture
Architecture
Four Flutter clients talk to one API. The server authorises every write; the apps keep a local copy so work continues offline and syncs safely afterwards.
Clients
- Station app
- SMS provider app
- Developer console
- Subscriber app
API
- NestJS 11 on Fastify
- 45 controllers, 248 routes
- Socket.IO realtime
- 4 OpenAPI contracts
Data and identity
- PostgreSQL 18, 96 tables, RLS
- Keycloak 26
- MinIO storage
Operations
- Docker Compose
- Caddy 2.10
- WAL-G point-in-time recovery
- Prometheus, Grafana, Loki, Alertmanager
Engineering
Engineering decisions
The first version ran on Firebase. Moving it to an owned backend without stopping live stations shaped most of the decisions below.
- Server authority
- Clients propose, the server decides. Every financial write is validated and authorised by the API, never trusted from the phone.
- Offline-first sync
- The station app works on a local SQLite copy; idempotency keys and optimistic versions make replaying queued writes safe.
- Append-only money
- Financial history is never updated in place. Corrections are new entries, so every balance can be explained.
- Tenant isolation in the database
- PostgreSQL row-level security keeps each station’s data separate even if application code makes a mistake: 190 policies, FORCE RLS on 61 tables, and SQL tests that check the authorisation rules themselves.
- Gateway phones with real identity
- SMS phones enrol with mutual TLS, using keys that never leave the Android Keystore.
- Exactly one message per bill
- A lock-safe queue, idempotent jobs, failure classification, backoff and a WorkManager fallback.
- From Firebase to an owned backend
- The move from Firestore to PostgreSQL ran through ordered, checksummed migrations (109 to date) and an outbox, with stations live throughout.
- Billing in monthly periods
- Each month is a billing period with its own document numbering. A balance carried forward is posted as an account entry, and closed periods stay browsable, so a customer statement is built from the ledger and agrees with the balances report.
- A repeated transaction is named, not duplicated
- Submitting a transaction number that already exists returns 409 with the receipt that holds it, so a double tap or a replayed queue never becomes a second receipt.
- Invitations that can be used once
- A subscriber invitation is a 256-bit single-use link, valid for up to 7 days and opened through an Android App Link straight into the subscriber app.
- Tests as the safety net
- About 1,980 automated tests run in CI before anything is deployed: 1,296 Flutter (station app 897, developer console 165, SMS app 108, subscriber app 66, field app 55), 451 backend Vitest, and legacy-import, Python and SQL tests.
Structure
Backend modules
The API is split into one NestJS module per domain. These are the main ones.
- financial
- Bills, receipts and the append-only ledger
- cashboxes
- Cash boxes, transfers and shift closing
- sync
- Offline write replay with idempotency and versions
- outbox
- Reliable event publishing after each commit
- realtime
- Socket.IO updates to connected apps
- sms_gateway
- Outbound message queue for provider phones
- sms_enrollment
- Mutual-TLS enrolment of gateway devices
- client_portal
- Subscriber-facing bills, payments, statements and invitations
- platform_billing
- Station subscriptions and invoicing
- audit
- Security and change trail
Tech stack
Mobile
- Flutter
- Dart
- sqflite offline store
- workmanager
- Socket.IO client
- FCM
- pdf and printing
- excel
- Kotlin plugins
Backend
- NestJS 11
- Fastify 5
- Kysely
- Socket.IO 4.8
- zod
- jose
Data and identity
- PostgreSQL 18 + RLS
- Keycloak 26
- MinIO
Web
- Next.js 16
- React 19
- TypeScript
Infrastructure
- Docker Compose
- Caddy 2.10
- WAL-G
- Prometheus 3.5
- Grafana 12
- Loki 3.5
- Alertmanager
- GitHub Actions
Quality
- Flutter tests
- Vitest
- SQL authorization tests
- OpenAPI contracts
Outcome
Where it stands
FinyxWatt runs at client stations, self-hosted, and is public at finyxwatt.com.
- Current versions: station app 1.6.3, SMS app 2.0.15, developer console 1.11.0, subscriber app 1.1.0. The station app is in use at client stations.
- The subscriber app is now shipped: sign-in by phone number, home sections, requests and suggestions, payment reminders, and every account movement pushed to the customer.
- Customer SMS became a system responsibility with a delivery record, instead of a person with a phone.
- Readings, bills and receipts are linked, so a billing question resolves to a traceable chain.
- The same platform now serves water stations as well as electricity, as a water edition built with Android flavours.
- Collection settlements and a subscribers’ balances report are available in the app and on the website.
Written about it
Articles about this project
- One rename to deploy, 9 ms to roll back, 8 traps to dodgeMy deploy kit for a static site on a small VPS: a folder per release, one atomic rename to go live, a 9 ms rollback, a read-only Caddy box, and 8 traps I found by testing it.
- Why idempotency keys didn't stop 105 resends of one receiptOffline-first billing for electricity stations: one id from the phone to the receipt, why bill totals must never be added, an outbox that knows what to retry, and the 500 that looped.
- From Firebase to PostgreSQL while the stations kept billingHow FinyxWatt left Firestore for NestJS and PostgreSQL with stations live: an importer built to say no, 109 checksummed migrations, and releases that go back in one step.
- The final payment should be the easy one. How I run client projectsHow I run client projects so the client pays, trusts me and comes back: a written proposal with phases, every phase live on their server, tests they can read, and a handover pack.
- How to learn programming in year one: a map without the noiseOne language, one kind of product, a real user by month three. What to skip, the four basics every path shares, and where Flutter, Next.js, NestJS and .NET lead.
- Security that survives my own bugs: six layers and their configsSix layers in production, each built for the day the one above it fails: forced row-level security, logins that cannot bypass it, sealed containers, phone certificates, weekly restores.
Need something like this?
Tell me about the operation you want to organise and I will map it into a clear system before writing a line of code.
Let's talk