Designing a Scalable Backend for Credit Card Processing
System DesignModel answerLast updated
Design a scalable backend architecture for a card issuer handling real-time payment processing, fraud detection, ledger management, credit limits, and credit bureau batch exports.
Design the core backend architecture for a digital credit card issuance and processing platform.
Requirements
The system must support the following primary capabilities:
- Authentication & Access: Secure login for cardholders across mobile and web channels.
- Real-Time Payment Processing & Fraud Analysis: Handle incoming authorization requests from payment networks (e.g., Visa/Mastercard) and render an approve/decline decision in under 50–100ms after applying real-time fraud scoring and balance checks.
- Account Dashboard & Spending Insights: Provide customers with near-real-time visibility into current balances, pending holds, posted transactions, and categorized spend history.
- Instant Credit Limit Adjustment: Allow cardholders to request a credit limit increase via the app and receive an immediate automated underwriting decision.
- Credit Bureau Reporting: Generate and publish monthly snapshot files summarizing account statuses and balances to major credit reporting agencies.
Guidance
Begin by establishing core data entities, system boundaries, and overall architectural topology. Detail key write and read flows, then perform targeted deep dives on critical sub-components (such as authorization paths, idempotency, or ledger consistency). State your operational scale assumptions clearly.
Hints
Hint 1
Separate the critical write path (payment authorizations) from heavy read/analytics queries using CQRS or CDC pattern.
Hint 2
Ensure the authorization flow uses strict latency budgets with safe fallback defaults (e.g., stand-in processing / degraded mode) if the ML fraud service times out.
Hint 3
Design the transaction ledger as an immutable double-entry journal to guarantee strict financial accounting standards.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
1. Requirements & System Scope
Functional Requirements
- User Authentication: Secure access token generation for mobile/web apps.
- Real-time Payment Authorization: Evaluate authorization requests within strict SLA (99.9th percentile < 50ms) using real-time credit limit verification and fraud scoring.
- Transaction History & Analytics: Provide real-time pending holds and historical spend summaries grouped by category and merchant.
- Instant Credit Limit Increase (CLI): Evaluate user eligibility dynamically and update available credit instantly if approved.
- Bureau Reporting: Generate batch regulatory reporting files (e.g., Metro 2 format) on monthly billing cycles.
Non-Functional Requirements & Scale Assumptions
- Active Users: 10 million active account holders.
- Peak Authorization Load: 2,000 transactions/sec (TPS) peak; average ~500 TPS.
- Latency Budget: Authorization decisions must respond in
< 50mstotal end-to-end to meet payment network SLAs. - Availability: High availability for Authorization Path ($99.999%$ uptime / "Five Nines"); lower availability tolerable for non-critical app viewing ($99.9%$).
- Consistency: Strong consistency for available credit balance and authorization holds; Eventual consistency for analytical spend views and reporting.
2. High-Level System Architecture
+-----------------------+
| Payment Network |
| (Visa / Mastercard) |
+-----------+-----------+
|
(ISO 8583 / HTTPS)
|
v
+------------------+ +------------+------------+
| Mobile / Web | | Card Network Gateway |
| Clients | +------------+------------+
+--------+---------+ |
| (HTTPS) v
v +------------+------------+
+--------+---------+ | Authorization Engine |<---> [ Redis Cluster ]
| API Gateway | +-----+----------+--------+ (Credit Hold Cache)
+----+---+---------+ | |
| | | v
| | (gRPC / | +----+-----------------+
| | <30ms) | | Real-time Fraud Service|
| | | +----------------------+
| | v
| | +-----+--------------------+
| | | Double-Entry Ledger |
| | | (PostgreSQL / CockroachDB|
| | +------------+-------------+
| | |
| | (CDC / Debezium)
| | |
| v v
| +---------------------+ +------------+-------------+
| | Limit Increase Svc | | Kafka Event Streaming |
| +---------------------+ +------------+-------------+
| |
+-----------------+ |
v v
+--------------+-----+ +-----------+-------------+
| Spend Query Svc | | Bureau Reporting Batch |
| (Read Model DB) | | (S3 / Spark Pipeline) |
+--------------------+ +-------------------------+
3. Core Entities & Data Model
Entities
- Account: Primary container storing
account_id,status(Active, Delinquent, Frozen),credit_limit_cents, andcurrent_balance_cents. - Card: Virtual or physical instrument tied to an account (
card_id,account_id,pan_hash,expiry,cvv_hash,status). - Auth Hold: Transient lock on credit (
auth_id,account_id,amount_cents,merchant_id,expires_at,status). - Ledger Entry: Immutable record of financial movements (
entry_id,account_id,type[DEBIT/CREDIT],amount_cents,timestamp,reference_id).
4. Key Workflows & Subsystems
Workflow A: Payment Authorization & Fraud Scoring (Write Path)
[Network] -> [Gateway] -> [Auth Engine] --(Parallel check)--> [Fraud Service]
|
+--(Balance Check)----------> [Redis Cache / Ledger]
|
[Decision Engine] ---> [Network]
- Ingress: Card network sends an ISO 8583 message translated by the Network Gateway into internal gRPC calls to the Authorization Engine.
- Fast Cache Check: Auth Engine reads the account's Available Credit from a Redis Cluster: $$\text{Available Credit} = \text{Credit Limit} - (\text{Posted Balance} + \text{Active Auth Holds})$$
- Parallel Fraud Scoring: Simultaneously, Auth Engine invokes the Real-time Fraud Service via gRPC with a strict 25ms timeout.
- Fallback Strategy: If the Fraud Service times out or fails, the Auth Engine degrades to rules-based fallback scoring (e.g., velocity check against local cache) to avoid missing payment network SLAs.
- Reserve Hold & Ledger Update: If approved:
- Write an
Auth Holdrecord with TTL to Redis/DB. - Decrement available credit atomically in Redis (
DECRBY). - Emit an
AuthorizationApprovedevent to Apache Kafka.
- Write an
- Egress: Return approval/decline code back to network within ~40ms total.
Workflow B: Spending Overview & Analytical Queries (Read Path)
- Transaction events from Kafka stream into an Event Consumer.
- Writes feed a read-optimized store like Elasticsearch or MongoDB pre-indexed by
account_id, category (MCC code), merchant, and month. - Mobile app queries the Spend Query Service which serves aggregated analytics without impacting the core OLTP database.
Workflow C: Instant Credit Limit Increase (CLI)
- Cardholder submits request via Mobile App.
- Limit Increase Service pulls internal telemetry:
- Payment history (on-time payments in last 6-12 months).
- Credit utilization ratio trends.
- If necessary, synchronously calls external credit bureau API (e.g., Experian/Equifax) for soft pull score.
- Rule/ML Engine makes instant decision:
- Approved: Atomically updates
credit_limit_centsin PostgreSQL, invalidates/refreshes Redis account balance cache, and emitsCreditLimitUpdatedevent. - Declined: Stores adverse action reasons and dispatches notification.
- Approved: Atomically updates
Workflow D: Monthly Credit Bureau Reporting (Batch Path)
- Trigger: Automated batch job runs per billing cycle group.
- Extraction: Apache Spark extracts account snapshot states as of statement closing date from cold/read-replica storage.
- Validation Engine: Runs regulatory verification checks (e.g., ensuring balance matches ledger balances, valid SSN/address syntax).
- File Generation: Formats records into standard Metro 2 format and writes encrypted output files to Amazon S3 for transmission to major credit bureaus.
5. Critical Technical Considerations & Trade-Offs
1. Strong Consistency vs. High Availability in Authorizations
- Trade-off: We choose strong consistency for available balance checks to prevent overspending/double-spending.
- Implementation: Use atomic Lua scripts in Redis for instant authorization evaluation combined with optimistic locking on primary databases.
2. Idempotency & Duplicate Transactions
- Payment networks frequently retry authorization requests during network instability.
- Solution: The Gateway uses a unique payment network key (
retrieval_reference_number+transaction_time+amount) stored in Redis with a 24-hour TTL. Duplicate authorization requests return cached responses immediately without re-running rules or re-deducting limits.
3. Fault Isolation / Stand-In Processing (STIP)
- If internal services fail or latency spikes beyond 50ms, card networks allow the issuer to specify fallback behavior (Stand-In Processing).
- Local rule engine at gateway enforces conservative checks (e.g., allow up to $100 for non-flagged accounts) when backend database connections degrade.