learn-mermaid-with-phoebe / Session 1 of 6
Learn Mermaid with Phoebe · Session 1 of 6

Draw with text: diagrams as code

Why the best diagrams in tech are typed, not dragged - and your first mermaid flowchart, live in the browser, pushed to GitHub, rendering in Notion, all before the coffee gets cold.

🟢 Easiest Data & AI teams Anyone who explains systems 45 min live + self-study depth
0-3 · Welcome 3-23 · Concepts (live cards) 23-40 · Three demos 40-45 · Q&A
Part 0

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.

Live - presented in session Self-study - read after class ★ Try it now Every diagram on this page is REAL mermaid, rendered live
★ What you walk out with today The diagrams-as-code mental model, working flowchart syntax (nodes, shapes, arrows, direction), a mermaid.live workflow, your first diagram rendering natively in GitHub and Notion - and Nova's 30,000-foot map, the first artifact of our running project. Every pink diagram block below is live mermaid: flip to Code, copy it, break it, fix it.
Part 1 · covers "About Mermaid" + why diagrams-as-code

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.

flowchart LR A[Sources] --> B[Pipeline] B --> C[Warehouse] Plain text lives in git, diffs in PRs, edits in any editor mermaid.js renders it The renderer built into GitHub, Notion, Obsidian, docs sites A crisp diagram SVG output, always sharp, restyled by theme, never stale
🔍 Click to zoom - text in, renderer in the middle, diagram out. The text is the source of truth.
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.
Real world

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.
★ Try it nowOpen any diagram on this page, flip to Code, hit "Edit on mermaid.live" - change a label, watch it re-render as you type. That feedback loop is the whole workflow.
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.
Part 2 · covers "Flowchart" syntax basics

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 typeYou getConvention
a[text]rectanglea process or step
a(text)rounded rectanglea softer step, an activity
a{text}diamonda decision - pair with yes/no edge labels
a[(text)]cylindera database or store
a([text])stadium/pillstart and end points
a((text))circlea 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.

Quoting rule Label contains punctuation that confuses the parser - parentheses, brackets, colons? Wrap it in quotes: 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 --> c works, and a & b --> c fans two nodes into one.
  • No arrowhead: a --- b for 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.

★ Try it nowCopy the edge-styles diagram above into mermaid.live and change LR to TD. Same meaning, new geometry, zero rework - that's the machine doing the layout job.
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 sequenceDiagram block, or vice versa. Check line 1 first.
  • A reserved word as a node ID - naming a node end breaks flowcharts; use End or fin.

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.

Part 3 · covers "Getting started" + ecosystem integrations

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.

one mermaid source GitHub Notion Obsidian VS Code docs sites mermaid.live Write once as text - every host renders it natively. No exports, no stale screenshots.
🔍 Click to zoom - one source, six homes. The fence syntax is the passport.
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:

The fence - memorize this shape```mermaid flowchart LR a[Write text] --> b[Get diagram] ```
  • 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).
Real world

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.

Demo 1 of 3 · the running project starts here

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.

Layout twitchy? Node order in the source nudges layout. If two boxes cross wires, reorder the lines that declare them - usually enough. Session 2 adds subgraphs, which tame layout properly.
Demo 2 of 3

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.

Real world

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.

Demo 3 of 3

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.

Homework

Try it yourself - this week ◐ 30-45 min total

Source material

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.

✓About MermaidPart 1 - what it is, the diagrams-as-code case
✓Getting startedPart 3 + Demos - live editor, the fence, first integrations
✓Flowchart: nodes, shapes, edges, directionPart 2 - the daily-driver subset to working depth
◐Flowchart: full shape catalog + v11 shape syntaxSession 2 finishes - 30+ shapes via @{ shape: ... }
◐Syntax and configurationcomments + structure today; config and directives in Session 6
✓Ecosystem: tutorials + integrations overviewPart 3 - GitHub, Notion, Obsidian, VS Code, docs sites
Check yourself

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.

Session 1 cheat sheet · pin this

The skeletonType keyword first line (flowchart LR), statements after, %% for comments. The first word picks the grammar.
Shapes[step] · (soft) · {decision} · [(database)] · ([start/end]) · ((event)). Shape = meaning.
Edges--> solid · -.-> dotted (async) · ==> thick (critical) · ---> no head with --- · label with |text|.
DirectionLR reads like a sentence (processes) · TD reads like a tree (hierarchies, decisions). Flip when cramped.
The fence```mermaid + source + ``` renders in GitHub, GitLab, Obsidian, Notion (/code → Mermaid), most docs sites.
Debug orderQuote weird labels → check arrow dashes → check line 1 type → rename any node called "end" → bisect with %%.
WorkshopDraft in mermaid.live (errors as you type, URL = the file) · live in the fence next to the code it describes.
Nova so farevents + CRM → ingestion → quality gate → warehouse → dashboards + ML. We refine it for five more sessions.