Mermaid syntax tutorial

Mermaid Architecture Diagram Tutorial

Architecture diagrams show services, groups, and connections in a system. They are useful for infrastructure and platform overviews.

Cloud architecture overviewsPlatform onboardingService dependency maps
Syntax

architecture-beta

Examples

1 starter pattern

Review

5 production checks

Diagram preview

Rendered Mermaid example

Architecture Diagram
Mermaid Architecture Diagram example

What You Will Learn

How to recognize when Architecture Diagram is the right Mermaid diagram, write the opening declaration, and shape a readable first version.

Best Fit

Cloud architecture overviews, Platform onboarding, Service dependency maps.

Start Here

Copy the starter example, replace labels with your domain language, then simplify anything that does not help the reader.

Syntax Basics

Start with the diagram declaration, then add the smallest set of labels, relationships, and annotations needed to communicate the idea.

  • Use architecture-beta as the declaration.
  • Define groups for boundaries.
  • Define services with meaningful icons and labels.
  • Connect services with directional edges.

Official Documentation Coverage

The Mermaid documentation for Architecture Diagram covers the following syntax areas. This tutorial condenses those topics into practical guidance for day-to-day documentation.

Groups

Groups is part of the official Mermaid Architecture Diagram syntax surface. Add it when the starter example needs more precision for production documentation.

Services

Services defines the named objects in the diagram. Keep names stable, domain-specific, and short enough to remain readable in exported images.

Edges

Edges controls how elements connect. Treat these connections as the main information layer, and label them when direction, ownership, or meaning is not obvious.

Sibling alignment

Sibling alignment is part of the official Mermaid Architecture Diagram syntax surface. Add it when the starter example needs more precision for production documentation.

Junctions

Junctions is part of the official Mermaid Architecture Diagram syntax surface. Add it when the starter example needs more precision for production documentation.

Configuration

Use Configuration after the diagram communicates the right structure. Styling should improve scanning and emphasis without hiding the underlying Mermaid syntax.

Layout tuning

Layout tuning is part of the official Mermaid Architecture Diagram syntax surface. Add it when the starter example needs more precision for production documentation.

Icons

Icons is part of the official Mermaid Architecture Diagram syntax surface. Add it when the starter example needs more precision for production documentation.

How This Tutorial Uses The Official Docs

Mermaid syntax evolves, so the official page remains the primary reference. This tutorial turns that reference material into an authoring workflow, review checklist, and production guidance.

Start with the official grammar

The official Mermaid Architecture Diagram page is the source of truth for syntax changes. Use this tutorial to choose the right authoring pattern, then confirm exact keywords and edge cases in the official reference.

Prioritize the core sections

For the first pass, focus on Groups, Services, Edges, Sibling alignment. These sections usually explain the minimum structure required for a valid Architecture Diagram.

Add advanced syntax only when it earns its space

Treat Junctions, Configuration, Layout tuning, Icons as optional layers. They are valuable when the diagram needs precision, but they should not make the first version harder to read.

Syntax Reference Map

Use this map as a practical reading order for the official syntax page. It separates the first concepts to learn from the advanced details that are better added after the diagram already communicates the right idea.

Phase
How to use it
Start
Groups

Groups is part of the official Mermaid Architecture Diagram syntax surface. Add it when the starter example needs more precision for production documentation.

Does this groups detail make the architecture diagram easier to understand or maintain?

Start
Services

Services defines the named objects in the diagram. Keep names stable, domain-specific, and short enough to remain readable in exported images.

Does this services detail make the architecture diagram easier to understand or maintain?

Refine
Edges

Edges controls how elements connect. Treat these connections as the main information layer, and label them when direction, ownership, or meaning is not obvious.

Does this edges detail make the architecture diagram easier to understand or maintain?

Refine
Sibling alignment

Sibling alignment is part of the official Mermaid Architecture Diagram syntax surface. Add it when the starter example needs more precision for production documentation.

