Mermaid code
flowchart TD
A[Order placed] --> B{Payment authorized?}
B -- No --> C[Notify customer<br/>and cancel order]
B -- Yes --> D{Items in stock?}
D -- No --> E[Create backorder]
E --> F[Wait for restock]
F --> D
D -- Yes --> G[Pick and pack]
G --> H[Generate shipping label]
H --> I[Hand off to carrier]
I --> J[Delivered]
J --> K{Return requested?}
K -- Yes --> L[Issue refund]
K -- No --> M[Order complete] Paste this into any tool that renders Mermaid, or into the editor to change the theme and export PNG or SVG. Syntax reference: Flowchart guide.
What this diagram shows
This diagram has two decision points that produce most of the real-world complexity: Payment authorized? and Items in stock?. A failed payment cancels the order outright, while a stock miss sends the order into a backorder loop (Create backorder → Wait for restock) that returns to the stock check instead of ending. After delivery, a final Return requested? branch covers refunds without a separate diagram.
A flowchart beats a sequence diagram here because the actors matter less than the order of checks. Nobody needs to know which service calls which; they need to know what happens when stock is short.
How to adapt it
- Add a
Fraud reviewdiamond between payment and stock check if your store holds high-value orders for manual review. - Split
Pick and packinto warehouse-specific subgraphs when orders can ship from more than one location. - Replace the
Wait for restockloop with aPartial shipmentbranch if you ship in-stock items first. - Switch
flowchart TDtoflowchart LRwhen embedding the diagram in a wide runbook page.
FAQ
Why does the backorder path loop back to the stock check instead of ending?
Because a backorder is a waiting state, not a terminal one. Looping back to Items in stock? makes it explicit that the same check runs again after restock, which matches how most order management systems re-evaluate held orders.
How do I show the refund amount or shipping cost on the edges?
Put the text in the edge label, for example K -- Yes, full refund --> L. Keep edge labels short; anything longer than four or five words belongs in the node itself.