Full Order Flow — Sequence Diagram
sequenceDiagram
participant P as Pharmacy
participant UI as Next.js UI
participant AUTH as Identity (Okta)
participant GW as API Gateway
participant BFF as BFF (GraphQL)
participant CAT as Catalog
participant PRC as Pricing
participant INV as Inventory
participant ORD as Order Mgmt
participant CMP as Compliance
participant SAP as SAP ERP
participant FUL as Fulfillment
participant K as Kafka
participant WMS as WMS/TMS
Note over P,WMS: 0. AUTHENTICATION (B2B — First Gate)
P->>UI: Navigate to abc-order.cencora.com
UI->>AUTH: Redirect to Okta login
P->>AUTH: Credentials + MFA
AUTH-->>P: JWT (account: PH-45678, segment: independent, DEA: active, 340B: false, can_order_schedule_II: true)
Note over P,AUTH: All subsequent requests carry this JWT
Note over P,WMS: 1. PRODUCT DISCOVERY (identity-gated)
P->>UI: Search NDC 12345-6789-01
UI->>GW: GraphQL query + JWT
GW->>GW: Validate JWT
GW->>BFF: Routed + JWT claims forwarded
par Parallel fetch
BFF->>CAT: Product details
BFF->>PRC: Customer price
BFF->>INV: ATP (availability)
end
CAT-->>BFF: NDC data + attributes
PRC-->>BFF: Contract price ($42.30)
INV-->>BFF: 850 units available
BFF-->>UI: Combined response
UI-->>P: Product page rendered
Note over P,WMS: 2. CART
P->>UI: Add to cart (qty: 100)
UI->>GW: POST /cart/items
GW->>ORD: Create cart item
ORD->>K: cart.item.added
K->>INV: Soft-reserve 100 units
Note over P,WMS: 3. CHECKOUT — SAGA ORCHESTRATION
P->>UI: Place order
UI->>GW: POST /orders
GW->>ORD: Initiate order saga
rect rgb(238, 237, 254)
Note over ORD,SAP: Saga Steps (orchestrated)
ORD->>CMP: Step 1: Validate compliance
CMP->>CMP: DSCSA serial verification
CMP->>CMP: DEA schedule check
CMP-->>ORD: Compliance PASSED
ORD->>INV: Step 2: Hard-reserve stock
INV-->>ORD: 100 units reserved
ORD->>PRC: Step 3: Final price
PRC-->>ORD: $4,230.00 confirmed
ORD->>SAP: Step 4: Create sales order
SAP-->>ORD: SO# 4500012345
end
ORD->>K: order.confirmed
K->>P: Email: Order confirmed
Note over P,WMS: 4. FULFILLMENT
K->>FUL: Process shipment
FUL->>WMS: Pick/pack instruction
WMS-->>FUL: Shipment SHP-98234
FUL->>K: fulfillment.shipped
K->>P: Email: Tracking # sent
Note over P,WMS: 5. DELIVERY
WMS-->>FUL: Delivered
FUL->>K: fulfillment.delivered
K->>ORD: Mark order complete
Saga Compensation — What Happens When a Step Fails
sequenceDiagram
participant ORD as Order Mgmt (Saga)
participant CMP as Compliance
participant INV as Inventory
participant PRC as Pricing
participant SAP as SAP ERP
Note over ORD,SAP: Happy path until SAP fails...
ORD->>CMP: Step 1: Validate compliance
CMP-->>ORD: PASSED
ORD->>INV: Step 2: Reserve stock
INV-->>ORD: Reserved
ORD->>PRC: Step 3: Final price
PRC-->>ORD: Confirmed
ORD->>SAP: Step 4: Create sales order
SAP-->>ORD: ERROR — SAP timeout
rect rgb(255, 235, 238)
Note over ORD,SAP: COMPENSATION (reverse order)
ORD->>PRC: Undo Step 3: Void price lock
PRC-->>ORD: Done
ORD->>INV: Undo Step 2: Release stock
INV-->>ORD: 100 units released
ORD->>CMP: Undo Step 1: Void compliance
CMP-->>ORD: Audit record voided
end
ORD->>ORD: Order status = FAILED
ORD-->>ORD: Queue for retry (Kafka DLQ)
Note over ORD: Notification sent to pharmacy