Design Splitwise (expense sharing)

Design an expense-sharing app where friends split bills and can see who owes whom.

Why interviewers ask it

It tests clean modelling of money, validation, and a small algorithm (debt simplification), and it catches people who use floats for money.

Functional requirements

Non-functional requirements

From version 1 to the final design

  1. Version 1: equal splits only, stored as pairwise 'A owes B' records.
  2. Version 2: exact and percentage splits, behind a split strategy that validates them.
  3. Version 3: one net balance per user, plus debt simplification.
  4. Version 4: groups, several currencies, history and notifications.

The design, step by step

  1. Add an expense: validate the split (it sums to the total) → each participant now owes the payer their share.
  2. Keep one net balance per user: positive means they're owed money, negative means they owe.
  3. Simplify debts: repeatedly match the biggest debtor with the biggest creditor until everyone is at zero.

Deep dives

Common mistakes

Not true: Settling the debts between n people always needs one payment for every pair of people.
In fact: Only the final balances matter. Matching the person who owes the most with the person owed the most settles n people in at most n − 1 payments.

In the interview

Expenses have a payer and a list of splits, created by a split strategy that checks they add up to the total. Each expense updates a net balance per user, stored in whole pence. To settle a group, I greedily match the largest debtor with the largest creditor, which needs at most n − 1 payments.

Part of Unit 7: Low-level design questions in the free System Design course.