0
0
LLDsystem_design~12 mins

Why Splitwise tests financial logic in LLD - Architecture Impact

Choose your learning style9 modes available
System Overview - Why Splitwise tests financial logic

Splitwise is an app that helps friends share expenses and keep track of who owes what. Testing financial logic ensures that calculations for debts, payments, and balances are accurate and fair. This prevents mistakes that could cause confusion or disputes among users.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
Financial Logic Service <-> Cache
  |
  v
Database
  |
  v
Notification Service
Components
User
client
Person using the app to add expenses and view balances
Load Balancer
load_balancer
Distributes incoming user requests evenly to backend services
API Gateway
api_gateway
Routes requests to appropriate services and handles authentication
Financial Logic Service
service
Calculates debts, payments, and balances between users
Cache
cache
Stores recent financial calculations to speed up responses
Database
database
Stores user data, expenses, and transaction history
Notification Service
service
Sends alerts to users about updates or payments
Request Flow - 11 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayFinancial Logic Service
Financial Logic ServiceCache
CacheFinancial Logic Service
Financial Logic ServiceDatabase
DatabaseFinancial Logic Service
Financial Logic ServiceCache
Financial Logic ServiceAPI Gateway
API GatewayUser
Financial Logic ServiceNotification Service
Failure Scenario
Component Fails:Database
Impact:New expense data cannot be saved; cache may serve stale balances; users cannot see updated balances
Mitigation:Use database replication for failover; serve cached data for reads; queue writes for retry when DB recovers
Architecture Quiz - 3 Questions
Test your understanding
Which component checks if recent financial calculations are already available to speed up responses?
ANotification Service
BCache
CLoad Balancer
DAPI Gateway
Design Principle
This architecture shows the importance of caching and service layering to ensure fast and accurate financial calculations. Testing financial logic is critical because it directly affects user trust and fairness in shared expenses.