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

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
Step 1

Meter files arrive: a duplicate changes nothing, an out-of-order revision is stored but supersedes nothing. Step 2

Billing run in review: three blocked connections must be decided before any bill is issued. Step 3

Late actual reads: the original bill stays untouched and a +$4.02 adjustment joins its document chain.

Engineering invariants
Rules the system enforces whatever the user does, and where each one is proven.
| Invariant | Why it matters | Evidence |
|---|---|---|
| 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
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.