Design Splitwise
Problem Statement
Design the Low-Level Design (LLD) for an expense-sharing application like Splitwise, where a group of friends can add expenses, split them among participants, and track who owes whom.
The goal is to model classes, relationships, and operations that enable efficient expense tracking and balance settlement — focusing on object-oriented design and clean extensibility, not
distributed systems or APIs.
🧠 Functional Requirements
User Management
Expense Creation
Expense Splitting
Balance Tracking
Simplify Debts
Show Balances
🚫 Non-Functional Requirements
🧱 Suggested Classes
ClassResponsibility
User
Represents an individual user with personal details.
Expense
Abstract base class representing a generic expense.
EqualExpense, ExactExpense, PercentageExpense
Concrete subclasses for different split types.
Split
Represents how much a particular user owes in an expense.
BalanceSheet
Maintains net balances for each user relative to others.
ExpenseManager
Central class responsible for adding expenses and updating balances.
Transaction (Optional)
Represents a settlement between two users.
🔄 Example Flow
1
2A = new User("A", "a@email.com", "9999")
3B = new User("B", "b@email.com", "8888")
4C = new User("C", "c@email.com", "7777")1
2ExpenseManager.addExpense(
3 payer = A,
4 amount = 1200,
5 participants = [A, B, C],
6 type = EQUAL
7)1
2B owes A ₹400
3C owes A ₹4001
2ExpenseManager.addExpense(
3 payer = B,
4 amount = 600,
5 participants = [A, B, C],
6 type = EQUAL
7)1
2A owes B ₹200
3C owes A ₹200🧪 Example Input / Output
Input:
1
2Users = [A, B, C]
3Expense1: A pays 1200 (equal)
4Expense2: B pays 600 (equal)Output:
1
2A owes B ₹200
3C owes A ₹200⚙️ Constraints
🎯 Goals
Your design should:
✅ In short:
Design the classes and interactions for a Splitwise-like expense sharing system that supports multiple users, different split types, and real-time balance management.