Learn
Requirement diagram syntax
Learn SysML-style requirements, elements, relationship types, and direction used in the Login requirements template.
On this page8 sections
Syntax cheatsheet
Quick reference for this diagram type
| Concept | Syntax |
|---|---|
| Declare | requirementDiagram |
| Requirement | requirement name { id · text · risk · verifymethod } |
| Types | functionalRequirement · performanceRequirement · … |
| Element | element name { type · docref } |
| Link | A - satisfies -> B · B <- verifies - A |
| Rel types | contains · copies · derives · satisfies · verifies · refines · traces |
| Direction | direction TB · LR · BT · RL |
- 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
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
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
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 -> loginExpand - 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_reqExpand - 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_reqExpand
Check your level
80% or higher certifies this lesson. You'll get 3–5 random questions from a larger bank.