๐งญ Mermaid Syntax Highlights
๐ Flowcharts
Direction:
- LR: Left to Right
- TB: Top to Bottom
- BT: Bottom to Top
flowchart LR
G[(Goals)] <===> P[(Projects)]
P ---o PD(Deadline)
PD ---- OV([Overdue]) ---> FOV{4 Days}
PD ---x MT([Met])
P ---o PT(Tasks)
PT ---- C([Complete])
PT ---x IC([Incomplete])
C ---> R[[Review]]
R -..-> G
๐ Comments:
- %% โ Comment not rendered in the chart
- |Label| โ Annotates arrows
๐ฏ Example with styling, click links, and labels:
flowchart LR;
classDef blue fill:#2374f7,stroke:#000,color:#fff
G[(Goals)]:::blue <===> |Connects To| P[(Projects)]:::blue
click P "https://github.com/norbix"
๐งฑ Graph Diagrams (UML-style)
graph TD
a(content) --> b([hello])
b --> c[(world)]
b --> d(branch)
d --> e((circle))
d ==> f>flag]
f --- g{diamond}
Use subgraph to group elements:
graph TD
subgraph Graph One
A --> B
end
subgraph Graph Two
C --> D
end
A --> D
๐ฅง Pie Charts
pie
title Content Breakdown
"youtube" : 50
"twitch" : 20
"twitter" : 30
๐งญ Journey Diagrams
Track progress or workflows using narrative sections:
journey
title My Working Day
section Work
Wrote code: 3: me
Reviewed PRs: 4: me
section Twitch
Streamed: 3: me
๐งฉ Class Diagrams
Great for OOP design documentation.
classDiagram
class Order {
+OrderStatus status
}
class OrderStatus {
<<enumeration>>
FAILED
PENDING
PAID
}
class PaymentProcessor {
<<interface>>
-String apiKey
+processPayment(Order order) OrderStatus
}
class Customer {
+String name
}
Order o-- Customer
Car *-- Engine
PaymentProcessor <|-- StripePaymentProcessor
๐ Sequence Diagrams
sequenceDiagram
participant fe as Front-End
participant be as Back-End
participant auth as Auth
fe -->> be: Login
be -->> auth: Validate
auth -->> be: Token
be -->> fe: Success
alt Invalid credentials
be -->> fe: Error
end
โ Why Use Mermaid in Your Codebase?
- ๐ Self-documenting code and architecture
- ๐ฅ Team-wide clarity on workflows and design
- ๐ Easy to update and version control
- ๐งฉ Supports component trees, state machines, database schemas, and more
๐ฆ Resources
- ๐ Official Repo (mermaid-js/mermaid)
- ๐ YouTube Course
- โจ Try live: Mermaid Live Editor