Design Splitwise
Understanding the Problem
💸 What is Splitwise? Splitwise is an app for sharing costs with friends, roommates or travel companions. Someone pays for dinner, enters the expense and how to split it, and the app keeps a running tally of who owes whom. When it's time to settle up, it tells each person how much to pay and to whom, often with fewer payments than you'd expect, because it can simplify debts across the whole group.
This question is less about scale and more about getting a small, money-like domain right. Interviewers use it to see whether you can model data cleanly, keep derived balances consistent with the expenses they come from, handle rounding and concurrent edits, and explain the debt simplification algorithm. Some ask it as a pure low-level design (classes and methods); we'll treat it as a system design question and cover the algorithm along the way.
Functional Requirements
Core Requirements
- Users should be able to create groups and add friends to them.
- Users should be able to add, edit and delete expenses, paid by one or more people and split equally, by exact amounts, by percentages or by shares.
- Users should be able to see balances: within a group (who owes whom) and overall with each friend.
- Users should be able to settle up by recording a payment, and see a simplified set of payments that clears the group's debts.
Below the line (out of scope)
- Moving real money. We record settlements; a payment integration (Venmo, PayPal, bank transfer) can be linked out to.
- Receipt scanning and itemization.
- Recurring expenses and budgeting charts.
Non-Functional Requirements
Ask about scale, though it won't be the main challenge. A reasonable set: 50 million registered users, 10 million monthly active, about 1 million new expenses per day, and groups that are usually small (a median of a handful of people, a cap of a few hundred).
Core Requirements
- Balances must always be consistent with expenses. If the expenses say Alice is owed $42.17, every screen says $42.17. No drift, no lost cents.
- Reads should be fast: the balances screen should load in under 200 ms.
- The app should work well on mobile with flaky connectivity: adding an expense offline and syncing later must not create duplicates.
- The system should be highly available; losing data (an expense that silently disappears) is the worst outcome.
Below the line (out of scope)
- Real-time collaboration within milliseconds. Seeing a friend's new expense within a few seconds is fine.
Quick math. One million expenses per day is about 12 writes per second on average, maybe 100 per second at peak (Friday nights, holidays). Reads are maybe 20-50x that: people open the app to check balances far more than they add expenses, so a few thousand reads per second at peak. Each expense has a header and one row per participant, say 5 rows on average, so 5 million rows a day, about 2 billion a year, a few hundred gigabytes. A sharded relational database handles this comfortably.
The interesting constraint is the scope of consistency. Every expense belongs to one group (or one pair of friends), and every balance in that group must change together with it. That makes the group the natural unit of transactions and sharding.
This question rewards treating balances as derived data. Expenses are the facts; balances are a summary of them. Design so you can always recompute balances from expenses, then add a materialized copy for speed, kept in sync transactionally.