Navigation

Energy retail

EnergyDesk

Smart-meter data, tariffs, a monthly billing run and rebilling, where every issued bill can be recalculated to the cent from the data it saw.

In the demo you run a fictional NZ retailer's September billing day: meter files arrive duplicated, out of order or implausible, you resolve three blocking exceptions and issue the month's bills for 2,000 connections. When late actual reads arrive, you review and issue a +$4.02 adjustment. Underneath: readings that are never overwritten, a data watermark on every bill, and corrections that never edit the original.

My role
Sole engineer: spec to deployment
Walkthrough
90-second guided scenario
Focus
Reproducible bills from versioned data

Launch guided demo (opens in a new tab)Engineering evidence

Stack: React · TypeScript · PHP/Symfony · PostgreSQL · Playwright + axe

Independently built portfolio showcase · simulated data

EnergyDesk September 2026 billing run with all three exceptions resolved: 2,002 bills ready to issue totalling $413,612.58 including GST, 4 of 4 coverage checks passing, the pinned input snapshot and an "Issue September (2002 bills)" button.

The business problem

An electricity retailer bills two thousand customers from half-hourly meter data that arrives late, twice, out of order or implausible. Prices change mid-month, clocks go forward, customers move, and a meter goes silent for three days — its bill goes out on estimates, then the actual readings arrive.

Try the workflow

  1. Step 1

    EnergyDesk meter data after the 06:00 September files arrive: four files listed with Duplicate, Applied, Partially applied and Out of order statuses, and the guide strip asking to estimate the gaps.
    Meter files arrive: a duplicate changes nothing, an out-of-order revision is stored but supersedes nothing.
  2. Step 2

    EnergyDesk September 2026 billing run in review: 2,000 connections assessed, 1,998 bills ready to issue, 3 blocked connections listed as exceptions, and the held meter read for ED-00932 open with its evidence and decision options.
    Billing run in review: three blocked connections must be decided before any bill is issued.
  3. Step 3

    EnergyDesk bill B-2609-00417 after the adjustment is issued: original total $185.63, a +$4.02 adjustment and a revised total of $189.65, the bill lines by tariff version, and the document chain from the original bill to adjustment A-2609-00417-1.
    Late actual reads: the original bill stays untouched and a +$4.02 adjustment joins its document chain.
EnergyDesk customer view on a phone: the September bill revised to $189.65, an explanation of the +$4.02 increase from actual meter readings, a note that rates have not changed, and a chart of estimated against actual daily use for 21–23 September.
The customer's view of the revised bill on a phone (390 × 844).

Engineering invariants

Rules the system enforces whatever the user does, and where each one is proven.

InvariantWhy it mattersEvidence
Meter readings are INSERT-only versions. A new file never overwrites, and a delayed older revision is stored but replaces nothing.Every issued bill can be recalculated from exactly the data it saw.INSERT-only observations (opens in a new tab)Integration/EnergyDeskIngestionTest.php :: testObservationsAreInsertOnly
The same pinned data gives the same bill to the cent. An issued bill is never edited; corrections form a chain, and applying a stale preview returns 409.Rebilling is auditable, and a second late file cannot charge the customer twice.Adjustment chain (opens in a new tab)Integration/EnergyDeskRunTest.php :: testTheAdjustmentChainOfAnIssuedBill
Each line is rounded once, half away from zero, and GST is allocated to lines. An adjustment is the difference of rounded lines.Totals reconcile exactly: lines + GST = bill, and original + adjustments = revised total.Rounding (opens in a new tab)Integration/EnergyDeskBillingEngineTest.php :: testRoundingIsHalfAwayFromZeroAndAppliedOncePerLine

System architecture

EnergyDesk system architectureBrowser, then a React and TypeScript single-page app, then a Symfony modular monolith with the Energy module, then PostgreSQL: row-level security isolates every demo session. The backend calls an AI adapter: AI structures a customer enquiry into intent, period and claimed facts with verbatim quotes, and drafts a bill explanation from engine-computed facts with placeholders; a number guard and claims check reject invented figures or causes, a person approves, and nothing is sent.BrowserAnonymous demo session · guided scenarioReact + TypeScriptSingle-page app · Playwright end-to-end + axeJSON · RFC 9457 problem detailsSymfony modular monolithEnergy moduleversioned readings · billing run · adjustment chainstransactions · constraintsPostgreSQLRow-level security isolates every demo sessionAI adapterJSON schema + semanticvalidation · fixture modeby default · no AI numbersDocker + Caddy on a shared 4-vCPU host · synthetic data only
AI structures a customer enquiry into intent, period and claimed facts with verbatim quotes, and drafts a bill explanation from engine-computed facts with placeholders; a number guard and claims check reject invented figures or causes, a person approves, and nothing is sent.

Key decisions

  • Readings are versions with a full precedence order: a metering agent's value beats an estimate, a higher source revision wins, and a same-revision contradiction is held for a person.

    Why: Reproduce every issued bill to the cent despite late, duplicate and corrected data.

    Rejected: Overwriting readings in place.

    ADR 0009 §1

  • Each bill's data watermark is a committed publication revision, allocated under a locked per-session counter.

    Why: Gap-free and in commit order, so bills, previews and corrections can all pin it.

    Rejected: A timestamp or a database sequence.

    ADR 0009 §2

Engineering evidence

  • Benchmark

    10,000 connections × one month

    20.4 M readings (2.6 GB). All 40 chunks of 250 connections aggregated in 5.2 s with a daily roll-up, median 0.12 s per chunk, every interval counted exactly once. Without the roll-up: 161 s.

    Conditions: Isolated throw-away database, not production; laptop Docker VM, 8 vCPU, 7.75 GB RAM, PostgreSQL 19 defaults

  • Tests

    Fixture bill reproducibility

    Bill ED-00417 ($185.63, GST $24.21) recalculates to the cent at its pinned revision; the +$4.02 adjustment touches only the three corrected lines. Plus ingestion, billing-engine and concurrency tests.

  • End-to-end

    Playwright billing day with axe

    The billing day end to end, with axe at six points and a 390×844 customer view. 1/1 passing on production on 26 Nov 2026.

    Conditions: Desktop; phone view at 390×844 in the same test

  • Engineering page

    “How it's engineered” in the live demo (opens in a new tab)

    The full detail: rules, data model, tests and measurements, next to the running product.

I use AI-assisted development for implementation, exploration and review. I remain responsible for architecture, business rules, code quality and deployment. Critical behaviour is verified with deterministic tests, static analysis and reproducible benchmarks.

Trade-offs and limits

  • Fictional retailer (Pūkeko Power, 2,000 connections), synthetic data and invented tariffs
  • Not a certified billing system; no real market rules, payments or regulatory reporting
  • No direct debit, collections, switching or settlement
  • The large benchmark runs only in an isolated stack

My contribution

I built EnergyDesk as an independent engineering showcase: product specification, architecture, frontend, backend, data model, automated tests and deployment.

Want to discuss the engineering behind this?

Launch demo (opens in a new tab)Get in touch

Source-code walkthroughs available on request.