Why this session exists
Every architecture conversation you've ever had ended the same way: someone draws boxes on a whiteboard, someone photographs it, and the photo dies in a chat thread. Mermaid fixes this. You type a few lines of text, and a crisp diagram renders - in GitHub, in Notion, in your docs, in this very page. Over six sessions we diagram one realistic data platform ("Nova") end to end: architecture, runtime, data model, roadmap, the lot. Today: your first flowchart, rendering in three real places.
Why text beats drag-and-drop 6 min live
Mermaid is a JavaScript library that turns short text descriptions into rendered diagrams. The text IS the diagram - which means diagrams finally behave like code: versioned, diffable, reviewable, and impossible to lose.
LiveWhat mermaid is, and the pain it kills2 min▶
Mermaid is an open-source JavaScript library (70k+ GitHub stars, built into half the tools you already use) that renders diagrams from a markdown-ish text syntax. You describe WHAT connects to what; mermaid decides where boxes go and draws the SVG.
Why this matters to you
- Diagrams stop rotting. A PowerPoint architecture slide is stale the week after it's made. A mermaid block sits next to the code or doc it describes and gets updated in the same pull request.
- Diagrams become reviewable. "You removed the validation step" is visible in a text diff. Nobody can diff a PNG.
- Speed. Typing 6 lines beats aligning 6 boxes. Layout is the machine's job now.
- AI speaks it fluently. Ask Claude or ChatGPT to "diagram this as mermaid" and you get working source you can paste anywhere - text diagrams are the native diagram format of the AI era.
The whiteboard photo problem. A data team designs their new ingestion flow on a whiteboard. Six months later the new joiner finds the photo in Slack: half-erased, glare over the important box, and two pipelines out of date. The team that wrote it as 12 lines of mermaid in the repo README? Their diagram was updated in the PR that changed the pipeline. Same effort, permanent payoff.
LiveAnatomy of a mermaid block2 min▶
Every mermaid diagram has the same skeleton: a diagram type keyword on the first line, then statements describing content. That first word decides the entire grammar that follows.
flowchart LR %% this is a comment - renderers ignore it idea[An idea] --> diagram[A shared picture]
- Line 1: the type.
flowchart,sequenceDiagram,erDiagram,gantt,mindmap... ~15 stable types, each with its own mini-language. This course teaches the daily-driver set. - Direction (flowcharts):
LR= left to right,TD= top down. One flag, whole layout flips. - Comments: lines starting
%%are ignored - leave notes for the next editor. - Indentation is cosmetic - mermaid doesn't care, but your reviewers do. Indent statements two spaces.
Self-studyHow the rendering actually works2 min read▶
Under the hood, mermaid parses your text into a graph structure, hands it to a layout engine (dagre by default; ELK optionally for complex graphs - Session 6) that computes where every node and edge should sit, then emits SVG styled by the active theme. Three consequences worth knowing:
- You trade pixel control for speed. You cannot nudge one box 3px left, and that is the deal: mermaid is for thinking and communicating, not print-perfect posters. When exact layout truly matters, export the SVG and refine elsewhere.
- Layout can change between versions - same source, slightly different arrangement. The MEANING never changes; the placement might. This is why source, not screenshots, is what you commit.
- Themes restyle everything. The pink diagrams on this page are stock mermaid with a custom theme (Session 6 shows you exactly how). One config block, whole-deck restyle.
Self-studyWhen NOT to use mermaid1 min read▶
Fluency includes knowing the tool's edges. Reach for something else when:
- Pixel-perfect brand visuals - a marketing one-pager wants Figma or Illustrator, not auto-layout.
- Huge graphs - 200+ nodes turns into spaghetti in any auto-layout tool. Split into linked smaller diagrams instead (we do this with Nova in Session 2).
- Free-form spatial sketching - if the POSITION of things is the meaning (a floor plan, a customer journey map on a wall), a canvas tool like Excalidraw or tldraw fits better.
Flowchart fundamentals 9 min live
The flowchart is mermaid's workhorse - it draws processes, architectures, decision trees, and org flows. Learn four things and you can already diagram most of your job: nodes, shapes, edges, direction.
LiveNodes and shapes - the vocabulary3 min▶
A node is an ID plus an optional label: ing[Ingestion job]. The brackets around the label pick the shape, and shapes carry meaning - readers decode them before reading a single word.
flowchart LR
a[Process step] --> b(Soft process)
b --> c{Decision?}
c -->|yes| d[(Database)]
c -->|no| e([Start / end])
| You type | You get | Convention |
|---|---|---|
a[text] | rectangle | a process or step |
a(text) | rounded rectangle | a softer step, an activity |
a{text} | diamond | a decision - pair with yes/no edge labels |
a[(text)] | cylinder | a database or store |
a([text]) | stadium/pill | start and end points |
a((text)) | circle | a connector or event |
Node IDs (a, ing, dw) are how you reference nodes later - keep them short and meaningful. The label is what humans read. Mention a node ID again anywhere and mermaid knows it's the same node - no duplicates drawn.
a["Read config (v2)"]. This one habit prevents 80% of beginner syntax errors.
LiveEdges - how things connect3 min▶
Edges are the arrows. Three styles cover nearly everything: solid --> for normal flow, dotted -.-> for optional/async, thick ==> for the critical path. Add a label with pipes: a -->|nightly| b.
flowchart LR src[App events] -->|stream| ing[Ingestion] crm[CRM export] -.->|nightly batch| ing ing ==> dw[(Warehouse)] dw --> dash[Dashboards] dw -.-> ml[ML features]
- Chain in one line:
a --> b --> cworks, anda & b --> cfans two nodes into one. - No arrowhead:
a --- bfor plain association lines. - Longer arrows nudge layout: extra dashes (
---->) ask for extra rank distance - a gentle layout hint, not a command.
LiveDirection - one flag, whole new layout1 min▶
The token after flowchart sets flow direction: TD (top-down), LR (left-right), BT, RL. Rule of thumb: processes read LR like a sentence; hierarchies and decision trees read TD. When a diagram feels cramped, flipping direction is the first thing to try - it's free.
Self-studyReading error messages without fear2 min read▶
Mermaid errors look scarier than they are: "Parse error on line 3... Expecting 'SEMI', 'NEWLINE'..." decodes as "line 3 confused me". The usual suspects, in order:
- Unquoted special characters in a label - parentheses, brackets, colons. Fix: quote the label.
- A typo in the arrow -
->instead of-->(flowchart arrows need two dashes). - Wrong grammar for the diagram type - flowchart syntax in a
sequenceDiagramblock, or vice versa. Check line 1 first. - A reserved word as a node ID - naming a node
endbreaks flowcharts; useEndorfin.
Debugging habit: comment out half the lines with %%, re-render, and bisect until the guilty line is obvious. In mermaid.live the error appears as you type, so you always know WHICH edit broke it.
Where mermaid renders 5 min live
The superpower isn't the syntax - it's that the places you already write render it natively. Learn the fence, and your diagrams follow you everywhere.
LiveThe fence: mermaid in markdown2 min▶
In GitHub (README, issues, PRs, wikis), GitLab, Obsidian, and most docs platforms, you get a rendered diagram by fencing mermaid source as a code block with the mermaid language tag:
- GitHub: works in README files, issues, pull requests, discussions, and wikis. Diagram renders on page view.
- Notion: type
/code, pick Mermaid as the language - Notion shows code and preview side by side or preview only. - Obsidian: same fence, renders in preview mode. Your second brain gets diagrams for free.
- VS Code: install a mermaid preview extension and the fence renders in markdown preview - diagrams in your repo docs, visible while you edit.
Livemermaid.live - your workshop1 min▶
mermaid.live is the official editor: source on the left, live render on the right, errors as you type. It's where you DRAFT; the fence is where diagrams LIVE. The share button encodes your whole diagram into the URL - no account, no save button, the link is the file. Every diagram block on this page has an "Edit on mermaid.live" button for exactly this reason.
Self-studyEverywhere else: slides, sites, AI chats2 min read▶
- Docs generators - MkDocs (Material), Docusaurus, VitePress, Hugo all render mermaid fences with a one-line config. Your architecture docs stay text end to end.
- This page loads mermaid.js from a CDN and renders every block client-side - about 10 lines of JavaScript, shown in full in Session 6.
- AI assistants - Claude and ChatGPT both emit mermaid on request ("diagram this pipeline as a mermaid flowchart"). You review the text, fix labels, paste into the fence. Minutes from description to committed diagram.
- Exports - mermaid.live exports PNG/SVG for slides; the mermaid CLI (
mmdc) batch-exports in CI (Session 6).
A data lead asks Claude to draft the mermaid for her ingestion redesign, pastes it into the design doc PR, and reviewers comment on specific LINES of the diagram like code review. The diagram merges with the design. Nobody opened a drawing tool at any point.
Nova at 30,000 feet ★ 8 min · follow along
Meet Nova: a small, realistic data platform - events and CRM data in, warehouse in the middle, dashboards and ML out. Six sessions from now it will be fully documented in mermaid. First artifact: the high-level flow, built line by line in mermaid.live.
flowchart LR
ev[App events] -->|stream| ing[Ingestion]
crm[CRM export] -.->|nightly| ing
ing --> qa{Quality checks}
qa -->|pass| dw[(Warehouse)]
qa -->|fail| dlq[Quarantine]
dw --> bi[Dashboards]
dw --> ml[ML features]
Open mermaid.live. Type just the first line: flowchart LR. Empty canvas, no errors - good start.
Add the happy path as one chain: ev[App events] --> ing[Ingestion] --> dw[(Warehouse)] --> bi[Dashboards]. Four nodes, one line of text.
Add the decision: insert qa{Quality checks} between ingestion and warehouse, with |pass| and |fail| labeled edges. Watch the diamond appear and the layout reflow itself.
Add the second source: crm[CRM export] -.->|nightly| ing. Dotted, because it's batch - edge style carrying meaning.
Break it on purpose: remove the quotes idea - rename a node to qa{Quality (v2) checks} and watch the parse error. Fix it with quotes. You have now debugged mermaid.
Compare with the finished block above (flip it to Code). Yours should match within cosmetics - copy the share URL, you'll want it in Demo 2.
Ship it: GitHub and Notion ★ 6 min · build your own
A diagram in an editor is a draft. A diagram rendering where your team already reads - that's documentation. Put Nova's map in both places you write most.
In any GitHub repo you own (or a fresh scratch repo), open the README, click edit, and add a ```mermaid fence with your Demo 1 source inside. Commit.
View the README. GitHub renders the diagram natively - no image upload happened. Resize the window; it's crisp at every size, because it's SVG.
Edit the diagram IN the GitHub editor: change "Dashboards" to "BI dashboards", commit again, and check the file diff. The reviewable-diagram superpower, live.
Now Notion: on any page, type /code, set the language to Mermaid, paste the same source. Toggle to preview. One source, second home.
Optional third home: paste the fence into an Obsidian note or a VS Code markdown preview if you use either.
The highest-leverage place for your first real mermaid diagram is the README of the repo people ask you about most. "How does this pipeline work?" becomes a link, and the diagram updates in the same PRs that change the pipeline.
Diagram your own week ★ 5 min · build your own
Syntax sticks when it draws YOUR world. Pick one real flow you own - your reporting pipeline, your release process, your morning routine - and map it with today's vocabulary.
Pick a flow with 5-10 steps and at least one decision point. Real ones work best: "how a data request gets to a dashboard", "how we ship a model", "how expense approval works".
Draft in mermaid.live: start/end pills, rectangles for steps, one diamond with labeled yes/no edges, a cylinder if data gets stored anywhere.
Apply meaning to edge styles: dotted for the async/optional parts, thick for the critical path.
Stuck on syntax? Ask an AI assistant to draft it, then FIX its output yourself - editing generated mermaid is exactly the skill the next five sessions build on.
Share the mermaid.live URL with one colleague who knows the flow. Their first correction ("step 3 goes to finance first, actually") proves the diagram is doing its job: making thinking visible.
Try it yourself - this week ◐ 30-45 min total
- Put one mermaid diagram in a real README at work - the repo or doc people ask you about most. The fence, five minutes, permanent payoff.
- Rebuild Nova's 30,000-foot map from memory (no peeking), then diff against the block in Demo 1. Whatever you forgot is the syntax to review.
- Do the shape drill: one flowchart using all six shapes from Part 2's table, each used for its conventional meaning.
- Break three things on purpose in mermaid.live - an unquoted label, a one-dash arrow, a node named
end- and read the errors. Debugging without fear starts here. - Bring to Session 2: one real diagram of yours that grew past 10 nodes and got messy. Subgraphs are the medicine, and we'll apply it to Nova and to yours.
Official docs covered
This session teaches the working content of these sections of the official docs at mermaid.js.org (mermaid 11.x). What stays with the official ecosystem: the full shape catalog reference, video tutorials, and the Mermaid Chart SaaS product.
Three questions before you go 🎯 ◐ 90 seconds
1 · Your label "Load (v2) data" throws a parse error. The fix is...
Quotes tell the parser "everything inside is just text". The single most useful debugging habit in mermaid.
2 · Why commit mermaid source instead of an exported PNG?
The whole point of diagrams-as-code: versionable, diffable, reviewable, updated in the same PR that changes the system.
3 · Which line starts a top-down flowchart?
Type keyword first, direction second. LR for processes that read like sentences, TD for hierarchies and decisions.