Design Digital Wallet

Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2025-03-30

Problem Statement

Designing a Digital Wallet system that allows users to store money, make payments, receive funds, and manage transactions in a secure and efficient manner. The system should support both peer-to-peer (P2P) payments and merchant payments, along with features like transaction history, balance management, and security mechanisms.


Functional Requirements (FR)


1.User Account Management
•Users can register/login using email/phone number.
•Link bank accounts, debit/credit cards.
•Manage profile information.
2.Wallet Operations
•Add money from linked bank accounts or cards.
•Withdraw money to linked bank accounts.
•Check wallet balance.
3.Payments & Transfers
•Send money to other users (P2P transfer) using phone number, email, or wallet ID.
•Pay merchants online or in-store using QR codes or wallet ID.
•Receive money from other users.
4.Transaction Management
•Maintain transaction history (debit, credit, refunds).
•Search/filter transactions by date, amount, or type.
•Support transaction status: pending, success, failed, reversed.
5.Security & Fraud Prevention
•Two-factor authentication (2FA) for sensitive operations.
•Encryption of sensitive data (wallet balance, payment info).
•Transaction limits per day/week to prevent fraud.
•Detect suspicious transactions and raise alerts.
6.Notifications
•Notify users on payment received, payment sent, low balance, or failed transactions.
•Support email/SMS/push notifications.
7.Refunds & Disputes
•Users can raise disputes for failed or incorrect transactions.
•Support refunds or reversals.


Non-Functional Requirements (NFR)


•High Availability: Wallet must be available 24/7.
•Low Latency: Transactions should be processed in near real-time.
•Scalability: Must handle millions of users and transactions.
•Consistency: Wallet balances must be accurate after every transaction.
•Auditability: Keep logs for all transactions for compliance and dispute resolution.


Core Entities & Attributes


1.User
•userId, name, email, phone, linkedAccounts, walletBalance
2.Wallet
•walletId, balance, linkedBankAccounts, transactionHistory
3.Transaction
•transactionId, fromUserId, toUserId, amount, type (credit/debit), status, timestamp
4.BankAccount/Card
•accountId, userId, type, balance, linkedWalletId
5.Merchant
•merchantId, name, walletId, merchantCategory


Operations / APIs


1.Wallet APIs
•createWallet(userId)
•getBalance(walletId)
•addMoney(walletId, amount)
•withdrawMoney(walletId, amount)
2.Transaction APIs
•sendMoney(fromWalletId, toWalletId, amount)
•payMerchant(walletId, merchantId, amount)
•getTransactionHistory(walletId, filters)
3.Security APIs
•enable2FA(userId)
•verifyTransaction(transactionId)


Advanced Features (Optional / Bonus)


•Split bills / group payments
•Loyalty points / cashback system
•Support for multiple currencies
•Integration with UPI / payment gateways


Solution

Comments