Skip to main content

Enhanced E-commerce Platform

Keeping stock counts honest under flash-sale traffic with service boundaries, idempotent reservations and a BFF.

  • ReactJS
  • NestJS
  • Fastify
  • PostgreSQL
  • Redis
  • Microservices
  • Real-time
  • E-commerce
higher customer retention on the e-commerce platforms I built at WebandCrafts
~20%
higher customer retention on the e-commerce platforms I built at WebandCrafts

01 — Problem

The problem

Inventory has to match reality while catalog, carts, payments and fulfilment all touch it. A synchronous “reserve stock” call in the checkout path fails under promotional traffic, and naive retries can reserve the same unit twice.

The platform also had to stay responsive on every device and scale for traffic spikes without one slow component taking checkout down with it.

02 — Role

My role

  • Designed the service boundaries and the inventory reservation flow.
  • Built the NestJS/Fastify services and the React storefront’s backend-for-frontend.
  • Owned PostgreSQL schema design and the Redis caching and locking strategy.

03 — Architecture

How it fits together

  1. 01 Client

    • React storefront
    • Admin console
  2. 02 Edge

    • BFF (Fastify)
    • WebSocket stock feed
  3. 03 Services

    • Catalog
    • Cart & checkout
    • Inventory
    • Orders
    • Payments
  4. 04 Data

    • PostgreSQL
    • Redis
    • Event outbox
The browser talks to one BFF. Services publish changes through an outbox, so a database commit and its event can never disagree.

Key decisions

  • Idempotent reservation tokens, so a retried checkout can’t reserve stock twice.
  • Outbox pattern instead of dual writes, so inventory events stay consistent with the database.
  • Short-TTL Redis keys for carts and locks. Inventory itself is never cached without an invalidation path.
  • WebSocket stock updates, with polling and backoff as a fallback on flaky connections.

04 — Results

Results

  • ~20% higher customer retention on the e-commerce platforms I built at WebandCrafts
  • Checkout no longer depends on a synchronous stock call, so inventory slowdowns stay out of the payment path
  • Each service scales on its own during promotions instead of scaling the whole monolith

05 — Retrospective

What I’d do differently

Start as a modular monolith with the same boundaries and split services only where scaling or team ownership demands it. That is cheaper to run early on.

Add distributed tracing from day one. A reservation that crosses several services is hard to debug from logs alone.

Related articleModern E-commerce: Real-Time Inventory and Microservices

Working on something similar?

I’m happy to talk through architecture, trade-offs or a role.

Get in touch