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.
Write service id(icon)[Label]. Example: service db(database)[Database] in api. The id is used by edges, and the word in parentheses is the icon.
Declare group id(icon)[Label], then add in groupId on each service that belongs inside it. The group draws the boundary around those services.
Name the side of each service. web:R -- L:db connects the right side of web to the left side of db. The sides are T, B, L, and R.
cloud, database, disk, server, and internet are the icons used in the examples on this page. The icon name goes in parentheses before the label.
Use an architecture diagram for infrastructure icons and groups. Use a C4 diagram when the review needs people, external systems, and the context, container, or component zoom.
Ready to create your own architecture diagram?
Open the editor with this example pre-loaded and start customizing.