Design a Banking System
Design the backend for a simplified banking system that supports core financial operations, scheduled payments with cashback, account ranking, and account merging capabilities.
Core Requirements
Accounts & Ledger
- Enable creation of accounts and storage of their balances.
- Maintain a complete, auditable history of all transactions, ensuring no data loss.
Account Ranking
- Support querying a leaderboard of accounts, ranked by their total outgoing transaction volume.
- The ranking should be configurable over specific time windows (e.g., last day, week, or month).
Scheduled Payments with Cashback
- Allow users to schedule payments for future execution.
- Each scheduled payment must have a queryable status.
- Payments may include a cashback component, calculated as a percentage of the outgoing amount, which is credited to the user's account only after the payment successfully executes.
Account Merging
- Implement a mechanism to merge two distinct accounts.
- Upon merging, both original account balances and their complete transaction histories must be retained for audit purposes.
- Define how future transactions behave: new activity should be directed to a "merged" view, while the original accounts become read-only for historical queries.
Non-Functional Requirements
- Correctness and Consistency: Absolutely critical; prevent issues like double-spending.
- Idempotency: Payment execution must be idempotent.
- Concurrency: The system must robustly handle concurrent transfers and scheduled payment executions.
- Scalability: Design for millions of accounts and high transaction throughput.
Deliverables
Candidates should be prepared to present:
- A high-level architecture outlining key services.
- A detailed data model (tables/entities) including critical fields.
- API sketches for core operations: transfers, scheduled payments, status checks, ranking queries, and account merging.
- An approach to consistency and comprehensive failure handling (e.g., retries, idempotency, reconciliation).
- Strategies for efficient and scalable computation of account ranking and cashback.
AI interview prep
Core dilemma
Ensuring strong consistency and atomicity for financial transactions across complex, asynchronous operations (scheduled payments, cashback, merges) while maintaining high availability and scalable analytics.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Design a Banking System
Design the backend for a simplified banking system that supports core financial operations, scheduled payments with cashback, account ranking, and account merging capabilities.
Core Requirements
Accounts & Ledger
- Enable creation of accounts and storage of their balances.
- Maintain a complete, auditable history of all transactions, ensuring no data loss.
Account Ranking
- Support querying a leaderboard of accounts, ranked by their total outgoing transaction volume.
- The ranking should be configurable over specific time windows (e.g., last day, week, or month).
Scheduled Payments with Cashback
- Allow users to schedule payments for future execution.
- Each scheduled payment must have a queryable status.
- Payments may include a cashback component, calculated as a percentage of the outgoing amount, which is credited to the user's account only after the payment successfully executes.
Account Merging
- Implement a mechanism to merge two distinct accounts.
- Upon merging, both original account balances and their complete transaction histories must be retained for audit purposes.
- Define how future transactions behave: new activity should be directed to a "merged" view, while the original accounts become read-only for historical queries.
Non-Functional Requirements
- Correctness and Consistency: Absolutely critical; prevent issues like double-spending.
- Idempotency: Payment execution must be idempotent.
- Concurrency: The system must robustly handle concurrent transfers and scheduled payment executions.
- Scalability: Design for millions of accounts and high transaction throughput.
Deliverables
Candidates should be prepared to present:
- A high-level architecture outlining key services.
- A detailed data model (tables/entities) including critical fields.
- API sketches for core operations: transfers, scheduled payments, status checks, ranking queries, and account merging.
- An approach to consistency and comprehensive failure handling (e.g., retries, idempotency, reconciliation).
- Strategies for efficient and scalable computation of account ranking and cashback.