Design a bank account ledger
Design a Bank Account Ledger Service
Context
You are tasked with building the core ledger service for a fintech wallet/banking platform. This service must accurately manage customer account balances, ensuring full auditability and correctness even under high concurrency and system failures.
Functional Requirements
- Support for deposits, withdrawals, and intra-ledger transfers between accounts.
- Ability to query account balances, distinguishing between posted and available balances.
- Provide transaction history with pagination and filtering capabilities.
Non-Functional and Architectural Requirements
- Consistency: Ensure ACID semantics for single-account updates and atomicity for multi-account transfers.
- Auditability: Implement double-entry bookkeeping for comprehensive auditability and reconciliation.
- Reliability: Guarantee idempotency and exactly-once effect for all API requests and asynchronous processing.
- Performance: Design for robust concurrency control to handle high throughput.
- Integrations: Facilitate integration and reconciliation with external payment rails (e.g., ACH, cards).
- Security & Compliance: Incorporate mechanisms for fraud checks, spending limits, and dispute/chargeback handling.
- Scalability: Detail strategies for sharding/partitioning, indexing, read replicas, and caching to support growth.
- Resilience: Define recovery strategies including backups, point-in-time recovery, and invariants validation.
Deliverables
Your design should describe the following:
- Public APIs: Define endpoints, request/response shapes, and how idempotency is utilized.
- Data Model: Present the entities, relationships, and constraints, specifically leveraging a double-entry ledger system.
- Transaction Semantics: Explain how ACID properties for single-account updates and atomic multi-account transfers are ensured.
- Idempotency & Exactly-Once: Detail the design for achieving idempotency and exactly-once processing.
- Concurrency Control: Outline your approach to managing concurrency under high load.
- External Integrations: Describe the reconciliation process with external payment rails, fraud checks, spending limits, and dispute flows.
- Scalability & Recovery: Elaborate on strategies for sharding, indexing, read replicas, and system recovery to ensure both scale and consistency.
AI interview prep
Core dilemma
Balancing absolute financial correctness and auditability (strong consistency, ACID, double-entry) under extreme scale, high concurrency, and potential failures, while also integrating with external, often eventually consistent, systems.
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 bank account ledger
Design a Bank Account Ledger Service
Context
You are tasked with building the core ledger service for a fintech wallet/banking platform. This service must accurately manage customer account balances, ensuring full auditability and correctness even under high concurrency and system failures.
Functional Requirements
- Support for deposits, withdrawals, and intra-ledger transfers between accounts.
- Ability to query account balances, distinguishing between posted and available balances.
- Provide transaction history with pagination and filtering capabilities.
Non-Functional and Architectural Requirements
- Consistency: Ensure ACID semantics for single-account updates and atomicity for multi-account transfers.
- Auditability: Implement double-entry bookkeeping for comprehensive auditability and reconciliation.
- Reliability: Guarantee idempotency and exactly-once effect for all API requests and asynchronous processing.
- Performance: Design for robust concurrency control to handle high throughput.
- Integrations: Facilitate integration and reconciliation with external payment rails (e.g., ACH, cards).
- Security & Compliance: Incorporate mechanisms for fraud checks, spending limits, and dispute/chargeback handling.
- Scalability: Detail strategies for sharding/partitioning, indexing, read replicas, and caching to support growth.
- Resilience: Define recovery strategies including backups, point-in-time recovery, and invariants validation.
Deliverables
Your design should describe the following:
- Public APIs: Define endpoints, request/response shapes, and how idempotency is utilized.
- Data Model: Present the entities, relationships, and constraints, specifically leveraging a double-entry ledger system.
- Transaction Semantics: Explain how ACID properties for single-account updates and atomic multi-account transfers are ensured.
- Idempotency & Exactly-Once: Detail the design for achieving idempotency and exactly-once processing.
- Concurrency Control: Outline your approach to managing concurrency under high load.
- External Integrations: Describe the reconciliation process with external payment rails, fraud checks, spending limits, and dispute flows.
- Scalability & Recovery: Elaborate on strategies for sharding, indexing, read replicas, and system recovery to ensure both scale and consistency.