Skip to content

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'

On this page
  1. How an order is saved
  2. A failure, and the skeleton
  3. When to use it
  4. For everyone
  5. Props

How an order is saved

HTTPSinsertliveShopbrowserAPISypnia RunDatabasePostgresorders.createdqueueMailthe receiptKitchen screen
This diagram in words
  1. Shop leads to API: HTTPS
  2. API leads to Database: insert
  3. API leads to orders.created
  4. orders.created leads to Mail
  5. 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

on declineCheckoutPaymentcard declinedAsk for another card
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

FlowDiagramTypeDefault
edgesrequired FlowEdge[]
labelrequired

What the diagram shows.

string
nodesrequired FlowNode[]
words

Your own words for it; without them the edges are listed.

ReactNode
DiagramSkeletonTypeDefault
height number 220
  1. How an order is saved
  2. A failure, and the skeleton
  3. When to use it
  4. For everyone
  5. Props

    Search pages, sections and terms