CloudSketch AI Logo
FeaturesTemplatesPricingEnterpriseAboutContactLog in
πŸŒ™β˜€οΈ
Log inStart free
Home/Templates/Retail & E-commerce

πŸ›’ Retail & E-commerce Β· C4 Architecture Β· Pro

E-commerce Microservices Architecture

An online store split into microservices: catalog, cart, orders, payments and search, with Kafka events connecting them to shipping and notifications.

More Retail & E-commerce templates

C4 Architecture diagrams are part of Pro. Anyone can view this one; generating and editing it needs Pro.

Drawing diagram…

What this diagram shows

  • Web and mobile apps share one API gateway
  • Each service owns its own database
  • Order events drive shipping and customer emails

Prompt used

An e-commerce platform with a React web app and a mobile app calling an API gateway. Behind it are catalog, search, cart, order and payment microservices. Catalog uses PostgreSQL, search uses Elasticsearch, cart uses Redis. Orders publish events to Kafka, which the shipping service and the notification service consume. Payments go to an external payment gateway.

Mermaid code
C4Container
title E-commerce Platform
Person(shopper, "Shopper", "Browses and buys")
System_Boundary(shop, "Online Store") {
  Container(web, "Web Store", "React", "Browse, cart, checkout")
  Container(gw, "API Gateway", "Node.js", "Auth and routing")
  Container(catalog, "Catalog Service", "Java", "Products and prices")
  Container(cart, "Cart Service", "Go", "Shopping carts")
  Container(orders, "Order Service", "Java", "Orders and status")
  ContainerDb(cartdb, "Cart Store", "Redis", "Active carts")
  ContainerDb(orderdb, "Order DB", "PostgreSQL", "Orders")
  ContainerQueue(kafka, "Events", "Kafka", "Order events")
  Container(ship, "Shipping Service", "Node.js", "Courier bookings")
}
System_Ext(pay, "Payment Gateway", "Cards and UPI")
Rel(shopper, web, "Uses")
Rel(web, gw, "Calls", "HTTPS")
Rel(gw, catalog, "Routes")
Rel(gw, cart, "Routes")
Rel(gw, orders, "Routes")
Rel(cart, cartdb, "Stores")
Rel(orders, orderdb, "Stores")
Rel(orders, pay, "Charges")
Rel(orders, kafka, "Publishes")
Rel(kafka, ship, "Consumed by")

How an e-commerce microservices architecture fits together

In a microservices design the online store is split into small services that each own one job and its data: the catalogue, search, cart, orders and payments. They talk through an API gateway and through events, so each part can change and scale on its own.

The main parts

  • API gateway: the single entry point for the web and mobile apps; it handles routing, authentication and rate limits.
  • Catalog service with its own database: products, descriptions and prices.
  • Search service: a search engine such as Elasticsearch, kept up to date from catalogue changes.
  • Cart service: fast, short-lived data, often kept in an in-memory store such as Redis.
  • Order and payment services: the order is created, the payment is taken through an external gateway, and the result is recorded.
  • Event streaming with Kafka: when an order is placed, shipping and notifications react to the event instead of being called one by one.

Design choices that matter

  • One database per service: other services read data through APIs or events, never straight from another service's tables.
  • Plan for partial failure: a payment can succeed while the order update fails, so use retries with idempotency keys and compensating steps (the saga pattern).
  • Events must be safe to receive twice; consumers should ignore duplicates.
  • Microservices add operational work. A small team often does better with a well-structured single application first and splits services out as it grows.

Using this template

  • Paste your own docker-compose or OpenAPI file into "Import from code" to draw your real services without using AI credits, or describe them in plain English.

Inside this diagram

A C4 architecture diagram of E-commerce Platform with 1 person, 9 building blocks, 1 outside system and 10 relationships.

People

  • Shopper: Browses and buys

Inside the system

  • Web Store (React): Browse, cart, checkout
  • API Gateway (Node.js): Auth and routing
  • Catalog Service (Java): Products and prices
  • Cart Service (Go): Shopping carts
  • Order Service (Java): Orders and status
  • Shipping Service (Node.js): Courier bookings

Databases and queues

  • Cart Store (Redis): Active carts
  • Order DB (PostgreSQL): Orders
  • Events (Kafka): Order events

Outside systems

  • Payment Gateway: Cards and UPI

Boundaries

  • Online Store

How they connect

  • Shopper β†’ Web Store: Uses
  • Web Store β†’ API Gateway: Calls (HTTPS)
  • API Gateway β†’ Catalog Service: Routes
  • API Gateway β†’ Cart Service: Routes
  • API Gateway β†’ Order Service: Routes
  • Cart Service β†’ Cart Store: Stores
  • Order Service β†’ Order DB: Stores
  • Order Service β†’ Payment Gateway: Charges
  • Order Service β†’ Events: Publishes
  • Events β†’ Shipping Service: Consumed by

Make your own diagram like this

Describe your own system in plain English and the AI C4 diagram generator draws it in seconds, in the same style as this template.

Related templates

SequenceRetail & E-commerce

Checkout and Payment Sequence

What happens when a shopper clicks Pay: stock is reserved, the payment is authorised, the order is created and stock is released again if payment fails.

State MachineRetail & E-commerce

Order Lifecycle State Machine

Every status an online order moves through, from placed to delivered, including cancellations, returns and refunds.

Database ERDRetail & E-commerce

Product Catalog Database Schema

A flexible product catalog: categories, products with variants (size, colour), prices, stock per warehouse and images.

Data FlowRetail & E-commerce

Omnichannel Inventory Sync

How stock stays in sync across stores, warehouses and marketplaces so the same item isn't sold twice.

FlowchartRetail & E-commerce

Returns and Refunds Workflow

How an online store handles a return: eligibility, pickup, quality check at the warehouse and the refund or replacement.

Data FlowRetail & E-commerce

Product Recommendation Engine

How an online store builds 'recommended for you' and 'frequently bought together': click and order data, model training and a fast serving layer.