Does this sibling alignment detail make the architecture diagram easier to understand or maintain?

Refine
Junctions

Junctions is part of the official Mermaid Architecture Diagram syntax surface. Add it when the starter example needs more precision for production documentation.

Does this junctions detail make the architecture diagram easier to understand or maintain?

Polish
Configuration

Use Configuration after the diagram communicates the right structure. Styling should improve scanning and emphasis without hiding the underlying Mermaid syntax.

Does this configuration detail make the architecture diagram easier to understand or maintain?

Polish
Layout tuning

Layout tuning is part of the official Mermaid Architecture Diagram syntax surface. Add it when the starter example needs more precision for production documentation.

Does this layout tuning detail make the architecture diagram easier to understand or maintain?

Polish
Icons

Icons is part of the official Mermaid Architecture Diagram syntax surface. Add it when the starter example needs more precision for production documentation.

Does this icons detail make the architecture diagram easier to understand or maintain?

How To Study The Official Syntax

The official Mermaid page is broad because it documents the full parser surface. For a working tutorial, read it in passes instead of trying to memorize every option at once.

Step 1

Skim the official Architecture Diagram documentation once to understand the full syntax surface before copying examples into production docs.

Step 2

Focus first on Groups, Services, Edges, Sibling alignment, Junctions because these topics usually explain the core authoring model.

Step 3

After the first diagram renders, revisit the official styling, configuration, and advanced sections only when the diagram needs that extra precision.

Authoring Workflow

This workflow turns the official syntax reference into a repeatable writing process for docs, specs, and product pages.

Step 1

Frame the reader question

Before writing syntax, decide what question the Architecture Diagram should answer. Good diagrams usually answer one question clearly instead of answering several partially.

Step 2

Draft the smallest valid diagram

Start with the declaration for architecture-beta, add only the required elements, and render it before introducing advanced styling or configuration.

Step 3

Add semantic labels

Replace placeholder names with business or system language that readers already know. Labels should reduce explanation work.

Step 4

Review for maintenance

Remove details that are likely to drift quickly. If a value, date, or dependency changes often, explain who owns the update.

Quick Syntax Cheat Sheet

Use this compact reference when you already know the goal and need to write a valid Mermaid Architecture Diagram quickly.

Declaration
architecture-beta

Start the code block with architecture-beta so Mermaid selects the Architecture Diagram renderer.

Core content
Use architecture-beta as the declaration.

Add the smallest number of statements that express the main idea before adding visual polish.

Connections
Connect services with directional edges.

Use connections only where they explain ownership, sequence, flow, dependency, or hierarchy.

Advanced topic
Groups

Use official syntax topics as optional layers, not as requirements for every diagram.

Practice Prompts

Use these prompts after reading the official syntax sections. They force the diagram to stay practical instead of becoming a syntax inventory.

Exercise 1

Create a Architecture Diagram for cloud architecture overviews using no more than eight visible elements.

Exercise 2

Rewrite the starter example with labels from your own product or engineering domain, then remove any line that does not change the reader's understanding.

Exercise 3

Add one official syntax feature from Groups, Services, Edges and explain why that feature makes the diagram clearer.

Exercise 4

Compare the result with c4 and block and write one sentence explaining why Architecture Diagram is still the better fit.

Examples

Copy the example into the Mermaid editor, then adjust labels and relationships for your own documentation.

Web Architecture

A small service architecture sketch.

architecture-beta
  group app(cloud)[Application]
  service web(server)[Web] in app
  service api(server)[API] in app
  service db(database)[Database] in app
  web:R --> L:api
  api:B --> T:db

Example Walkthrough

Read Mermaid examples from top to bottom. The first meaningful line usually selects the diagram parser; the following lines add labels, relationships, values, states, or layout hints.

architecture-beta

This line declares the Mermaid diagram type, which tells Mermaid which parser and renderer to use.

group app(cloud)[Application]

This line configures structure, labels, sections, participants, axes, or reusable diagram elements.

