Built a fault-tolerant payment system using Stripe, designed for exactly-once execution under high concurrency. Implements idempotent APIs, race-condition-safe processing, and an asynchronous worker system (BullMQ) with retries and DLQ for reliable payment handling.
Validated system under concurrency and real load conditions:
- ~50 concurrent users
- ~5k requests, ~237 req/sec (end-to-end flow)
- ~12k req/sec idempotency fast-path (~3ms rejection latency)
- Zero duplicate transactions
- Cookie-based authentication (JWT)
- Stripe PaymentIntent integration
- Webhook-based payment confirmation (source of truth)
- Idempotent APIs (prevents duplicate execution)
- Race-condition safe processing
- Asynchronous processing via BullMQ workers (Redis)
- Retry mechanism with exponential backoff
- Dead Letter Queue (DLQ) for failed jobs
- Create Order → Generate PaymentIntent
- Client confirms payment
- Stripe sends webhook
- Webhook enqueues job
- Worker processes payment (success/failure)
- Order + Payment updated in DB
- Node.js
- Prisma + PostgreSQL
- Stripe
- BullMQ + Redis

