A scalable and extensible expense-sharing platform built using modern C++ and Object-Oriented Design principles.
ExpenseFlow enables users to create groups, add shared expenses, split bills using multiple strategies, track balances, simplify debts, and settle payments efficiently.
The project demonstrates real-world backend system design concepts including Strategy Pattern, Factory Pattern, Observer Pattern, Debt Simplification Algorithms, Validation Layers, and Service-Oriented Architecture.
- Create and manage users
- Track individual balances
- Maintain peer-to-peer settlements
- View personal balance sheets
- Create expense groups
- Add or remove members
- Prevent members from leaving with pending dues
- Maintain group-specific ledgers
- Add shared expenses
- Support multiple participants
- Track expense history
- Maintain group balance sheets
Distributes the expense equally among all participants.
Example:
Expense = βΉ1200
Users = 4
Each User Pays = βΉ300
Allows specifying exact contribution amounts.
Example:
Expense = βΉ1000
User A β βΉ400
User B β βΉ300
User C β βΉ300
Allows specifying percentage-based sharing.
Example:
Expense = βΉ1000
User A β 50%
User B β 30%
User C β 20%
- User-to-user balances
- Group-specific balances
- Outstanding dues tracking
- Settlement support
- Reduces unnecessary transactions
- Uses net balance calculation
- Greedy settlement optimization
- Minimizes payment graph complexity
Example:
A owes B βΉ100
B owes C βΉ100
After Simplification
A owes C βΉ100
- Expense creation notifications
- Settlement notifications
- Group activity updates
- Observer-based event propagation
The system follows SOLID principles and separates responsibilities into independent layers.
ββββββββββββββββββββββββββ
β Main App β
ββββββββββββββ¬ββββββββββββ
β
ββββββββββββββΌββββββββββββ
β Services β
β ExpenseService β
β GroupService β
β BalanceService β
ββββββββββββββ¬ββββββββββββ
β
ββββββββββββββΌββββββββββββ
β Validators β
ββββββββββββββ¬ββββββββββββ
β
ββββββββββββββΌββββββββββββ
β Factories β
ββββββββββββββ¬ββββββββββββ
β
ββββββββββββββΌββββββββββββ
β Strategies β
ββββββββββββββ¬ββββββββββββ
β
ββββββββββββββΌββββββββββββ
β Models β
ββββββββββββββββββββββββββ
ExpenseFlow
β
βββ include
β βββ models
β βββ services
β βββ strategies
β βββ factories
β βββ observer
β βββ algorithms
β βββ exceptions
β βββ enums
β βββ utils
β
βββ src
β βββ models
β βββ services
β βββ strategies
β βββ factories
β βββ observer
β βββ algorithms
β βββ utils
β
βββ tests
βββ docs
βββ main.cpp
Used for implementing multiple expense splitting algorithms.
SplitStrategy
βββ EqualSplitStrategy
βββ ExactSplitStrategy
βββ PercentageSplitStrategy
Benefits:
- Open for extension
- Closed for modification
- Easy addition of new split types
Creates appropriate split strategy at runtime.
SplitFactory::createStrategy(splitType);Benefits:
- Decouples object creation
- Cleaner service layer
- Runtime flexibility
Used for notification broadcasting.
Group
β
βββ User
βββ User
βββ User
Benefits:
- Loose coupling
- Event-driven communication
- Scalable notification system
Used for central application management.
Splitwise::getInstance();Benefits:
- Single source of truth
- Global state management
Responsible for:
- Expense creation
- Validation
- Strategy execution
- Balance updates
Responsible for:
- Balance tracking
- Settlement calculations
- Balance sheet generation
Responsible for:
- Group creation
- Membership management
- Group operations
Responsible for:
- Net balance calculation
- Debt graph optimization
- Transaction minimization
ExpenseFlow includes a dedicated validation layer.
Checks:
- Sum of splits equals total expense
- Participant count matches split values
Checks:
- Percentage total equals 100%
- Invalid distributions are rejected
The project contains dedicated test modules:
tests/
βββ test_balance.cpp
βββ test_group.cpp
βββ test_split.cpp
Tests cover:
- Expense creation
- Split calculations
- Group operations
- Balance updates
- Debt simplification
mkdir build
cd build
cmake ..
make./splitwise- Expense Categories
- Multi-Currency Support
- Persistent Database Storage
- REST API Layer
- Authentication & Authorization
- Monthly Expense Reports
- Email Notifications
- Mobile Integration
- Settlement Recommendations
- Expense Analytics Dashboard
This project demonstrates:
- Object-Oriented Design
- SOLID Principles
- Low-Level Design Concepts
- Design Patterns
- Service-Oriented Architecture
- Data Modeling
- Debt Simplification Algorithms
- Scalable Backend Development
- Modern C++ Development
- Designed and implemented a Splitwise-inspired expense-sharing platform using C++17 and SOLID principles.
- Implemented Strategy, Factory, Observer, and Singleton design patterns to achieve extensibility and maintainability.
- Built a debt simplification engine to minimize transaction count and optimize settlements.
- Developed modular service, model, validation, and algorithm layers following clean architecture practices.
- Created a scalable group expense management system supporting equal, exact, and percentage-based expense splitting.