Unsaved
Ready
Loading Monaco Editor...
Preview
Styling
All diagram types

Mermaid Architecture Diagram Syntax & Examples

Architecture diagrams place services in groups and connect their sides. Built-in icons cover the usual infrastructure boxes.

Examples

Copy an example, or open it in the live editor with this diagram already loaded.

App, database, and storage

A group is the boundary. Edges name the side of each service: L, R, T, or B.

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

Edge in front of the app

Two groups show a boundary between the edge and the private services. The edge crosses groups.

architecture-beta
    group edge(internet)[Edge]
    group vpc(cloud)[VPC]
    service cdn(disk)[CDN] in edge
    service app(server)[App] in vpc
    service db(database)[Postgres] in vpc
    cdn:R -- L:app
    app:R -- L:db

Backup beside the database

A service can connect to more than one neighbor. Each edge names the sides it uses.

architecture-beta
    group data(cloud)[Data]
    service primary(database)[Primary] in data
    service replica(database)[Replica] in data
    service backup(disk)[Backup] in data
    primary:R -- L:replica
    primary:B -- T:backup

What is a Architecture Diagram?

A Mermaid architecture diagram is an infrastructure sketch. architecture-beta starts it. service id(icon)[Label] declares a box, and group id(icon)[Label] draws a boundary. Adding in groupId places the service inside that group. Edges name the sides they attach to: L, R, T, and B. db:L -- R:server draws a line from the left of the database to the right of the server. Icons include cloud, database, disk, server, and internet. Use this for machines and networks. Use C4 when you want person, system, and container semantics instead of icons.

When to use it

Use an architecture diagram for a deployment sketch: edge, app, database, storage. Use a C4 diagram for a context or container review with descriptions. Use a block diagram when you want a plain grid and no icons.

Edit this architecture diagram in the live editor, read the Mermaid cheat sheet, or compare it with C4 Diagram, Block Diagram and Flowchart.

Common Use Cases

  • •Cloud architecture - Document AWS, GCP, or Azure infrastructure
  • •Microservice design - Visualize service dependencies and communication
  • •Infrastructure documentation - Map servers, databases, and networks
  • •System design interviews - Communicate architecture decisions clearly
  • •DevOps planning - Plan deployment architecture and service topology

Syntax Quick Reference

ElementSyntaxDescription
Serviceservice id(icon)[Label]Define a service with icon
Groupgroup id(icon)[Label]Group services together
In groupservice id(icon)[Label] in groupPlace service in a group
Connectiona:L -- R:bConnect services (L/R/T/B)
Iconsdatabase, server, disk, cloudBuilt-in service icons

Syntax tips

  • •Start with architecture-beta. Declare groups before the services that sit inside them.
  • •service id(icon)[Label] in groupId places the box. The id is what edges use.
  • •Icons you can rely on here include cloud, database, disk, server, and internet.
  • •An edge names sides: serviceA:R -- L:serviceB. Sides are T, B, L, and R.
  • •A group is a boundary, not a network device. Put a load balancer in its own service if you need to show it.

Common mistakes

Connecting services by id alone, with no side.

Architecture edges need a side on each end: web:R -- L:db.

Using an icon name the renderer does not know.

Stay with cloud, database, disk, server, and internet unless you have confirmed another icon in this version.

Writing C4 descriptions inside an architecture service.

Architecture services take an icon and a label. Move person/system/container descriptions to a C4 diagram.

Export Options

Infrastructure sketches belong in a runbook or a design doc. SVG keeps the icons sharp. Free PNG exports include a watermark.

Got Mermaid code from ChatGPT? Paste it here to render and export instantly.

Get the Free Mermaid Syntax Cheat Sheet

Free Mermaid Syntax Cheat Sheet

All 21 diagram types in one PDF reference.

Frequently Asked Questions

Ready to create your own architecture diagram?

Open the editor with this example pre-loaded and start customizing.

Architecture Diagram templates

Related Diagram Types

All diagram types