Appearance
Supply Chain Flow
This page traces the complete lifecycle of a product from Brand creation to an end-customer purchase, covering every service interaction, event, and data transformation along the way.
End-to-End Flow
Step-by-Step Breakdown
Phase 1: Catalog Setup
| Step | Service | Action |
|---|---|---|
| 1 | Brand | Brand creates/updates master catalog |
| 2 | Brand | Publishes new catalog version |
| 3 | Kafka | BrandCatalogUpdated event emitted |
| 4 | Supplier | Consumes event, imports catalog with Supplier pricing |
| 5 | Kafka | SupplierProductPublished event emitted |
| 6 | Retailer | Consumes event, adopts products with retail pricing |
Phase 2: Order Placement
| Step | Service | Action |
|---|---|---|
| 7 | Retailer | Customer submits order via storefront |
| 8 | Supply Chain | Creates order record, starts Saga |
| 9 | Payment | Creates Stripe PaymentIntent, authorises funds |
| 10 | Supplier | Redis lock acquired on inventory |
| 11 | Supply Chain | Confirms all steps succeeded |
Phase 3: Payment and Fulfillment
| Step | Service | Action |
|---|---|---|
| 12 | Payment | Captures payment from Stripe |
| 13 | Stripe Connect | Splits payment: Brand / Supplier / Retailer / Platform |
| 14 | Kafka | PaymentCaptured → OrderConfirmed emitted |
| 15 | Supplier | Begins production |
| 16 | Notification | "Order confirmed" email sent to customer |
| 17 | Supplier | Marks order dispatched, emits OrderDispatched |
| 18 | Notification | "Order dispatched" email with tracking sent to customer |
Saga Pattern and Compensation
The Supply Chain Service orchestrates a Saga across multiple services. If any step fails, compensating actions are triggered:
| Failure point | Compensation |
|---|---|
| Payment authorisation fails | Order cancelled, no inventory reserved |
| Inventory unavailable | Payment authorisation voided |
| Payment capture fails | Inventory lock released, order cancelled |
| Supplier rejects order | Payment refunded, order cancelled, customer notified |
Compensation events follow the naming convention {Event}Compensated e.g. OrderPlacementCompensated.
Payment Split
Stripe Connect distributes the order value automatically at capture time:
Customer pays retail price
├── Retailer margin = retail_price − supplier_price
├── Supplier amount = supplier_price − brand_trade_price
├── Brand amount = brand_trade_price
└── Platform fee = (configurable %, deducted from each party's transfer)The exact percentages and amounts are recorded in the Payment Service ledger for each order.
Domain Routing During Order Processing
All service-to-service HTTP calls (where used) go through the internal Docker network by service name. The Nginx reverse proxy is only for external traffic. Service discovery uses Docker DNS: http://supply-chain:9000, http://payment:9000, etc.
Cross-service calls within the Saga use Laravel HTTP client with circuit breakers (via Guzzle retry middleware) and a standard timeout of 10 seconds.