service web(server)[Web] in app

This line configures structure, labels, sections, participants, axes, or reusable diagram elements.

service api(server)[API] in app

This line configures structure, labels, sections, participants, axes, or reusable diagram elements.

service db(database)[Database] in app

This line configures structure, labels, sections, participants, axes, or reusable diagram elements.

web:R --> L:api

This line adds a relationship, transition, message, data value, or visual item to the diagram.

api:B --> T:db

This line adds a relationship, transition, message, data value, or visual item to the diagram.

When To Use Architecture Diagram

Cloud architecture overviews
Platform onboarding
Service dependency maps
Infrastructure planning

Diagram Choice Guide

A strong Mermaid tutorial should also explain when not to use the diagram type. Use this guide before adding a Architecture Diagram to a public page or technical design document.

Use this diagram when

Architecture Diagram works best for cloud architecture overviews, platform onboarding, service dependency maps. It should make the reader's next decision easier, not merely decorate the page.

Choose a different diagram when

Your main question is better answered by another structure, such as c4, block, packet. For example, use a sequence diagram for message order and a flowchart for branching process logic.

Keep it maintainable by

Keeping the first version small, naming every important element with business language, and linking back to the official Mermaid syntax page when advanced syntax is required.

Production Checklist

Before publishing a Mermaid Architecture Diagram, run through this checklist so the diagram remains useful after the immediate conversation is over.

Confirm that Architecture Diagram is the right diagram type for the problem.
Start from the smallest example that communicates the idea clearly.
Use consistent names for nodes, actors, states, or data labels.
Check the diagram in the Mermaid editor before publishing.
Add surrounding text that explains assumptions, scale, or business context.

Production Review Questions

Before shipping the diagram in public docs, compare it against the official syntax page and then ask whether each line helps the reader make a better decision.

Does the first line clearly select the Mermaid Architecture Diagram renderer with architecture-beta?
Are names and labels from the Services area short, stable, and meaningful to the target reader?
Do the edges details show real meaning instead of visual decoration?
Could a teammate update this diagram next month without rereading the whole surrounding document?

Troubleshooting

Most Mermaid issues come from an incorrect declaration, a syntax feature used before the base diagram works, or a diagram that is trying to communicate too many ideas at once.

The diagram does not render

Check that the first line is the correct declaration for Architecture Diagram: architecture-beta. Then remove advanced lines until the smallest version renders.

The diagram renders but is hard to read

Shorten labels, reduce the number of visible items, and split separate ideas into separate diagrams.

The meaning is ambiguous

Add edge labels, relationship names, axis labels, or surrounding explanatory text so readers know what the diagram is proving.

The diagram becomes stale

Prefer stable concepts over volatile implementation details, and add ownership notes when the diagram documents a changing system.

Publishing Notes

For SEO and long-term documentation quality, keep the Mermaid code close to the explanation. Search engines can understand the surrounding text, while engineers can copy the exact syntax into their own editor.

If the diagram is used in a product page, add a short caption that states what decision the diagram supports. If it is used in internal docs, add ownership and update expectations so the diagram does not become stale after the system changes.

Best Practices

  • -Use groups to show boundaries.
  • -Name services by responsibility.
  • -Keep infrastructure and product views separate.
  • -Document assumptions near the diagram.

Common Mistakes

  • -Mixing deployment, runtime, and business process in one diagram.
  • -Using unclear service names.
  • -Adding every low-level resource.

Choosing Related Diagram Types

If Architecture Diagram does not quite match your communication goal, compare it with these nearby Mermaid diagram types.

FAQ

Is Mermaid Architecture Diagram rendered on the server?

This tutorial page is server-rendered for SEO. The Mermaid syntax is shown as plain text so search engines and readers can inspect it without waiting for client-side rendering.

Can I edit this Architecture Diagram example?

Yes. Open the Mermaid editor, paste the example, and modify the labels, relationships, or values for your own use case.