Skip to content

Learn

Requirement diagram syntax

Learn SysML-style requirements, elements, relationship types, and direction used in the Login requirements template.

On this page8 sections
  1. Syntax cheatsheet
  2. 1.Start a requirement diagram
  3. 2.Requirement fields
  4. 3.Elements and document refs
  5. 4.Relationship types
  6. 5.Layout direction
  7. 6.Put it together: Login requirements
  8. Check your level

Syntax cheatsheet

Quick reference for this diagram type

ConceptSyntax
DeclarerequirementDiagram
Requirementrequirement name { id · text · risk · verifymethod }
TypesfunctionalRequirement · performanceRequirement · …
Elementelement name { type · docref }
LinkA - satisfies -> B · B <- verifies - A
Rel typescontains · copies · derives · satisfies · verifies · refines · traces
Directiondirection TB · LR · BT · RL
  1. 1

    Start a requirement diagram

    Begin with requirementDiagram. Define requirements and elements first, then connect them with typed relationships.

    Names are identifiers — avoid spaces unless you quote user-facing text fields.

    requirementDiagram
      requirement login {
        id: 1
        text: User must authenticate
        risk: High
        verifymethod: Test
      }
    Expand
  2. 2

    Requirement fields

    Each requirement has id, text, risk (Low / Medium / High), and verifymethod (Analysis, Inspection, Test, Demonstration).

    Use a more specific keyword than requirement when the SysML type matters: functionalRequirement, interfaceRequirement, performanceRequirement, physicalRequirement, or designConstraint.

    requirementDiagram
      functionalRequirement auth {
        id: 1.1
        text: Support OAuth and password login
        risk: Medium
        verifymethod: Test
      }
    Expand
  3. 3

    Elements and document refs

    Elements are lightweight links to other artifacts. Give them a type and an optional docref pointing at docs, code, or tickets.

    Quote values that contain spaces: type: "test suite".

    requirementDiagram
      element auth_service {
        type: service
        docref: docs/auth.md
      }
    Expand
  4. 4

    Relationship types

    Connect nodes with {source} - type -> {dest} or the reverse form {dest} <- type - {source}.

    Valid types: contains, copies, derives, satisfies, verifies, refines, traces. Each appears as an edge label.

    requirementDiagram
      requirement login {
        id: 1
        text: User must authenticate
        risk: High
        verifymethod: Test
      }
      element auth_service {
        type: service
      }
      auth_service - satisfies -> login
    Expand
  5. 5

    Layout direction

    Use direction TB (default), BT, LR, or RL to control how Mermaid lays out the graph.

    LR is useful when requirements fan out beside the elements that satisfy them.

    requirementDiagram
      direction LR
      requirement parent_req {
        id: 1
        text: the test text.
        risk: high
        verifymethod: test
      }
      element sim {
        type: simulation
      }
      sim - satisfies -> parent_req
    Expand
  6. 6

    Put it together: Login requirements

    Combine requirement types, elements, contains / satisfies / verifies links, and direction into the examples template.

    requirementDiagram
      direction LR
      requirement parent_req {
        id: 1
        text: the test text.
        risk: high
        verifymethod: test
      }
      functionalRequirement child_req {
        id: 1.1
        text: the second test text.
        risk: low
        verifymethod: inspection
      }
      element sim {
        type: simulation
      }
      parent_req - contains -> child_req
      sim - satisfies -> child_req
    Expand

Check your level

80% or higher certifies this lesson. You'll get 35 random questions from a larger bank.