Moss X
Production e-commerce platform serving 100+ users with sub-50ms homepage latency, Redis catalog caching, and idempotent Razorpay webhooks.
- Timeline
- Apr 2025 — Oct 2025
- Stack
- JavaScript · Node.js · Express.js · REST APIs · MongoDB · Redis · React · Zustand · Tailwind CSS · Docker
The problem
Taking an e-commerce store from prototype to 100+ real customers and live Razorpay orders exposed two bottlenecks: 1.5-second catalog queries and webhook retry race conditions.
- Dynamic category filters and recommendation aggregations in MongoDB took ~1.5s under cold/concurrent requests.
- Payment gateway webhooks can arrive before or simultaneously with the client callback, risking duplicate order fulfillment without strict idempotency.
How it works
- 01
Redis write-aside catalog caching
Cached product listing and filter responses in Redis with automatic invalidation on admin inventory mutations, cutting API latency by 90% (from 1.5s to 150ms) and keeping homepage load under 50ms. - 02
Idempotent Razorpay webhook pipeline
Verified HMAC-SHA256 webhook signatures over raw request payloads and enforced unique payment-order idempotency keys across 20+ real customer transactions. - 03
MongoDB aggregation analytics
Built multi-stage aggregation pipelines for admin revenue metrics, inventory alerts, and personalized product recommendations. - 04
Team leadership & Dockerized deployment
Containerized the stack with Docker on Render and led a 3-developer team through PR reviews, schema design, and production releases.
Architecture
Modular monolith with Redis catalog caching and idempotent Razorpay verification.
- 01Sub-50ms storefront
Customers browse products, carts, and checkout flows in the React storefront.
- 02Express modular monolith
Domain modules isolate catalog, cart, auth, payment, and analytics logic.
- 03Redis catalog acceleration
Product listings resolve from Redis in 150ms instead of hitting MongoDB on every request.
- 04MongoDB persistence & pipelines
Orders, users, and aggregation pipelines run against indexed collections.
- 05HMAC-verified Razorpay webhooks
Cryptographic signature verification and idempotency guards prevent duplicate charges.
- 06Real-time admin insights
Aggregation pipelines power revenue breakdowns and inventory management.
Latency & production metrics
- reduction in product listing API latency (1.5s → 150ms)
- 90%
- homepage response latency
- <50 ms
- registered customers on mossx.in
- 100+
- live Razorpay orders with zero duplicate charges
- 20+
- With Redis Cache150 ms
- Uncached MongoDB Query1500 ms
Technical deep dive
Complete system specification, schemas, and implementation notes.
A lightning-fast E-Commerce platform that guarantees zero duplicate charges and sub-50ms catalog load times.
The Problem
Modern retail platforms either bloat your codebase or crash during high-traffic checkout events, leading to duplicate charges, lost carts, and furious customers.
The Outcome
A seamless, production-ready monolithic platform handling guest cart merging, secure multi-gateway payments, and real-time analytics. Shoppers get a frictionless experience, and administrators get full control.
How It Works (The Mechanism)
- Zero Duplicate Charges: Integrated Razorpay and Stripe with custom idempotency logic to guarantee that users are never charged twice, even if their network drops mid-request.
- Instant Product Loading: Intelligent Redis caching for the product catalog and user sessions drastically reduces read pressure on MongoDB.
- Frictionless Shopping: Intelligent cart merging allows users to build a cart anonymously and seamlessly sync it upon login.
- Bulletproof Security: Dual-Token Authentication (JWT + HttpOnly refresh tokens) mitigates CSRF and XSS risks.
System Design Decisions
- MongoDB as the Primary Data Store: E-commerce catalogs often require flexible schemas for diverse product attributes (e.g., bundles vs. standalone products). MongoDB's document model handles this polymorphism natively without complex SQL joins.
- Redis Caching Layer: To handle traffic spikes during sales events, Redis is employed to cache heavily requested endpoints (like featured products and category lists). This dramatically reduces MongoDB read pressure and latency.
- Dual-Token Authentication: Instead of relying purely on session cookies, we use a short-lived JWT Access Token paired with a long-lived, HttpOnly Refresh Token. This mitigates CSRF and XSS risks while providing a smooth UX.
- Guest Cart Merging Strategy: To lower the friction of shopping, users can build their cart anonymously. The state is temporarily held, and upon authentication, the system intelligently merges the guest cart with their persistent cloud cart.
- Multi-Gateway Payment Architecture: Relying on a single payment provider can be a single point of failure. MossX abstracts payment logic to seamlessly toggle or support both Stripe and Razorpay based on regional requirements.
Architecture
Database Design
MossX revolves around a highly relational NoSQL design utilizing Mongoose references.
The Value Stack
- Frontend: React 18, Vite, Zustand, TailwindCSS, Framer Motion
- Backend: Node.js, Express
- Database & Caching: MongoDB, Upstash Redis
- Payments & Storage: Stripe, Razorpay, Cloudinary
- Deployment: Docker
Detailed Features
User Features
- Seamless Shopping Flow: Browse products by category, search with price ranges, and view tailored recommendations.
- Advanced Cart System: Fully featured cart supporting both authenticated users and anonymous guest sessions with intelligent cart merging upon login.
- Secure Authentication: Robust JWT-based authentication with seamless token refreshing.
- Profile & Order Management: Track past orders, apply promotional coupons, and manage account details.
Admin Features
- Comprehensive Dashboard: Real-time sales analytics and key performance indicators.
- Inventory Management: Create, update, and manage products, bundles, and custom collections.
- Promotions Engine: Issue and manage discount coupons and featured products.
E-commerce Features
- Dynamic Bundles & Collections: Curate customized product offerings for specific campaigns.
- Flexible Checkout: Multi-gateway payment integration featuring Stripe and Razorpay.
- Coupons & Discounts: Validation engine for promotional codes.
Security Features
- Stateless JWT Auth: Utilizing short-lived access tokens and secure, HttpOnly refresh tokens.
- Robust Validation: Input sanitization and error handling.
- Payment Security: Cryptographic webhook signature verification for all payment gateways.
Performance Features
- Redis Caching: Ultra-fast data retrieval for product catalogs and high-traffic queries using Upstash Redis.
- Asset Optimization: Cloudinary integration for scalable, optimized image delivery.
- Efficient Bundling: Vite-powered lazy loading and code splitting for lightning-fast frontend load times.
The Proof
- Reduced homepage and product catalog latency to under 50ms.
- Achieved 100% reliable checkouts with zero duplicate charges reported.
- Scaled effortlessly during peak traffic events without the overhead of microservices.