Business flows¶
Each page describes one business capability: the rules, the endpoints, and a diagram of who calls whom. Paths are gateway paths.
| Flow | Owner service | Page |
|---|---|---|
| Sign-up, sign-in, refresh, MFA, password reset | backend | Accounts and MFA |
| Catalog, product search, facets, reviews, wishlist | backend | Catalog and search |
| Cart, coupons, gift cards, loyalty points | backend | Cart, coupons, gift cards, loyalty |
Checkout, VAT, tenders, amountDue, idempotency |
backend | Checkout, VAT and tenders |
| Stock reservations that expire, the reservation saga | backend + payment-service + notification-service | Stock reservations |
| Card payments, 3-D Secure, settlement, voids, refunds | payment-service + backend | Card payments |
| Queue → pick → pack → ship → deliver, split shipments | warehouse-service + backend | Warehouse fulfilment |
| Simulated carrier, public tracking | warehouse-service | Carrier tracking |
| Returns (RMA), refunds and their split | warehouse-service + backend + payment-service | Returns and refunds |
| Suppliers, purchase orders, reorder suggestions | warehouse-service | Purchasing and suppliers |
| Customer emails | backend (account) + notification-service (commerce) + consumer | Emails |
| Signed HTTP callbacks for order events | notification-service | User webhooks |
| Webhooks and commerce emails from the event feed | notification-service + backend | Notifications |
| Last-mile courier, delivery tracking micro-frontend | delivery-service | Courier deliveries |
| Display currencies | backend + frontend | Currencies |
| Order, payment, shipment, return state machines | all | State machines |
The order journey¶
The happy path of one order across all services: a card that is captured immediately and a parcel handed to the simulated carrier. It is split into three stages.
1. Buy and pay¶
sequenceDiagram
autonumber
actor C as Customer
participant B as Backend
participant P as payment-service
C->>B: Sign in
B-->>C: Tokens
C->>B: Add items, coupon
C->>B: Check out
B-->>C: Order 42 PENDING
C->>P: Pay with card
P->>B: Read order 42
P-->>C: CAPTURED
P->>B: Signed result
Note over B: Order 42 is now PAID
B-->>C: Emails
Endpoints: POST /api/v1/users/signin, POST /api/v1/cart/items,
PUT /api/v1/cart/coupon, POST /api/v1/orders, POST /api/v1/payments;
internally GET /internal/v1/orders/42 and
POST /internal/v1/orders/42/payment. Details: Checkout,
Card payments.
2. Warehouse¶
sequenceDiagram
autonumber
actor O as Operator
participant W as warehouse-service
participant B as Backend
O->>W: Open queue
W->>B: List PAID orders
B-->>W: Order 42
O->>W: Create shipment
W->>B: AWAITING_PICK
O->>W: Pick
W->>B: PICKED
O->>W: Pack
W->>B: PACKED
O->>W: Ship (DHL)
W->>B: SHIPPED
Endpoints: GET /api/v1/warehouse/queue, POST /api/v1/warehouse/shipments,
POST /api/v1/warehouse/shipments/{id}/pick|pack|ship; internally
PUT /internal/v1/orders/42/fulfilment. Details:
Warehouse fulfilment.
3. Delivery¶
sequenceDiagram
autonumber
participant W as warehouse-service
participant B as Backend
actor C as Customer
Note over W: Carrier scans every step:<br/>in transit, out for delivery
W->>B: DELIVERED
B-->>C: Email
C->>W: Track parcel
W-->>C: Scans
Endpoints: GET /api/v1/orders/42/shipment/tracking (or the public
GET /api/v1/tracking/{number}). Details: Carrier tracking.
After delivery the customer may review the product and, within 30 days, request a return. Every status change above also triggers the customer's webhooks.
Domain events¶
The backend publishes a domain event inside the transaction that changes an
order. In the same transaction every event is appended to the event feed
(domain_events), which warehouse-service and payment-service poll; other
listeners run after commit. Emails, loyalty points, user webhooks, card
refunds (payment-service) and shipment cancellations (warehouse-service) all
hang off these events. See Event feed.
| Event | Wire name | Published when |
|---|---|---|
ORDER_CREATED |
order.created |
Checkout creates an order (not on an idempotent replay) |
ORDER_PAID |
order.paid |
Admin status change to PAID, a captured card payment, or tenders covering the whole total |
ORDER_CANCELLED |
order.cancelled |
Any cancellation: customer, admin or warehouse |
ORDER_SHIPPED |
shipment.shipped |
Admin status change to SHIPPED or fulfilment reaching SHIPPED |
ORDER_DELIVERED |
shipment.delivered |
Admin status change to DELIVERED or fulfilment reaching DELIVERED |
REFUND_BOOKED |
refund.booked |
A refund is booked for a return |
PAYMENT_FAILED |
payment.failed |
payment-service reports a failed payment for a PENDING order |
CARD_REFUND_REQUESTED |
card-refund.requested |
A booked refund has a card leg, or a card-paid order is cancelled. Internal: read by payment-service from the feed, never sent to user webhooks |
Every event's data contains orderId, status and totalAmount (except
card-refund.requested, whose data is exactly requestId, orderId,
amount and reason); refunds add amount and requestId, payments add paymentId (and failureCode on
failure). Repeating the current status, replays and rejected changes publish
nothing.