Shared expenses for a group of friends

DesignEasy25 min

Your task

Design the backend of an app where groups of friends or roommates record shared expenses and see who owes whom. Anyone in a group can add an expense (who paid, the amount, the currency, and how it is split: equally, by exact amounts, or by percentage), edit or delete it, and record a settle-up payment. Balances must always add up to zero within a group, and two people editing the same expense at the same time must not silently lose a change. The app has 1 million users in 300,000 groups, with about 200,000 new expenses a day. Describe the data model, how balances are computed, and how you handle rounding and concurrent edits.

It covers

  • Integer money
  • Rounding
  • Optimistic concurrency