The traditional monolithic e-commerce platform — Magento, WooCommerce, or SAP Commerce — can no longer keep up with modern retail demands: mobile-first experiences, social commerce, marketplace integrations, personalisation at scale, and sub-second page loads. Headless commerce separates the frontend presentation layer from the backend commerce engine, giving teams freedom on both sides. Here's how Zyllo Tech architects and delivers these platforms.
What does 'headless commerce' actually mean?
Headless means your frontend (React, Next.js, or a mobile app) talks to commerce APIs instead of a coupled CMS+commerce monolith. The backend still handles catalogue management, cart, checkout, order management, pricing, and promotions — but via well-defined APIs that any frontend can consume. What it doesn't mean: rebuilding everything from scratch. You compose best-of-breed services rather than building each one.
The Composable Commerce Stack
- Commerce API: Commercetools, Medusa.js (open source), or custom-built for specific requirements.
- CMS: Contentful, Sanity, or Strapi for content-heavy catalogues.
- Search: Algolia or Elasticsearch for product discovery — never database full-text search for catalogues above 10K SKUs.
- Payments: Stripe, Razorpay, or Adyen — abstracted behind a payment provider interface to switch processors without code changes.
- OMS (Order Management): Fabric OMS or custom-built for complex fulfilment logic.
- CDN: Cloudflare or AWS CloudFront for edge caching of product pages and assets.
Phase 1 — How should you model a product catalogue?
The product catalogue is the heart of any commerce platform. Poor data modelling here causes cascading problems across search, cart, and checkout. We design catalogue schemas to handle:
- Variant hierarchies: product → variant (size/colour) → SKU — with attributes that differ per variant.
- Category taxonomies: multi-level trees with efficient path queries.
- Pricing rules: base price, tier pricing, customer group pricing, promotional pricing with validity windows.
- Multi-warehouse inventory: real-time stock levels per location, reservation system to prevent overselling.
- Bundle and kit products: assemblies of multiple SKUs with their own pricing and inventory.
{
"id": "prod_trail_runner",
"title": "Trail Runner GTX",
"attributes": { "brand": "Acme", "material": "Gore-Tex" }, // same for every variant
"variants": [
{
"sku": "TR-GTX-BLK-42",
"options": { "colour": "black", "size": "42" }, // what actually varies
"price": { "amount": 899000, "currency": "INR" }, // minor units, integer
"inventory": [
{ "location": "whs_hyd", "onHand": 12, "reserved": 3 },
{ "location": "str_bng", "onHand": 2, "reserved": 0 }
]
}
]
}
// Two modelling decisions that are expensive to reverse later:
// - Prices as integer minor units, never floats. Float arithmetic is
// how a cart total arrives at 8989.999999.
// - Sellable stock is onHand minus reserved, computed at read time.
// Any path that sells against onHand oversells the moment two
// shoppers overlap.Phase 2 — How do you keep inventory accurate in real time?
Inventory accuracy is where most retail platforms fail. Showing in-stock items that are actually sold out costs customer trust and creates support overhead. We build inventory sync as an event-driven system:
- ERP / WMS integration via webhooks or polling adapters that publish inventory events to Kafka.
- Inventory reservation during add-to-cart with TTL expiry (15–30 minutes) to prevent overselling.
- Read-heavy inventory served from Redis cache with invalidation on reservation/purchase events.
- Separate write path (reservations, adjustments) from read path (availability display) for scalability.
Phase 3 — How do you make product pages fast?
Product listing pages (PLP) and product detail pages (PDP) are the primary performance battleground. Every 100ms of additional load time costs ~1% in conversion. Our frontend architecture for retail:
- Next.js with ISR (Incremental Static Regeneration) for PLPs — pre-rendered at the edge, refreshed in the background on inventory changes.
- Algolia InstantSearch for client-side filtering — faceted search results in <100ms.
- Image optimization: Cloudflare Images or imgix for automatic WebP/AVIF conversion and responsive sizing.
- Core Web Vitals targets: LCP < 2.5s, FID < 100ms, CLS < 0.1. We track these in CI and block deploys that regress metrics.
- Preloading: next/link prefetching on hover for instant PDP loads.
Phase 4 — How do you engineer a store for flash sales?
Flash sales are the most demanding load scenario in retail. 10x normal traffic in 30 seconds, with everyone trying to add the same 500 units to cart. Standard cart APIs cannot handle this without engineering specifically for it:
- Virtual queue (Cloudflare Waiting Room or custom queue service) to cap concurrent checkout sessions during flash events.
- Redis atomic DECR for inventory counters — prevents race conditions that cause overselling.
- Cart abandonment within seconds of sale start: extend reservation TTL for items in active checkout.
- Separate flash sale pricing service with caching, so a pricing query during a flash sale doesn't hit the database on every request.
- Auto-scaling with AWS Application Auto Scaling triggered 5 minutes before the scheduled flash sale start.
- Add-to-cart takes a time-boxed reservation (reserved += 1) instead of decrementing stock, so an abandoned cart returns its inventory automatically when the reservation expires.
- The reservation is taken as a single conditional write — an atomic decrement guarded by 'only if sellable > 0'. Reading availability and then writing in a second statement is the classic oversell race, and it only shows up under exactly the load a flash sale creates.
- Payment authorisation converts the reservation into an allocation against a specific location. A declined card releases it immediately rather than leaving it to time out.
- A sweeper releases expired reservations continuously. Without one, a traffic spike quietly locks stock that nobody is buying — the sale shows sold out while units sit unsold.
- Availability reads come from the cache and are allowed to be slightly stale; only the reservation write has to be strictly correct. Conflating the two is what makes teams put the whole flash sale on the primary database.
Phase 5 — How do you build a product recommendation engine?
- Collaborative filtering for 'Customers also bought' — runs nightly on purchase data, served from a feature store.
- Real-time signals (current session views, cart contents) combined with historical purchase patterns for homepage recommendations.
- A/B testing framework to measure recommendation click-through and conversion uplift before full rollout.
- Segment-based pricing and promotions for loyalty members, wholesalers, and VIP customers.
- Conversion Rate Uplift: +18%
- Page Load (LCP): < 1.8s
- Stockout Rate Reduction: −45%
- Flash Sale Capacity: 50K concurrent
A headless commerce platform migration is a 4–9 month engagement depending on catalogue size and existing integrations. Zyllo Tech recommends a phased approach: launch the new frontend against the existing backend first, then migrate backend services incrementally while the frontend is already live.
