FlowDiagram
Steps and how they lead to each other, left to right: a request through services, a payment, a deploy. Give nodes and edges; the columns are worked out. Narrow, it turns top to bottom.
import { FlowDiagram, DiagramSkeleton } from '@sypnia/ui/react'
How an order is saved
This diagram in words
- Shop leads to API: HTTPS
- API leads to Database: insert
- API leads to orders.created
- orders.created leads to Mail
- orders.created leads to Kitchen screen: live
Code
import { FlowDiagram } from '@sypnia/ui/react';
// Give nodes and edges: the columns are worked out. Narrow, it turns top to bottom.
export default function Request() {
return (
<FlowDiagram label="How an order is saved" nodes={[
{ id: 'web', label: 'Shop', sub: 'browser' },
{ id: 'api', label: 'API', sub: 'Sypnia Run', tone: 'light' },
{ id: 'db', label: 'Database', sub: 'Postgres' },
{ id: 'queue', label: 'orders.created', machine: true, sub: 'queue' },
{ id: 'mail', label: 'Mail', sub: 'the receipt' },
{ id: 'kitchen', label: 'Kitchen screen' },
]} edges={[
{ from: 'web', to: 'api', label: 'HTTPS' }, { from: 'api', to: 'db', label: 'insert' }, { from: 'api', to: 'queue' },
{ from: 'queue', to: 'mail' }, { from: 'queue', to: 'kitchen', label: 'live' },
]} />
);
} A failure, and the skeleton
This diagram in words
The checkout sends the payment. The card was declined, so the customer is asked for another card.
Code
import { DiagramSkeleton, FlowDiagram } from '@sypnia/ui/react';
// A step that broke is marked, and a path that happens only sometimes is dashed. Below, the skeleton.
export default function Failure() {
return (
<div className="sy-stack">
<FlowDiagram label="A payment that failed" nodes={[
{ id: 'cart', label: 'Checkout' }, { id: 'pay', label: 'Payment', sub: 'card declined', tone: 'fail' }, { id: 'retry', label: 'Ask for another card', tone: 'muted' },
]} edges={[{ from: 'cart', to: 'pay' }, { from: 'pay', to: 'retry', label: 'on decline', dashed: true }]}
words="The checkout sends the payment. The card was declined, so the customer is asked for another card." />
<DiagramSkeleton height={120} />
</div>
);
} When to use it
Use it when
- How data moves between parts of a system.
- A process with a step that failed.
Do not use it when
- Who talks to whom, in time order: use SequenceDiagram.
- Tables and their relations: use EntityDiagram.
For everyone
- It is told in words: every edge as a sentence, or your own
words. - A failed step is marked by its outline and named in the words, not only by colour.
Props
| FlowDiagram | Type | Default |
|---|---|---|
edgesrequired | FlowEdge[] | |
labelrequiredWhat the diagram shows. | string | |
nodesrequired | FlowNode[] | |
wordsYour own words for it; without them the edges are listed. | ReactNode |
| DiagramSkeleton | Type | Default |
|---|---|---|
height | number | 220 |