Design a Peer-to-Peer Payment System (Venmo)
MediumReal World SystemsPaymentsSocial FeedConcurrencyBalance ManagementActivity Feed
Problem Statement
Design a P2P payment app like Venmo where users send/request money from friends, add social notes to transactions, and view a social activity feed of public payments.
Requirements
Functional Requirements
- User registration with linked bank account/card
- Add friends and manage friend list
- Send money: specify recipient, amount, note, visibility (PUBLIC/FRIENDS/PRIVATE)
- Request money: send a payment request; recipient can accept or decline
- Wallet balance: add money from bank, withdraw to bank
- Social feed: view friends' public and friends-only transactions with emoji reactions
- Notifications: receive alert when money received, request received, or request paid
- Transaction history: all sent/received payments
- Split payment request: request specific amounts from multiple people simultaneously
Non-Functional Requirements
- Thread-safe balance operations
- Singleton VenmoService
Key Entities
- User: id, name, username, email, balance, friends, transactions
- Payment: id, sender, receiver, amount, note, visibility, status (COMPLETED/PENDING/DECLINED), timestamp
- PaymentRequest: id, requester, requestee, amount, note, status
- FeedItem: paymentId, displayText, visibility, reactions
- VenmoService: Singleton
Constraints
- Balance cannot go negative (insufficient funds → payment rejected)
- Payment requests expire after 30 days if not responded to
- PRIVATE payments invisible in social feed
- Reactions only on PUBLIC and FRIENDS payments
- Thread-safe balance deduction (concurrent payments)
!Constraints
- Balance cannot go negative
- Payment requests expire after 30 days
- PRIVATE payments excluded from all social feeds
- Reactions available on PUBLIC and FRIENDS-visibility payments only
- Thread-safe concurrent payment processing
Output
Run or submit your code to see output here.