Build story · Personal project

WattSplit

An electricity-bill splitter for a meter shared by a family. Small, plain, and a good lesson in what happens when a delete has to recalculate a chain.

Type
Web app
Built
2026
Stack
One HTML page, Node, Postgres

What it is

A shared meter, a bill every month, and a family that has to split it fairly. WattSplit is the small app I built so nobody has to do that on a calculator.

You enter the new meter readings and it works out each household's share. The shares depend on the bills before them, because each month carries forward from the last, so the app keeps the bills as a chain rather than as separate rows.

How it is built

It started as a single HTML page on Vercel with Supabase behind it. In May 2026 I moved it to a small server of my own with Postgres, so it now runs full time instead of as serverless functions. The page is still one file, because that is all it needs.

The bug worth writing down

I made a test bill, deleted it, and the history suddenly showed duplicates of older months at the top.

Because bills depend on the ones before them, deleting one means recalculating everything after it. My delete code did that by saving every remaining bill again. The server only knew how to append, so each re-saved bill became a copy. The loop got through seven bills before something stopped it, which left seven duplicates.

What I changed

  • Saving a bill now replaces the one with the same id instead of adding another, and edits get their own endpoint.
  • Delete only re-saves the bills that come after the one removed, and does it as an update that is safe to repeat.
  • A one-time cleanup took the history from 34 bills down to 27, with no duplicate ids left. I took a backup first.
  • A new Edit button loads a bill back into the form and recalculates every later bill in the chain.
  • Two small test scripts cover the server and the edit and delete flow.

What I would do next

The family reads it on phones, so mobile polish is next. A share button that sends the monthly summary and a proper domain name are also on the list.

Related

  • DashAnother small tool I built for my own daily life: a car launcher.
  • All my workCase studies and open-source builds.
  • The blogMore build notes.