2.2.1 Why Nodes Matter
In a flowchart, nodes represent states, actions, decisions, or system components.
If edges define flow, nodes define meaning.
Well-designed nodes:
Make architecture self-explanatory
In Mermaid, nodes are defined by combining:
The bracket style determines the shape.
2.2.2 Basic Node Structure
Minimum syntax:
Here:
If you omit the label:
Mermaid automatically creates rectangular nodes named A and B.
However, explicit labels are recommended for production diagrams.
2.2.3 Standard Rectangle Node
Default shape:
Example:
Use this for:
2.2.4 Rounded Rectangle
Syntax:
Example:
Rounded nodes are commonly used for:
2.2.5 Circle Node
Syntax:
Example:
Often used for:
2.2.6 Diamond (Decision Node)
Syntax:
Example:
Decision nodes:
Represent branching logic
Require labeled outgoing edges
Are critical in workflow modeling
2.2.7 Subroutine Node
Syntax:
Example:
Use subroutine nodes to represent:
2.2.8 Advanced Shape Variants
Mermaid also supports extended shapes.
Example:
Asymmetric Shape
Example:
2.2.9 Combining Shapes in a Workflow
Let’s build a realistic example.
Scenario: Order Processing
Observe:
Subroutine → External module
This creates semantic clarity.
2.2.10 Multi-Line Labels
To improve readability, use <br> for line breaks:
Useful for:
2.2.11 Explicit Node ID with Custom Text
You can define ID separately from label:
Best practice:
Example:
Instead of:
This improves maintainability.
2.2.12 Reusing Nodes
Mermaid automatically reuses nodes if IDs match.
Example:
Creates bidirectional reference.
Important:
Reusing IDs unintentionally can break diagrams.
2.2.13 Node Styling (Preview)
Basic styling:
This changes:
Full styling is covered in advanced sections, but understanding node customization starts here.
2.2.14 Refactoring Example (Hands-On)
Start with a basic diagram:
Now improve clarity using shapes:
Notice the improvement in semantic clarity.
2.2.15 Common Beginner Mistakes
Forgetting to label decision branches
Overusing shapes unnecessarily
Using single-letter IDs in large diagrams
Poor practice:
Better:
2.2.16 Design Guidelines
For professional diagrams:
Use diamond strictly for decisions
Use rectangle for processes
Use subroutine for external modules
Avoid excessive shape variation
Maintain naming consistency
Think semantically, not visually.
2.2.17 Practice Exercise
Build a Registration Flow with:
Success and Failure paths
Constraints:
Use at least four different shapes
Ensure clarity without styling
2.2.18 Key Takeaways
Nodes define structure and meaning in flowcharts.
Mastering:
is essential for building maintainable and professional Mermaid diagrams.
In the next topic, we will explore Links and Direction, and how connections influence structural layout and readability.