Sequence Diagram

Model time-ordered interactions, lifelines, activation frames, parallel blocks, and conditional branches with compile-time participant validation.

Open in Live Sandbox ↗
Sandbox ↗
1dialect uml;
2​
3uml::sequence_diagram "E-Commerce Checkout Workflow" {
4​
5 schema {
6 lifeline actor @Customer [label: "Customer"];
7 lifeline client @Storefront [label: "Web Storefront"];
8 lifeline service @OrderAPI [label: "Order API Gateway"];
9 lifeline database @InventoryDB [label: "Inventory DB"];
10 lifeline service @PaymentSvc [label: "Payment Gateway"];
11 lifeline service @AuditLogger [label: "Audit Logger"];
12 lifeline service @EmailGateway [label: "Email Gateway"];
13 lifeline service @WarehouseSvc [label: "Warehouse Service"];
14 }
15​
16 flow {
17 phase "Phase 1: Order Placement & Verification";
18​
19 Customer -> Storefront.checkout: "submitCart(cart_id)";
20​
21 Storefront.checkout {
22 note @sessionValNote [on: Storefront, pos: left] "Validates session token before calling API";
23 -> OrderAPI.createOrder: "POST /api/v1/orders" => "201 Created(order_id)";
24 }
25​
26 OrderAPI.createOrder {
27 -> self.validatePayload: "orderData" => isValid;
28​
29 -> InventoryDB.reserveItems: "reserve(cart_id)" => reservationToken;
30​
31 alt "Stock Available" {
32 -> PaymentSvc.charge: "processPayment(amount)" => txn_id;
33​
34 note @mtlsNote [on: PaymentSvc, pos: right] "Secured via mTLS & Idempotency Key";
35​
36 create service WorkerTask [label: "Order Worker"];
37 -> WorkerTask.execute: "runPostOrderTasks(order_id)";
38 } else "Out of Stock" {
39 -> async AuditLogger.logFailure: "Inventory Conflict for cart_id";
40 }
41 }
42​
43 phase "Phase 2: Asynchronous Fulfillment & Cleanup";
44​
45 WorkerTask.execute {
46 par "Customer Receipt" {
47 -> async EmailGateway.sendReceipt: "sendConfirmationEmail(order_id)";
48 } also "Warehouse Dispatch" {
49 -> async WarehouseSvc.printPackingSlip: "enqueueShippingLabel(order_id)";
50 }
51​
52 loop "Retry status sync (3x)" {
53 -> InventoryDB.confirmSync: "confirm(order_id)" => synced;
54 }
55​
56 destroy WorkerTask;
57 }
58​
59 Storefront -> Customer: "renderOrderConfirmationPage()";
60 }
61​
62 layout {
63 lifeline @Customer { offset_x: 0 }
64 lifeline @Storefront { offset_x: 160 }
65 lifeline @OrderAPI { offset_x: 320 }
66 lifeline @InventoryDB { offset_x: 480 }
67 lifeline @PaymentSvc { offset_x: 640 }
68 lifeline @AuditLogger { offset_x: 800 }
69 lifeline @EmailGateway { offset_x: 960 }
70 lifeline @WarehouseSvc { offset_x: 1120 }
71 }
72}
73​
74​
Errors: 0 | sequence-diagram
Read-Only Preview

Core Syntax Reference

ConstructPurpose
lifeline <kind> @IdDeclare actor, client, service, boundary, or database participants
phase "Label";Group interactions into horizontal timeline bands
A -> B.op: "msg" => "reply";Synchronous call with optional inline return message
alt / else / par / loop { ... }Combined interaction fragments with automatic bounds