Pick the diagram that answers your question, then draw it the same way every time.
Which software architecture diagram to draw, when to draw it, and how. It covers the C4 model's levels plus the other diagrams software architecture work needs. Each entry says when to use it, how to draw it, and shows a live example with Mermaid source to copy.
These rules apply to every diagram below. They are the standard; the drawing tool is not.
People are person icons. Draw every person or role as a person icon with its name under it. Never put a person in a box. Boxes are for systems and their parts.
One level, one scope. Each diagram shows one level of zoom for one scope. Its title names both, such as "Container: ticketing system".
Say what each box is. Under each name, state its kind in brackets, such as [Container: REST service] or [External system], and add one line about what it does.
Label every arrow. Each arrow says what flows or what is asked, in the direction of the request, plus the technology when it matters: "Reads orders (SQL)".
Words carry the meaning. Colour, dashes, and line style may only highlight. Anything they suggest is also said in words, in the label or in a legend. External systems say [External] as well as being dashed.
Boundaries are labelled. A boundary (a system, a network, a cloud region) is a labelled group, and its label says what kind of boundary it is.
Safe in light and dark. Prefer coloured strokes over filled shapes, set text colour explicitly for high contrast, and check the diagram on both a light and a dark page before publishing.
Short arrow labels. Keep arrow labels to 2 to 6 words. When an arrow needs more, number it or move the detail to a relationship table under the diagram.
Visual language over syntax. The rules above are the standard; Mermaid is the default way to draw them. When a Mermaid type cannot follow a rule (C4 syntax draws people as boxes), use another type or another tool that can. Whatever the tool, keep names and meanings identical across every version of the same diagram.
Small enough to read. Aim for no more than about 12 boxes. When a diagram grows past that, split it or zoom out a level.
Around every diagram
Title block
Put these on the diagram or in the caption right above or below it.
Field
What goes in it
Title
Names the archetype and the scope: "Container: ticketing system".
Scope
One line on what is in and what is deliberately left out.
Status
Draft, Review, Final, or Retired.
Version and date
Bump the version when the meaning changes, not for layout tweaks.
Author
Who to ask.
Source
A link to the editable source (the Mermaid text, or the draw.io file next to its exports).
Companion tables
Table
Columns
When
Relationship table
Source, Target, Intent, Protocol or technology, Notes
When arrows need more than 2 to 6 words. Keep the arrow label short; put the detail here.
Beside every diagram that will be maintained. It is searchable when the picture is not, and it is the list reviewers check against.
Choosing a tool
Tool
Use it for
Mermaid
Small diagrams (up to about 12 elements), text kept in version control next to the docs, pages that render Mermaid natively.
Graphviz (DOT)
Dense graphs where automatic layout and ranking matter more than hand placement.
draw.io
Large or hand-arranged diagrams, and diagrams people who do not write code will edit. Keep the .drawio source next to its SVG or PNG export.
Structure
What the parts are and how they connect, zooming in one C4 level at a time.
AD06 System landscape
Structure · C4 supplementary · Mermaid flowchart · Active
Use when
You need the big picture of an organisation: all its systems, who uses each one, and how they depend on each other. Good for onboarding and portfolio planning.
Draw it
One box per software system, no containers inside.
People as person icons on the edge, grouped by role.
One labelled boundary for the organisation; systems outside it are [External].
Arrows only for real dependencies, each labelled with its purpose.
Scope
In: Every system in the organisation, its user groups, the outside systems it relies on. Out: Anything inside a system: containers, components, infrastructure.
Structure · C4 level 1 · Mermaid flowchart · Active
Use when
Showing who uses one system and which other systems it talks to. Start here: it is the diagram everyone, technical or not, can read.
Draw it
The system in focus is one box in the middle.
Its users as person icons, its neighbours as boxes marked [External system] where they are.
No technology choices, containers, or protocols beyond what a non-technical reader needs.
Each arrow names the purpose: "Buys tickets", not "HTTPS".
Scope
In: One system in focus, the people who use it, the outside systems it connects to. Out: Containers, components, technology choices, infrastructure.
Check it
Exactly one system in focus.
Every person and outside system has a one-line role or responsibility.
No container or component detail.
Every arrow names an intent a non-technical reader understands.
Example
---
title: "System context: ticketing system"
---
flowchart TB
attendee@{ icon: "fa:user", form: "circle", label: "Attendee", pos: "b", h: 48 }
staff@{ icon: "fa:user", form: "circle", label: "Box office staff", pos: "b", h: 48 }
ticketing["Ticketing system<br/><i>[Software system]</i><br/>Sells tickets and checks them at the door"]
payments["Payment provider<br/><i>[External system]</i>"]
email["Email service<br/><i>[External system]</i>"]
attendee -- "Buys tickets, shows them at the door" --> ticketing
staff -- "Sets up events, issues refunds" --> ticketing
ticketing -- "Takes card payments" --> payments
ticketing -- "Sends receipts and tickets" --> email
classDef ext stroke-dasharray: 5 5
class payments,email ext
Mermaid source
---
title: "System context: ticketing system"
---
flowchart TB
attendee@{ icon: "fa:user", form: "circle", label: "Attendee", pos: "b", h: 48 }
staff@{ icon: "fa:user", form: "circle", label: "Box office staff", pos: "b", h: 48 }
ticketing["Ticketing system<br/><i>[Software system]</i><br/>Sells tickets and checks them at the door"]
payments["Payment provider<br/><i>[External system]</i>"]
email["Email service<br/><i>[External system]</i>"]
attendee -- "Buys tickets, shows them at the door" --> ticketing
staff -- "Sets up events, issues refunds" --> ticketing
ticketing -- "Takes card payments" --> payments
ticketing -- "Sends receipts and tickets" --> email
classDef ext stroke-dasharray: 5 5
class payments,email ext
AD07 Application context
Structure · Between C4 levels 1 and 2 · Mermaid flowchart · Active
Use when
One application lives among many in a larger estate and you need to show its neighbours: the shared services it leans on (sign-in, notifications, reporting) and the sibling applications it trades data with. It looks outward. To look inward at what a change will affect, use AD15 Internal dependency map.
Draw it
The application in focus in the middle; everything else at the same level of detail.
Shared platform services in their own labelled group, so the reader sees what is reused rather than owned.
Users as person icons, only those who use this application.
Arrows name the data or service exchanged.
Scope
In: One application, the shared services it uses, the sibling applications it exchanges data with, its users. Out: The application's internals and anything it does not touch.
Check it
Shared services are grouped and labelled as shared.
Sibling applications are marked as siblings, not as outside systems.
Structure · C4 level 2 · Mermaid flowchart · Active
Use when
Showing the separately deployable or runnable parts of one system (apps, services, databases, queues) and how they talk. The workhorse diagram for technical design.
Draw it
A labelled boundary for the system; its containers inside, each with [Container: technology].
Data stores as cylinders.
Users and external systems outside the boundary, the same ones as the system context.
Arrows name the purpose and the protocol: "Calls (JSON/HTTPS)".
Scope
In: The containers inside one system boundary, the people and outside systems that touch them, and the main technology of each. Out: Components and classes; where things run (that is AD13 Deployment).
Check it
The system boundary is drawn.
Every container states its technology.
Data stores are cylinders.
No component detail and no hosting topology.
Example
---
title: "Container: ticketing system"
---
flowchart TB
attendee@{ icon: "fa:user", form: "circle", label: "Attendee", pos: "b", h: 48 }
staff@{ icon: "fa:user", form: "circle", label: "Box office staff", pos: "b", h: 48 }
subgraph sys["Ticketing system [System boundary]"]
web["Web shop<br/><i>[Container: single-page app]</i><br/>Browse events, buy tickets"]
admin["Box office app<br/><i>[Container: web app]</i><br/>Sales, refunds, scanning"]
api["Ticketing API<br/><i>[Container: REST service]</i><br/>Orders, pricing, tickets"]
db[("Ticket database<br/><i>[Container: PostgreSQL]</i>")]
end
payments["Payment provider<br/><i>[External system]</i>"]
attendee -- "Uses (HTTPS)" --> web
staff -- "Uses (HTTPS)" --> admin
web -- "Calls (JSON/HTTPS)" --> api
admin -- "Calls (JSON/HTTPS)" --> api
api -- "Reads and writes (SQL)" --> db
api -- "Takes payments (HTTPS)" --> payments
classDef ext stroke-dasharray: 5 5
class payments ext
Mermaid source
---
title: "Container: ticketing system"
---
flowchart TB
attendee@{ icon: "fa:user", form: "circle", label: "Attendee", pos: "b", h: 48 }
staff@{ icon: "fa:user", form: "circle", label: "Box office staff", pos: "b", h: 48 }
subgraph sys["Ticketing system [System boundary]"]
web["Web shop<br/><i>[Container: single-page app]</i><br/>Browse events, buy tickets"]
admin["Box office app<br/><i>[Container: web app]</i><br/>Sales, refunds, scanning"]
api["Ticketing API<br/><i>[Container: REST service]</i><br/>Orders, pricing, tickets"]
db[("Ticket database<br/><i>[Container: PostgreSQL]</i>")]
end
payments["Payment provider<br/><i>[External system]</i>"]
attendee -- "Uses (HTTPS)" --> web
staff -- "Uses (HTTPS)" --> admin
web -- "Calls (JSON/HTTPS)" --> api
admin -- "Calls (JSON/HTTPS)" --> api
api -- "Reads and writes (SQL)" --> db
api -- "Takes payments (HTTPS)" --> payments
classDef ext stroke-dasharray: 5 5
class payments ext
You are about to change one part of a system and need to know what else moves: which internal parts depend on it for data, which it triggers or is triggered by, and what to retest. Also good for planning a refactor or a split.
Draw it
The internal parts of one system (containers, jobs, queues, stores) at one level of detail.
Prefix every arrow with what kind of dependency it is: "data:" for information passed or read, "control:" for triggers, schedules, and commands.
Mark the part being changed [Changing] and each part it reaches [Impacted], in words as well as any highlight.
Leave out parts the change cannot reach; say so in the scope line.
Scope
In: The internal parts of one system that the change can reach, and the data and control dependencies between them. Out: Parts the change cannot reach, outside systems unless they depend on the changed part, and code-level detail.
Check it
The changed part is marked [Changing] in words.
Every reached part is marked [Impacted] in words.
Every arrow starts with "data:" or "control:".
Each impacted part has a retest or owner noted in the companion table.
Structure · C4 level 3 · Mermaid flowchart · Active
Use when
Showing the main building blocks inside one container and what each is responsible for. Draw it when a container is complex enough that people argue about where code belongs.
Draw it
A labelled boundary for the one container; its components inside with [Component: kind].
Only the components that matter to the decision at hand, not every class.
Neighbouring containers and external systems outside the boundary.
Arrows name what is asked of the component.
Scope
In: The components inside one container, how they collaborate, and the neighbouring containers they call. Out: Classes, methods, and implementation logic.
Check it
The container boundary is drawn.
Each component has a responsibility, not just a name.
Structure · C4 level 4 · Mermaid classDiagram · Active
Use when
Showing the types inside one component and how they relate. Draw it only when it earns its place, such as a tricky domain model; most code-level diagrams go stale fast and an IDE can generate them.
Draw it
One component's types only.
Show the fields and methods that explain the design; leave out getters and plumbing.
Name relationships with multiplicity: "1 order has 1..* tickets".
Scope
In: The types of one component that explain the design. Out: Every other type, getters, framework plumbing.
Check it
Only types that explain the design are shown.
Every relationship has a multiplicity and a verb.
Someone will keep it current, or it is generated.
Example
---
title: "Code: ordering model"
---
classDiagram
class Order {
+OrderId id
+Status status
+Money total()
+confirm(PaymentRef ref)
}
class Ticket {
+TicketId id
+Seat seat
+String qrCode
}
class PriceRule {
<<interface>>
+Money apply(Money base)
}
class EarlyBird
Order "1" *-- "1..*" Ticket : contains
Order ..> PriceRule : priced by
PriceRule <|.. EarlyBird
Mermaid source
---
title: "Code: ordering model"
---
classDiagram
class Order {
+OrderId id
+Status status
+Money total()
+confirm(PaymentRef ref)
}
class Ticket {
+TicketId id
+Seat seat
+String qrCode
}
class PriceRule {
<<interface>>
+Money apply(Money base)
}
class EarlyBird
Order "1" *-- "1..*" Ticket : contains
Order ..> PriceRule : priced by
PriceRule <|.. EarlyBird
Data
What is stored and how information moves.
AD05 Entity relationship
Data · Supplementary · Mermaid erDiagram · Active
Use when
Showing what is stored: the entities, their key fields, and how they relate. Use it for schema design and for agreeing on the meaning of words with domain experts.
Draw it
One box per entity, named as the business names it.
Only key and meaningful fields; mark PK and FK.
Each relationship has crow's-foot cardinality and a verb label: "places", "holds".
Scope
In: The entities in one data store or one domain, their key fields, their relationships. Out: Indexes, storage tuning, every column.
Check it
Entity names match the words the business uses.
Keys are marked.
Every relationship has cardinality and a verb.
Example
---
title: "Entity relationship: ticketing"
---
erDiagram
ATTENDEE ||--o{ ORDER : places
ORDER ||--|{ TICKET : contains
EVENT ||--|{ TICKET_TYPE : offers
TICKET_TYPE ||--o{ TICKET : "is sold as"
ATTENDEE {
uuid id PK
string email
}
ORDER {
uuid id PK
uuid attendee_id FK
string status
}
TICKET {
uuid id PK
uuid order_id FK
uuid ticket_type_id FK
string seat
}
Mermaid source
---
title: "Entity relationship: ticketing"
---
erDiagram
ATTENDEE ||--o{ ORDER : places
ORDER ||--|{ TICKET : contains
EVENT ||--|{ TICKET_TYPE : offers
TICKET_TYPE ||--o{ TICKET : "is sold as"
ATTENDEE {
uuid id PK
string email
}
ORDER {
uuid id PK
uuid attendee_id FK
string status
}
TICKET {
uuid id PK
uuid order_id FK
uuid ticket_type_id FK
string seat
}
AD08 Data flow
Data · Supplementary · Mermaid flowchart · Active
Use when
Showing how information moves: where it enters, which processes change it, where it rests, and where it leaves. Use it for privacy reviews, threat modelling, and integration design.
Draw it
People and outside parties at the edges, as person icons or [External] boxes.
Processes as rounded boxes named with a verb: "Take payment".
Data stores as cylinders.
Every arrow names the data it carries, not the call: "card details", "order".
Trust boundaries as labelled groups.
Scope
In: Entry and exit points, the processes that change data, stores, trust boundaries, the controls at each boundary. Out: Screens and business rules that do not change how data is handled.
Check it
Every entry and exit point is shown.
Every trust boundary is labelled and its controls (encryption, access check, logging) are named at the crossing.
Privileged paths (admin, staff) are drawn separately from ordinary user paths, and labelled as such.
Integration · Supplementary · Mermaid flowchart · Active
Use when
Showing the contracts between systems: which interfaces each one provides, which it needs, and who consumes them. Use it to plan versioning, ownership, and the impact of an interface change.
Draw it
Systems or containers as boxes; each interface as a circle named with its style and version: "Orders API, REST v2".
Arrows say "provides", "requires", "publishes" or "subscribes".
Mark external interfaces [External] in the label.
Scope
In: Interfaces (APIs, topics, files, shared databases) provided and required, their consumers, and their style and version. Out: Internal components behind the interface.
Check it
Every interface has a name, a style, and a version.
Every provider and consumer is shown.
Sign-in and authorisation for each interface are noted or linked.
Behaviour · C4 dynamic · Mermaid flowchart · Active
Use when
Walking through one use case on top of the structure diagrams: the same boxes, with numbered steps. Use it when the order matters but a full sequence diagram would be too much.
Draw it
Reuse the boxes and names from the container or component diagram.
Number each arrow in order: "Step 1: Places order".
One scenario per diagram; its title names it.
Scope
In: One use case: the people and parts it touches, in numbered order, plus its main exception path. Out: Every other use case.
Check it
One use case per diagram, named in the title.
Steps are numbered and unambiguous.
The main exception or decision path is shown or linked.
Scenarios that should become integration or acceptance tests are marked as test candidates.
Example
---
title: "Scenario: attendee buys a ticket"
---
flowchart TB
attendee@{ icon: "fa:user", form: "circle", label: "Attendee", pos: "b", h: 48 }
web["Web shop<br/><i>[Container]</i>"]
api["Ticketing API<br/><i>[Container]</i>"]
db[("Ticket database<br/><i>[Container]</i>")]
payments["Payment provider<br/><i>[External system]</i>"]
attendee -- "Step 1: Chooses seats and pays" --> web
web -- "Step 2: Places order" --> api
api -- "Step 3: Charges card" --> payments
api -- "Step 4: Saves order and tickets" --> db
web -- "Step 5: Shows QR tickets" --> attendee
classDef ext stroke-dasharray: 5 5
class payments ext
Mermaid source
---
title: "Scenario: attendee buys a ticket"
---
flowchart TB
attendee@{ icon: "fa:user", form: "circle", label: "Attendee", pos: "b", h: 48 }
web["Web shop<br/><i>[Container]</i>"]
api["Ticketing API<br/><i>[Container]</i>"]
db[("Ticket database<br/><i>[Container]</i>")]
payments["Payment provider<br/><i>[External system]</i>"]
attendee -- "Step 1: Chooses seats and pays" --> web
web -- "Step 2: Places order" --> api
api -- "Step 3: Charges card" --> payments
api -- "Step 4: Saves order and tickets" --> db
web -- "Step 5: Shows QR tickets" --> attendee
classDef ext stroke-dasharray: 5 5
class payments ext
AD11 Sequence
Behaviour · Supplementary · Mermaid sequenceDiagram · Active
Use when
Showing the exact order of calls and replies between parts, including waits, errors, and retries. Use it for API design, timing problems, and debugging.
Draw it
People as actors (Mermaid draws a stick figure), systems as participants.
Solid arrows for requests, dashed arrows for replies; each names the message.
Show the unhappy path with alt or opt blocks, not a second diagram.
Scope
In: The calls and replies for one interaction, including errors, waits, and retries. Out: Unrelated interactions and internal logic of each participant.
Check it
Every message is named.
The unhappy path is in an alt or opt block.
People are actors, not participant boxes.
Example
---
title: "Sequence: buy a ticket"
---
sequenceDiagram
actor A as Attendee
participant W as Web shop
participant API as Ticketing API
participant P as Payment provider [External]
A->>W: Choose seats and pay
W->>API: POST /orders
API->>P: Charge card
alt card approved
P-->>API: Approved
API-->>W: 201 Created, tickets
W-->>A: Shows QR tickets
else card declined
P-->>API: Declined
API-->>W: 402 Payment required
W-->>A: Asks for another card
end
Mermaid source
---
title: "Sequence: buy a ticket"
---
sequenceDiagram
actor A as Attendee
participant W as Web shop
participant API as Ticketing API
participant P as Payment provider [External]
A->>W: Choose seats and pay
W->>API: POST /orders
API->>P: Charge card
alt card approved
P-->>API: Approved
API-->>W: 201 Created, tickets
W-->>A: Shows QR tickets
else card declined
P-->>API: Declined
API-->>W: 402 Payment required
W-->>A: Asks for another card
end
AD12 State
Behaviour · Supplementary · Mermaid stateDiagram-v2 · Active
Use when
Showing the life cycle of one thing (an order, a ticket, a case) and the events that move it between states. Use it whenever someone asks "what can happen to it next?".
Draw it
One diagram per thing; states named as adjectives or past participles: "Paid".
Each transition names the event that causes it.
Mark the start and every end state.
Scope
In: The states of one thing and the events that move it between them. Out: Other things' states, how events are implemented.
Operations · C4 deployment · Mermaid flowchart · Active
Use when
Showing where the containers run: environments, regions, hosts, managed services, and the network paths between them. Use it for hosting decisions, capacity, and failover planning.
Draw it
Nested labelled groups for the infrastructure: [Environment], [Region], [Node].
Containers inside the node that runs them, with instance counts: "x2".
Arrows name the protocol and port when it matters.
One environment per diagram, named in the title.
Scope
In: One environment: its nodes, regions, and managed services, which containers run where, instance counts, and network paths. Out: Business logic, components, and other environments.
Check it
One environment per diagram, named in the title.
Major runtime and framework versions are stated.
The names of the settings and secrets each part needs are listed in the companion table, never their values.
Nodes match real infrastructure boundaries.
Scaling and failover are shown where they exist.
Example
---
title: "Deployment: production"
---
flowchart TB
attendee@{ icon: "fa:user", form: "circle", label: "Attendee", pos: "b", h: 48 }
subgraph prod["Production [Environment]"]
subgraph edge["CDN [Edge network]"]
web["Web shop files<br/><i>[Static site]</i>"]
end
subgraph region["US West [Cloud region]"]
subgraph app["App service [Node]"]
api["Ticketing API x2<br/><i>[Container]</i>"]
end
subgraph data["Managed database [Node]"]
db[("PostgreSQL primary + standby")]
end
end
end
attendee -- "HTTPS 443" --> web
web -- "JSON/HTTPS 443" --> api
api -- "SQL over TLS 5432" --> db
Mermaid source
---
title: "Deployment: production"
---
flowchart TB
attendee@{ icon: "fa:user", form: "circle", label: "Attendee", pos: "b", h: 48 }
subgraph prod["Production [Environment]"]
subgraph edge["CDN [Edge network]"]
web["Web shop files<br/><i>[Static site]</i>"]
end
subgraph region["US West [Cloud region]"]
subgraph app["App service [Node]"]
api["Ticketing API x2<br/><i>[Container]</i>"]
end
subgraph data["Managed database [Node]"]
db[("PostgreSQL primary + standby")]
end
end
end
attendee -- "HTTPS 443" --> web
web -- "JSON/HTTPS 443" --> api
api -- "SQL over TLS 5432" --> db
AD14 Operations
Operations · Supplementary · Mermaid flowchart · Active
Use when
Showing how people keep the system running: what is monitored, who gets alerted, where the runbooks and backups are, and how a restore happens. Use it for handovers, on-call setup, and reliability reviews.
Draw it
The people on call as person icons, with their role.
Monitoring, alerting, logs, and backups as boxes; the system itself as one box.
Arrows name the check or action and how often: "Health check every minute".
Scope
In: Build and release stages, monitoring, alerting, logs, security scanning, backups, and who is called and how. Out: Business process and user-facing detail.
Check it
Every build and release stage is shown.
Monitoring and alerting are visible, with who gets paged.
Security scanning and backups appear where they exist.