Skip to content
All projects

feature/roomsplit

RoomSplit

RoomSplit keeps shared expenses for roommates and friends in one place, from food and bills to trips. It works out exact balances, down to the last cent, and suggests the smallest number of payments that settles everyone up.

Role
Sole developer, backend to deployment
Built
31 October – 14 November 2026
Commits
51
Built with
Spring Boot PostgreSQL React Docker
RoomSplit balances screen showing who owes whom and a single suggested payment

How a request travels

  1. React 19 + ViteVercel
  2. Spring Boot 4.1 in DockerRender
  3. PostgreSQL 17Neon

The live demo runs on free plans, so the backend and database go to sleep when nobody is using them. The first request after a pause can take up to a minute.

Stack and why

The backend is Java 21 with Spring Boot 4.1, Spring Security with JWT and PostgreSQL 17. It follows three layers, Controller → Service → Repository: controllers hold no business logic, and the API never returns JPA entities, only DTOs as Java records. Only Flyway changes the schema; Hibernate just validates it (ddl-auto=validate).

Money is NUMERIC in the database and BigDecimal in Java, never double, because double cannot even represent 0.1 exactly.

The frontend is React 19 with Vite and plain CSS, with my own design and no UI library. The backend ships as a multi-stage Docker image that runs as a regular user, not root.

The hardest problems

Splitting money without losing a cent

The split is calculated in cents as whole numbers. The remainder goes to the first people in the list, one cent each, so 100.00 split three ways is 33.34 + 33.33 + 33.33 and the parts always add up to the total. An amount with more than two decimals is rejected with an error instead of being rounded quietly, because then someone would pay a different amount than they entered.

The fewest payments, exactly

A greedy algorithm usually finds the smallest set of payments, but not always: there are cases where it needs four payments and three are enough, and a test covers one. So SettlementPlanner uses dynamic programming over subsets. A test compares it with an independent algorithm on 400 random cases. The cost is exponential time, so it is exact up to 20 members with a non-zero balance and falls back to greedy above that, which is plenty for a flat or a group of friends.

Paging expenses without loading everything

Each expense has its shares. Fetching that list in the same query as a page would make Hibernate load every row and page in memory. The page query fetches only the one-to-one links (who paid, who entered it), and the shares for all expenses on the page come in one extra in :ids query.

RoomSplit new expense dialog: who paid, category, an equal split and each person’s share in KM

When you add an expense, the split updates live as you change who takes part.

What I would do differently today

I would use Testcontainers from day one. The database tests ran against my local PostgreSQL and read variables from .env. Once I ran the command from the wrong folder and the tests started without them. In SlotBook the tests start their own database in Docker and don’t depend on my machine.

I would build login the way I did in SlotBook. RoomSplit has only a JWT that lasts 60 minutes, with no refresh token and no server-side logout. At first I kept the token in localStorage, so logging in in one tab overwrote the token in the others. I only saw it when I tried three users in the same browser. I moved it to sessionStorage, but now every new tab asks you to log in again. I also left rate limiting on login and on join codes for later. Today it would go in from the start.

I would rotate the leftover cent. Right now it always goes to the first people in the list, so over many expenses the same people pay a cent or two more.