System Design: Migrating a Monolithic Digital Wallet (Apple Cash–like) to Microservices
Context
You operate a high-scale consumer digital wallet and peer‑to‑peer (P2P) payments app. The current system is a monolith with a single database handling identity/KYC, wallet balances, ledger, payment processing, risk decisions, and notifications. The system must meet strict reliability, security, and regulatory requirements.
Assumptions (adjust as needed):
-
Millions of monthly active users; peak thousands of TPS for wallet reads/writes.
-
Regulated environment; PCI DSS and PII obligations apply; sponsor bank and payment rails integrations (e.g., card/ACH/real-time payments).
-
Double-entry accounting is required; no loss or creation of funds.
-
99.99%+ availability targets for critical money-movement paths.
Task
Design a migration from the monolith to a microservices architecture. Address:
-
Service boundaries and responsibilities (e.g., identity/KYC, wallet, ledger, payments orchestration, risk/fraud, notifications, funding/settlement, limits/compliance, reporting).
-
Data ownership and a safe migration plan from the monolith’s database to service-owned data stores.
-
API design, versioning, and idempotency across retries and network faults.
-
Cross-service transaction patterns (saga vs. two-phase commit) and when to use each.
-
Consistency models and reconciliation (internal ledger and with external partners).
-
Authentication/authorization (user-to-service and service-to-service), key management, and secrets.
-
PCI/PII compliance and data governance (tokenization, encryption, retention, right-to-erasure).
-
Observability (tracing, metrics, logs, audit) and operability (SLOs, alerts, DLQs, replay).
-
Deployment and rollout strategy (strangler fig, canary, blue/green, rollback), including backward/forward compatibility.
-
A phased migration plan with milestones, key risks, and success metrics.