Design a Bank Account Ledger Service
Context
You are building the core ledger service for a fintech wallet/banking platform. The service must support customer account balances with full auditability and correctness under concurrency and failures.
Functional Requirements
-
Deposits, withdrawals, and intra-ledger transfers
-
Balance queries (posted vs available)
-
Transaction history with pagination and filters
Non-Functional and Architectural Requirements
-
ACID semantics for single-account updates
-
Atomicity for multi-account transfers
-
Double-entry bookkeeping for auditability and reconciliation
-
Idempotency and exactly-once effect for API requests and async processing
-
Concurrency control under high throughput
-
Integration and reconciliation with external payment rails (e.g., ACH, cards)
-
Fraud checks, spending limits, and dispute/chargeback handling
-
Scalability: sharding/partitioning, indexing strategy, read replicas, caching
-
Recovery strategies: backups, point-in-time recovery, invariants validation
Deliverables
Describe:
-
Public APIs (endpoints, request/response shape, idempotency usage)
-
Data model (entities, relationships, constraints) using a double-entry ledger
-
How to ensure ACID semantics and atomic multi-account transfers
-
Idempotency and exactly-once processing design
-
Concurrency control approach
-
Reconciliation with external rails, fraud checks, limits, and dispute flows
-
Sharding, indexing, read replicas, and recovery strategies for scale and consistency