Catalog Ecommerce.
A full-stack inventory and e-commerce platform with real-time stock tracking, multi-payment processing, granular RBAC, and end-to-end order fulfillment from catalog to invoice.
Architecture & Key Decisions
- Atomic transaction system with stock validation across 20+ API endpoints (sales, purchases, adjustments) — preventing overselling under concurrency.
- Idempotency keys on critical operations — preventing duplicate processing in distributed flows.
- Razorpay webhooks with signature verification — payment confirmation handled asynchronously and never trusted from the client.
- BullMQ/Redis background jobs for image processing, PDF generation, and async stock recomputation.
- Dinero.js for money calculations — no floating-point currency math.
- Service-layer architecture, Zod validation at every API boundary, S3 presigned uploads, and Sentry + Pino structured logging.
The Hard Part
Never oversell, never double-charge
Two customers buying the last unit at the same instant can't both succeed; a webhook that fires twice can't charge twice. The fix is a combination of atomic stock transactions, idempotency keys on critical operations, and webhook signature verification with async confirmation — the exact primitives that fintech backends live and die on.
Key Features
- Real-time stock validation during checkout.
- 7 payment methods (UPI, cards, COD, credit, and more).
- Customer credit ledger with reconciliation — reduced manual accounting by ~80%.
- Granular module-level RBAC (view/create/update/delete per module) for operators.
- Order lifecycle: multi-address support, tax-group calculations, and automated invoice generation.
Trade-offs & What v2 Adds
Why JSON fields for order items?
Cart-data flexibility versus rigid normalized tables.
Why async stock recomputation?
Faster transaction confirmation, with a synchronous fallback if queues are unavailable.
Why idempotency keys despite the overhead?
Duplicate prevention in distributed systems is worth the cost.
What v2 would add
Redis caching for product/category data, WebSockets for order status, Elasticsearch for product search, multi-warehouse inventory, and audit logging.
Want the full walkthrough?
Happy to walk through the concurrency model, idempotency, webhook handling, and the credit ledger.