Skip to content

SequenceDiagram

Who talks to whom, in order: the browser, the API, the database and back. Each participant has a line down the page; each message is a numbered arrow.

import { SequenceDiagram, DiagramSkeleton } from '@sypnia/ui/react'

On this page
  1. Signing in with a code
  2. Skeleton
  3. When to use it
  4. For everyone
  5. Props

Signing in with a code

BrowserAPIDatabaseMail1 POST /login2 save a code3 send the code4 202 check your mail5 POST /verify6 read the code7 401 code expired
This diagram in words
  1. Browser to API: POST /login
  2. API to Database: save a code
  3. API to Mail: send the code
  4. API answers Browser: 202 check your mail
  5. Browser to API: POST /verify
  6. API to Database: read the code
  7. API answers Browser: 401 code expired (failed)
Code
import { SequenceDiagram } from '@sypnia/ui/react';

// Who talks to whom, in order. Answers are dashed; what failed is in the failure colour and said in words.
export default function SignIn() {
  return (
    <SequenceDiagram label="Signing in with a code" participants={[
      { id: 'b', label: 'Browser' }, { id: 'api', label: 'API' }, { id: 'db', label: 'Database' }, { id: 'mail', label: 'Mail' },
    ]} messages={[
      { from: 'b', to: 'api', label: 'POST /login' },
      { from: 'api', to: 'db', label: 'save a code' },
      { from: 'api', to: 'mail', label: 'send the code' },
      { from: 'api', to: 'b', label: '202 check your mail', reply: true },
      { from: 'b', to: 'api', label: 'POST /verify' },
      { from: 'api', to: 'db', label: 'read the code' },
      { from: 'api', to: 'b', label: '401 code expired', reply: true, fail: true },
    ]} />
  );
}

Skeleton

Code
import { DiagramSkeleton } from '@sypnia/ui/react';

// A diagram while it loads: its stage at the height it will have.
export default function Skeleton() {
  return <DiagramSkeleton height={260} />;
}

When to use it

Use it when

  • Explaining a sign-in, a payment, a webhook.
  • Showing where a conversation between services failed.

Do not use it when

  • More than five participants: split it in two diagrams.

For everyone

  • It is told in words as a numbered list: who sends what to whom, and which answers failed.

Props

SequenceDiagramTypeDefault
labelrequired string
messagesrequired SequenceMessage[]
participantsrequired

In order, left to right: { id, label }.

{ id: string; label: string; machine?: boolean | undefined; }[]
DiagramSkeletonTypeDefault
height number 220
  1. Signing in with a code
  2. Skeleton
  3. When to use it
  4. For everyone
  5. Props

    Search pages, sections and terms