Forever

P95 API latency under 85ms with Nginx caching

Full-stack e-commerce with webhook state machines

00 / TECHNOLOGY
Frontend
ReactTailwind CSS v4Axios
Backend
Node.jsExpressJWT (RBAC)REST APIs
Data
MongoDB
Infra
Docker (multi-stage)Nginx (reverse-proxy caching, gzip)
Payments
Stripe Checkout webhooks
01 / FORMULATION

Problem formulation

High-concurrency e-commerce checkouts frequently trigger race conditions when multiple buyers contest the last remaining inventory item. In addition, monolithic container deployments bloat CI/CD transfer footprints, and unoptimized API endpoints suffer high latency tails without reverse-proxy caching and compression.

02 / ARCHITECTURE

Subsystem topology

COMMERCE STATE MACHINE|NGINX CACHING & ATOMIC INVENTORY LOCK
LATENCY P95: < 85ms // DOCKER: -55%
FRONTEND (SPA)React Customer UITailwind Admin PortalMulti-Stage Build-55% IMAGE SIZEHTTP/2NGINX REVERSE-PROXYgzip Dynamic CompressionP95 LATENCY < 85msCACHE HIT< 15ms StaticCACHE MISSProxy to Node APINODE.JS / EXPRESSRESTful Catalog APIsCursor-based PaginationJWT-based RBACCONTAINERIZED ENVMONGODBAtlas ClusterIndexed CatalogsAtomic LocksSTRIPE CHECKOUT WEBHOOK STATE MACHINE (CONCURRENCY & INVENTORY LOCKING)1. CARTItem Selected2. CHECKOUTStripe Session Init3. WEBHOOKpayment_intent.succeeded4. INVENTORY LOCKAtomic Lock Acquired2 BUYERS, 1 ITEM TEST5. CONFIRMEDOrder FinalizedELIMINATES HIGH-CONCURRENCY RACE CONDITIONS: Atomic MongoDB $inc checks stock before payment reconciliation.Oversell Prevention Guarantee: Second buyer webhook receives automatic refund and inventory release signal.
FIG. 01ARCHITECTURAL TOPOLOGY & SUBSYSTEM DATAFLOW

Forever is built on a decoupled MERN stack orchestrated with multi-stage Docker images that reduce container footprint by 55%. An Nginx reverse-proxy provides gzip compression and caching, ensuring P95 API response times remain under 85ms.

To eliminate overselling during flash sales, the Stripe Checkout webhook listener triggers an atomic inventory reservation state machine in MongoDB, locking items at payment authorization and rolling back locks on expiration or failure.

03 / TRADE-OFFS

Architectural decisions

DECISION 01

Multi-stage Docker builds and Nginx reverse-proxy caching

Shrinks production Docker image footprint by 55% and keeps P95 API latency under 85ms with gzip compression.

DECISION 02

Asynchronous Stripe Checkout webhook state machines

Reconciles payment intents with inventory locks, eliminating race conditions during high-concurrency checkout flows.

DECISION 03

JWT role-based access control and cursor pagination

Decouples catalog services with role-based permissions and structured pagination.