All projects
LiveBusiness system

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
My role
Product owner and sole engineer: architecture, backend, four Flutter apps, website and infrastructure
Timeline
2026
Platforms
Android, Web, REST API, Cloud
finyxwatt.com
Marketing site hero for electricity and water stations
Station app dashboard: collected since the last settlement, invoices, balances, customers, zones and staff online
Connected apps
4
Lines of code
~332k
Automated tests
~1,980
Database migrations
109

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

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.

FinyxWatt platform API

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 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.

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

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

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.

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