2.3.1 Why Links and Direction Matter
In a flowchart:
If nodes represent structure, links represent behavior.
A poorly structured linking strategy leads to:
Mastering links and direction ensures your diagrams are both logical and readable.
2.3.2 Declaring Direction
Every flowchart begins with a direction declaration:
Direction options:
Example 1 — Top to Down
Example 2 — Left to Right
Direction changes layout — not logic.
2.3.3 Basic Link Syntax
The most common link:
This means:
Node A flows into Node B.
Example:
2.3.4 Different Link Types
Mermaid supports multiple edge types.
1. Standard Arrow
2. Reverse Arrow
3. Undirected Link
Used when relationship is non-directional.
Indicates strong or emphasized flow.
Often used for:
Asynchronous communication
2.3.5 Labeled Links
You can label connections:
Example:
Labeled links are essential for decision modeling.
2.3.6 Multiple Links from One Node
A node can branch into multiple paths:
This represents fan-out architecture.
2.3.7 Merging Links
Multiple nodes can converge into one:
Used for:
2.3.8 Chained Links
You can simplify:
Equivalent to writing each link separately.
Use chaining for linear flows only.
Avoid chaining when branching exists.
2.3.9 Controlling Flow Clarity
Direction affects readability.
Compare:
Vertical Layout
Horizontal Layout
Horizontal layout is often better for system architecture.
Vertical layout works well for:
Choose direction intentionally.
2.3.10 Looping Links
Loops represent repeated execution.
Loop direction impacts readability.
Place decision above process when using TD layout.
2.3.11 Complex Example — Full Workflow
Let’s build a realistic checkout flow.
Observe:
2.3.12 Link Styling (Basic Preview)
You can style links:
linkStyle 0 refers to the first link.
Styling will be covered in detail later, but understanding that links are index-based is important.
2.3.13 Common Mistakes
Mixing directions unintentionally
Overcrowding diagram with crossing links
Failing to label decision branches
Using dotted links inconsistently
Incorrect:
Correct:
2.3.14 Design Guidelines
For professional diagrams:
Choose direction based on diagram purpose
Avoid unnecessary cross-links
Use dotted links for optional flow
Use thick links sparingly
Always label decision branches
Keep linear flows chained for clarity
Think structurally, not visually.
2.3.15 Hands-On Exercise
Build a Microservice Request Flow:
Requirements:
Gateway sends to Service A or Service B
Service B optionally calls External API (dotted link)
All responses return to Gateway
Constraints:
Include at least one dotted link
Include at least one labeled link
Ensure no unnecessary crossing lines
2.3.16 Key Takeaways
Links define how information moves through a system.
Direction defines how that movement is visually structured.
Understanding:
is critical for building readable and scalable flowcharts.
In the next chapter, we move beyond flowcharts and begin exploring Sequence Diagrams, where time and interaction order become central concepts.