Skip to content
Connect an agent
Get started

Architecture patterns

A pattern is a ready-made, checked diagram for a common architecture: a three-tier network, a two-zone network, a serverless API, a delivery pipeline, a sign-in flow, a starter database schema. An agent finds the one that fits the request, renames the parts, and has a diagram that already validates with no warnings. It is written for an AI agent first, so each step names the tool to call and says what comes back. A person can follow the same steps by hand and copy the source from any picture below.

TL;DR

QuestionAnswer
Why start from a pattern?The groups, icons, edge styles, and layout are already right, so the work is naming things, not drawing them. Every pattern validates with no warnings in every flavour.
How do I find one?Call find_pattern with the request in plain words, such as serverless api or two availability zones. The best match is first.
What do I get back?An id, a title, a one-sentence summary, the providers it comes in, and tags. Never the source, so a search stays small.
How do I read one?Call get_pattern with the id and a flavour in provider. It returns the source, every slot with its meaning, advice on what to keep, rename, and split, and the diagram as a tree.
How do I draw one?Call draw_from_pattern with the id, a flavour, and the slot values you want to change. It fills, validates, and renders in one call.
What is a slot?A named part of the diagram, such as office or database. A slot value replaces the label and nothing else, so it can never break the source.
What is a flavour?The way a pattern is drawn. Every pattern has a neutral flavour, with generic icons, and many also have one provider's flavour: aws, azure, or gcp. You choose it with the provider field.
Which pattern is too small or too big?Start from the closest one. If the request needs more than about 25 nodes, draw two diagrams and say so; each pattern says where to split.

1. The recipe

Follow these steps in order. Each one ends with a check.

  1. Find the pattern. Call find_pattern with the words of the request. Add provider to keep only the patterns that come in that flavour, kind for flow, sequence, or schema, and tags to require a tag. Read the summaries and pick one. If nothing fits, write the diagram from the language reference instead.
  2. Read it. Call get_pattern with the id and the flavour you want in provider. A flavour the pattern does not have is a problem that lists the ones it has. Read the slots, then the three notes: what to keep, what to rename, and when to split.
  3. Choose the slot values. Use the names from the request. A value is plain text of at most 60 characters, with no quotes, backslashes, or line breaks. A value that breaks a rule comes back as a problem with the slot named, never as an exception.
  4. Draw it. Call draw_from_pattern with the id, the flavour, and the values. It returns valid, the warnings, a summary for the picture's description, an outline to check against the request, and the SVG for the themes you asked for.
  5. Adapt what the slots cannot. To add a node, remove a service, or change an edge, take the source that get_pattern returned, edit it, and call validate_diagram until no warning is left. Keep the shape of the groups: they carry the meaning.
  6. Check the outline. Call outline_diagram, or read the outline in the answer, and compare it with the request line by line. Every service the request names is a node, and every node is something the request names.

A session for the request "a serverless API with a queue for slow work, on Google Cloud" looks like this:

CallInputWhat comes back
find_pattern{"query": "serverless api queue", "provider": "gcp"}serverless-api first, with its summary and tags
get_pattern{"id": "serverless-api", "provider": "gcp"}The source, the slots, the notes, and the group tree
draw_from_pattern{"id": "serverless-api", "provider": "gcp", "slots": {"title": "Order API"}}valid: true, no warnings, an outline, and the SVG

2. Slots

A slot is a named part of a pattern. Every pattern has title and description: the first is the name of the diagram, and the second is the sentence that a screen reader reads in place of the picture. The others are named for what they hold, such as office, load-balancer, or primary-database.

RuleWhy
A slot value replaces a label or a second line, nothing elseA value cannot change an id, a type, an icon, or an arrow, so a bad value cannot break the diagram.
A value has at most 60 characters, except descriptionA box grows to fit its text, and a long label makes the diagram wide.
A value has no quotes, backslashes, or line breaksThe label is a quoted text in the source.
An unknown slot is a problem with the nearest slot nameoffice and ofice are one letter apart; the answer says which you meant.
A slot that is not set keeps its defaultThe defaults are placeholders such as Web tier and 10.0.0.0/16, drawn in the pictures below.

A slot used in several places, such as the name of a load balancer drawn once for each tier, is set once and changes everywhere.

3. The patterns

PatternUse it forIdFlavours
Three-tier network behind load balancersAn office network joins a cloud network through a VPN gateway, and three tiers each put a load balancer in front of a redundant set of machines.three-tier-networkNeutral, Azure
Two-zone network with a replicated databaseA network spans two availability zones, each with a public, a private, and an isolated subnet, joined by one balancer set, one scaling group, and a replicated database.two-zone-networkNeutral, AWS
Hub and spoke networkA hub network with a firewall and shared services links an office to several isolated spoke networks, so all traffic between them passes one place.hub-and-spoke-networkNeutral, Azure
Web application on a cloudA single-page app is served through a CDN, backed by an API on a hosting plan, a database, a queue and worker, identity, storage, a delivery pipeline, and monitoring.web-app-on-cloudNeutral, Azure
Serverless APIA client calls an API gateway that checks sign-in and routes to three functions, which keep records in a managed database and files in object storage.serverless-apiNeutral, AWS, Google Cloud
Microservices behind an API gatewayClients call one API gateway that checks identity and routes to small services, which talk to each other through a message bus and each keep their own database.microservices-gatewayNeutral, AWS, Azure, Google Cloud
Container platformA delivery pipeline pushes images to a registry, and a managed cluster runs three services on a redundant node pool behind an ingress, with configuration, secrets, and monitoring.container-platformNeutral, Google Cloud
Queue and worker poolA web API puts jobs on a queue, a pool of workers takes them and writes results to a database, failed jobs go to a dead-letter queue, and an alarm watches the queue depth.queue-workerNeutral, AWS
Event-driven pipelineSeveral services publish events to an event bus, three independent consumers react to them, and events that keep failing go to a dead-letter queue.event-driven-pipelineNeutral, Google Cloud
Static site behind a CDNVisitors resolve a name through DNS and reach a content delivery network with a certificate, which serves files from a storage bucket that a build pipeline updates and clears from the cache.static-site-cdnNeutral, AWS
Data lake and analyticsSources feed an ingestion stage into a raw zone, a processing stage cleans the data into a curated zone, and a warehouse serves analysts through dashboards, with a catalog that describes the datasets.data-lake-analyticsNeutral, Google Cloud
Multi-region failoverA global routing service sends users to a primary region and fails over to a standby region, which holds replicated data and an identical stack.multi-region-failoverNeutral, AWS
CI/CD delivery pipeline with an approval gateA commit is built, tested, scanned, and stored as an image, then deployed to staging, held for an approval, and released to production.ci-cd-delivery-pipelineNeutral, Azure
Sign-in with an authorization code and proof keyA browser app signs a person in through an identity provider with the authorization code flow and a proof key, calls a backend API with the access token, and refreshes it when it expires.sign-in-token-flowNeutral
Multi-tenant application schemaOrganizations own projects and an audit log, and users join organizations through a memberships table that carries a role.database-schema-starterNeutral

Every id is stable. Tools and links use it, so it never changes.

Each pattern is drawn below in its neutral flavour, with its slots. The defaults are placeholders: documentation address ranges such as 192.0.2.0/24 and generic names such as web-tier.

Three-tier network behind load balancers

An office network joins a cloud network through a VPN gateway, and three tiers each put a load balancer in front of a redundant set of machines.

When to use it. Start here when the request is a classic web, application, and data layering inside a private network, especially when an office or data center connects to it. It shows what each tier holds, where the redundancy is, and the one way operators get in.

Id and flavours. three-tier-network, drawn below in its neutral flavour. It also comes in: Azure.

Three-tier network behind load balancers: 16 nodes, 15 connections. An office network reaches a cloud network through a VPN gateway. Inside it, a web tier, an application tier, and a data tier each put a load balancer in front of a redundant set of three machines. Operators reach the machines only through a management subnet.
SlotDefaultWhat goes there
officeOffice networkThe network on your side of the link: an office, a data center, or a branch.
workstationsStaff workstationsWho or what uses the system from the office side.
office-gatewayOffice gatewayThe router or firewall that ends the link on your side.
linkGateway subnetThe subnet that holds the cloud end of the link.
link-address10.0.0.0/27The address range of that subnet, as a plain sample value.
vpn-gatewayVPN gatewayThe cloud end of the link between the office and the cloud network.
cloudCloud sideThe name of the cloud network that everything else sits in.
cloud-address10.0.0.0/16The address range of the whole cloud network.
web-tierWeb tierThe first tier, which users reach.
web-address10.0.1.0/24The address range of the web tier.
app-tierApplication tierThe middle tier, which runs the application code.
app-address10.0.2.0/24The address range of the application tier.
data-tierData tierThe last tier, which holds the data.
data-address10.0.3.0/24The address range of the data tier.
load-balancerLoad balancerThe name of the balancer in front of each tier.
web-machineWebWhat a machine of the web tier is called; a number follows it.
app-machineAppWhat a machine of the application tier is called; a number follows it.
data-machineDataWhat a machine of the data tier is called; a number follows it.
web-setWeb machinesThe name of the redundant set in the web tier.
app-setApplication machinesThe name of the redundant set in the application tier.
data-setData machinesThe name of the redundant set in the data tier.
managementManagement subnetThe subnet operators use to reach the machines.
management-address10.0.4.0/27The address range of the management subnet.
jump-hostJump hostThe one machine operators sign in to.

Keep. Keep the order of the tiers, the edge from the middle machine of one tier to the load balancer of the next (it keeps the tiers level), the three overlays, and direction=down. Keep every machine in a tier as a member of that tier's overlay.

Rename. Rename the tiers, the machines, and the address ranges through the slots. Change the number of machines by adding a node, an edge from the load balancer, and the member id in the overlay, in all three places. Swap the generic icons for a provider's with the flavour you pick.

Split. Past about four machines in a tier, or a fourth tier, draw the tier alone in its own diagram and keep one machine of it here. Draw the management and monitoring paths in a second diagram if they pull in more than two nodes.

Two-zone network with a replicated database

A network spans two availability zones, each with a public, a private, and an isolated subnet, joined by one balancer set, one scaling group, and a replicated database.

When to use it. Start here when the request is a network that survives the loss of a zone: public subnets for the balancers, private subnets for the servers, isolated subnets for the data. It shows which resources are per zone, which span both, and how the data is kept in step.

Id and flavours. two-zone-network, drawn below in its neutral flavour. It also comes in: AWS.

Two-zone network with a replicated database: 8 nodes, 8 connections. Traffic enters through an internet gateway and reaches load balancers in the public subnets of two availability zones. Each balancer sends it to an application server in a private subnet, and the two servers form one scaling group. Each server writes to a database in an isolated subnet, and the primary database replicates to the replica in the other zone.
SlotDefaultWhat goes there
internetInternetWhere the traffic comes from.
cloudCloudThe outermost frame: the provider cloud, or your account in it.
gatewayInternet gatewayThe gateway that connects the network to the internet.
networkApplication networkThe private network that holds both zones.
network-address10.0.0.0/16The address range of the network, as a plain sample value.
zone-aZone AThe name of the first availability zone.
zone-bZone BThe name of the second availability zone.
public-aPublic subnet AThe public subnet of the first zone.
public-a-address10.0.0.0/24The address range of that subnet.
public-bPublic subnet BThe public subnet of the second zone.
public-b-address10.0.10.0/24The address range of that subnet.
private-aPrivate subnet AThe private subnet of the first zone, which holds the application server.
private-a-address10.0.1.0/24The address range of that subnet.
private-bPrivate subnet BThe private subnet of the second zone, which holds the application server.
private-b-address10.0.11.0/24The address range of that subnet.
isolated-aIsolated subnet AThe isolated subnet of the first zone, which holds the database.
isolated-a-address10.0.2.0/24The address range of that subnet.
isolated-bIsolated subnet BThe isolated subnet of the second zone, which holds the database.
isolated-b-address10.0.12.0/24The address range of that subnet.
balancerLoad balancerThe name of the balancer; a zone letter follows it on each node, and it names the dashed set that spans both zones.
serverApplication serverWhat the server in each private subnet is called; a zone letter follows it.
scalingScaling groupThe name of the dashed set that spans the servers of both zones.
primaryPrimary databaseThe database that takes the writes, in the first zone.
replicaReplica databaseThe database that follows the primary, in the second zone.
replicationreplicationWhat the dotted link between the two databases carries.

Keep. Keep both zones as siblings with the same three subnets in the same order, one node in each subnet, and the two dashed sets: they are what shows the balancer and the scaling group span both zones. Keep the replication link between the two databases.

Rename. Rename the zones, subnets, and resources through the slots, and replace the sample address ranges with the real ones. Give a subnet more than one node by adding nodes inside it and edges to them; add the new servers to the scaling set's members.

Split. Past about three nodes in a subnet, or a third zone, draw one zone alone in a second diagram and show only the balancer, one server, and the database here. Draw the outbound path (a NAT gateway and the routes) in its own diagram.

Hub and spoke network

A hub network with a firewall and shared services links an office to several isolated spoke networks, so all traffic between them passes one place.

When to use it. Start here when several workloads need their own networks but share connectivity, security, and services: each workload gets a spoke, and the hub holds what they share. It shows that spokes reach each other and the office only through the hub firewall.

Id and flavours. hub-and-spoke-network, drawn below in its neutral flavour. It also comes in: Azure.

Hub and spoke network: 11 nodes, 10 connections. An office network reaches a hub network through a VPN gateway. Every packet between the office, the shared services, and the three spoke networks passes the hub firewall. Each spoke holds one workload and its database, and spokes never connect to each other directly.
SlotDefaultWhat goes there
staffStaffWho uses the workloads from the office.
officeOffice networkThe network on your side of the link.
office-gatewayOffice gatewayThe router or firewall that ends the link on your side.
cloudCloud sideThe name of the frame around the hub and the spokes.
hubHub networkThe shared network every spoke connects through.
hub-address10.0.0.0/22The address range of the hub, as a plain sample value.
vpn-gatewayVPN gatewayThe cloud end of the link to the office.
firewallCentral firewallThe firewall every route between networks passes.
sharedShared servicesThe services every spoke uses, such as name resolution and directory.
spoke-aSpoke AThe name of the first spoke network.
spoke-a-address10.1.0.0/20The address range of the first spoke.
spoke-bSpoke BThe name of the second spoke network.
spoke-b-address10.2.0.0/20The address range of the second spoke.
spoke-cSpoke CThe name of the third spoke network.
spoke-c-address10.3.0.0/20The address range of the third spoke.
workload-aOrders applicationThe workload that runs in the first spoke.
workload-bReporting applicationThe workload that runs in the second spoke.
workload-cPartner portalThe workload that runs in the third spoke.
databaseDatabaseThe database each spoke keeps for its workload.

Keep. Keep every spoke connected to the hub firewall and to nothing else outside its own group: that is what the pattern says. Keep the hub in its own tone, and keep the office behind the gateway.

Rename. Rename the spokes after the workloads or teams that own them, and give each its real address range. Add a spoke by copying one group, its two nodes, and its two edges.

Split. Past about five spokes, draw the hub with two spokes here and list the others in a table, or draw a second hub for a second region in its own diagram.

Web application on a cloud

A single-page app is served through a CDN, backed by an API on a hosting plan, a database, a queue and worker, identity, storage, a delivery pipeline, and monitoring.

When to use it. Start here when the request is a typical web application and the reader needs to see every managed service around it: where files live, where code runs, how users sign in, how slow work is queued, and how changes ship. It is the usual first diagram of a cloud system.

Id and flavours. web-app-on-cloud, drawn below in its neutral flavour. It also comes in: Azure.

Web application on a cloud: 12 nodes, 12 connections. Visitors load a single-page app from storage through a content delivery network and sign in through an identity service. The app calls an API on an application plan, which stores uploads, reads a database, and hands slow work to a queue that a background worker drains. A pipeline builds and deploys the API, and a monitoring service collects telemetry.
SlotDefaultWhat goes there
visitorsVisitorsWho uses the application.
visitors-subBrowsersA short second line for the visitors, such as the kind of client.
edgeEdgeThe name of the group in front of the application.
cdnContent deliveryThe content delivery network that serves files and forwards API calls.
sign-inSign-inThe name of the group that holds the identity service.
identityIdentity serviceThe service that signs users in and issues tokens.
storageStorageThe name of the group that holds the stored files.
siteWeb app filesThe files of the single-page app.
uploadsUploadsWhere files that users upload are kept.
planApplication planThe name of the hosting plan that runs the API.
apiOrders APIThe service the app calls; name it for what it does.
messagingMessagingThe name of the group that holds the queue.
queueJob queueThe queue the API puts slow work on.
workerBackground workerThe function that drains the queue.
databaseDatabaseWhere the application keeps its records.
deliveryDelivery pipelineThe name of the group that builds and deploys the API.
sourceSource codeWhere the code lives.
buildBuild pipelineThe step that builds and deploys the image.
monitoringMonitoringThe name of the group that watches the application.
telemetryMetrics and logsThe service that collects what the API reports.

Keep. Keep one group for each concern (edge, sign-in, storage, hosting plan, messaging, delivery, monitoring), the queue between the API and the worker as a dotted link, and the deploy link from the pipeline to the API. Keep direction=down.

Rename. Rename the services for what the application does, and the stack marks for its technologies (up to three on a node). Add a node to a group for a second service of the same kind, with an edge from the node that uses it.

Split. Past about 20 nodes, move the data stores and the queue into a second diagram that starts at the API, and keep only the API here. Draw the pipeline alone when it has more than three steps.

Serverless API

A client calls an API gateway that checks sign-in and routes to three functions, which keep records in a managed database and files in object storage.

When to use it. Start here when the request is a small HTTP API built from managed services with no servers to run: a gateway, short-lived functions, a managed database, and a bucket. It shows where sign-in is checked and where telemetry goes. Start from the three-tier network pattern instead when the services run on machines you manage.

Id and flavours. serverless-api, drawn below in its neutral flavour. It also comes in: AWS, Google Cloud.

Serverless API: 9 nodes, 10 connections. A client calls an API gateway, which checks the caller with a sign-in service and routes each request to one of three functions. The functions keep records in a managed database and files in object storage, and send logs and metrics to monitoring.
SlotDefaultWhat goes there
clientClient appThe browser, mobile app, or program that calls the API.
client-subWeb or mobileA second line that says what kind of client it is.
gatewayOrders APIThe public name of the API that the gateway fronts.
path/ordersThe base path of the API, shown on the routes from the gateway.
sign-inSign-inThe name of the group that holds the identity service.
authUser directoryThe service that holds users and issues the tokens the gateway checks.
functionsFunctionsThe name of the group that holds the three request handlers.
fn-listList ordersThe function that returns many records.
fn-getGet orderThe function that returns one record.
fn-createCreate orderThe function that stores a new record and its file.
dataData storesThe name of the group that holds the database and the object storage.
databaseOrders databaseThe managed database that keeps the records.
storageOrder filesThe object storage that keeps uploaded files.
monitoringMonitoringThe name of the group that holds the telemetry service.
monitorLogs and metricsThe service that collects logs, metrics, and traces.

Keep. Keep the order of the groups (functions, sign-in, data stores, monitoring), the order of the functions (create, list, get), the sign-in check as the last edge from the gateway, the one dotted telemetry edge, which stands for every function, and direction=down. Keep the database and the storage in one group, because a group for each makes the arrows from the functions bunch at one point.

Rename. Rename the functions, the database, and the storage through the slots. Add a function by adding a node in the functions group, an edge from the gateway, and an edge to what it uses. Pick the aws or gcp flavour to swap the generic glyphs for that provider's icons.

Split. Past about five functions, draw the functions as one node here and give each route group its own diagram. Draw a deployment pipeline in a second diagram.

Microservices behind an API gateway

Clients call one API gateway that checks identity and routes to small services, which talk to each other through a message bus and each keep their own database.

When to use it. Start here when the request is a system split into small services that own their data: one public entry point, a sign-in check, and events between services instead of shared tables. It shows who may be called from outside and who only reacts to events. Start from the serverless API pattern instead when the services are short-lived functions.

Id and flavours. microservices-gateway, drawn below in its neutral flavour. It also comes in: AWS, Azure, Google Cloud.

Microservices behind an API gateway: 10 nodes, 9 connections. Client apps call one API gateway, which checks each caller with an identity provider and routes the request to a catalog service or a booking service. The booking service publishes an event to a message bus, and a billing service reacts to it. Every service keeps its own database, and no service reads another service's database.
SlotDefaultWhat goes there
clientsClient appsThe browsers, mobile apps, or programs that call the API.
clients-subWeb and mobileA second line that says what kind of client it is.
gatewayPublic APIThe public name of the API that the gateway fronts.
catalog-path/catalogThe path the gateway routes to the catalog service.
booking-path/bookingsThe path the gateway routes to the booking service.
sign-inSign-inThe name of the group that holds the identity provider.
identityIdentity providerThe service that holds users and issues the tokens the gateway checks.
public-servicesPublic servicesThe name of the group of services the gateway exposes.
catalogCatalog serviceThe service that answers read requests for the things you offer.
bookingBooking serviceThe service that accepts requests and publishes an event for each one.
messagingMessagingThe name of the group that holds the message bus.
busMessage busThe topic or bus that carries events from one service to the others.
eventbooking createdThe event the booking service publishes and the billing service reads.
internal-servicesInternal servicesThe name of the group of services that no client calls directly.
billingBilling serviceThe service that reacts to events and has no public route.
catalog-databaseCatalog databaseThe database that only the catalog service reads and writes.
booking-databaseBooking databaseThe database that only the booking service reads and writes.
billing-databaseBilling databaseThe database that only the billing service reads and writes.

Keep. Keep one database for each service and no edge from a service to another service's database, because that is what the pattern says. Keep the dotted edges through the message bus, the public and internal groups, the identity check as an edge from the gateway only, and direction=down.

Rename. Rename the services, the databases, the routes, and the event through the slots. Add a public service by adding a node in the public group, an edge from the gateway, and a database with an edge from the service. Pick the aws, azure, or gcp flavour to swap the generic glyphs for that provider's icons.

Split. Past about five services, draw the gateway and the public services in one diagram and give each group of related services its own, with the bus shown as an external node. Draw tracing, deployment, and the service mesh in separate diagrams.

Container platform

A delivery pipeline pushes images to a registry, and a managed cluster runs three services on a redundant node pool behind an ingress, with configuration, secrets, and monitoring.

When to use it. Start here when the request is a Kubernetes or managed container platform: where images come from, how traffic reaches the services, and what the services depend on. It does not show networks, multiple environments, or the data stores the services use.

Id and flavours. container-platform, drawn below in its neutral flavour. It also comes in: Google Cloud.

Container platform: 11 nodes, 10 connections. A delivery pipeline builds container images and pushes them to a registry. A managed cluster pulls the images and runs three services on a redundant node pool behind an ingress. The API service reads configuration and secrets, and a monitoring service collects metrics.
SlotDefaultWhat goes there
usersUsersWho sends traffic to the platform from outside.
pipelineDelivery pipelineThe name of the group that builds and publishes images.
repositorySource repositoryWhere the application code lives.
buildBuild and testThe pipeline stage that builds an image and runs its tests.
registryImage registryThe store that holds the built container images.
clusterManaged clusterThe name of the container cluster that runs the services.
cluster-detailManaged control planeA short fact about the cluster, such as who runs its control plane or its size.
ingressIngressThe entry point that routes outside traffic to the services.
node-poolNode poolThe name of the redundant set of machines the services run on.
webWeb serviceThe first service behind the ingress, for example the user interface.
apiAPI serviceThe middle service, which reads configuration and secrets.
adminAdmin serviceThe third service behind the ingress.
configConfigurationThe settings the services read when they start.
secretsSecretsThe credentials and keys the services read.
observabilityMonitoringThe name of the group that watches the cluster.
monitorMonitoring serviceThe service that collects metrics and raises alerts.

Keep. Keep the order from pipeline to registry to cluster to monitoring, the three services as the members of the node pool overlay, and direction=down. Keep a label on both the push edge and the traffic edge, or on neither, so the registry stays level with the first service. Keep the dotted edges: the image pull and the metrics are asynchronous.

Rename. Rename the services, the cluster, and the pipeline stages through the slots. Add a service by adding a node, an edge from the ingress, and its id in the overlay members. The pull and metrics edges each stand for every service. Swap the generic icons for a provider's with the flavour you pick.

Split. Past about five services, draw the cluster alone and show one service of it here. Draw the data stores, the network, and each environment in their own diagrams.

Queue and worker pool

A web API puts jobs on a queue, a pool of workers takes them and writes results to a database, failed jobs go to a dead-letter queue, and an alarm watches the queue depth.

When to use it. Start here when the request is background work: a request is accepted quickly and the slow part runs later on workers that can scale out. It shows the hand-off through a queue, the redundant pool, the retry path, and the alarm that tells you the workers fall behind. Start from the event-driven pipeline pattern instead when many independent consumers react to the same event.

Id and flavours. queue-worker, drawn below in its neutral flavour. It also comes in: AWS.

Queue and worker pool: 9 nodes, 8 connections. A client sends a request to a web API, which puts a job on a queue instead of doing the work itself. A pool of three workers takes jobs from the queue and writes the results to a database. A job that still fails after its retries goes to a dead-letter queue, and an alarm watches the queue depth.
SlotDefaultWhat goes there
clientClient appThe browser, mobile app, or program that submits work.
submitPOST /jobsThe request the client sends to submit a job.
apiWeb APIThe service that accepts a request and enqueues a job.
messagingMessagingThe name of the group that holds the job queue.
queueJob queueThe queue that holds jobs until a worker takes one.
poolWorkersThe name of the redundant set of workers. Keep it short, about eight characters, so its tab stays clear of the first arrow.
workerWorkerWhat a worker is called; a number follows it.
dataResultsThe name of the group that holds the database.
databaseResults databaseThe database that keeps what the workers produce.
dlqDead-letter queueThe queue that keeps jobs that failed after every retry.
retries3How many tries a job gets before it moves to the dead-letter queue, as a number.
alarmQueue depth alarmThe alarm that fires when too many jobs wait in the queue.

Keep. Keep the overlay around the workers, and the one edge from the pool to the database and the one to the dead-letter queue, because each stands for every worker. Keep the edge from the queue to the alarm without a label, because a label pushes the alarm one row below the pool. Keep the pool name short, because a long name makes a tab wide enough to cover the first arrow. Keep direction=down.

Rename. Rename the services, the queue, and the stores through the slots, and set the retry count in the retries slot. Change the number of workers by adding a node, a dotted edge from the queue, and the member id in the overlay, in all three places. Pick the aws flavour to swap the generic glyphs for AWS icons.

Split. Past about five workers, keep three nodes and say how many more in the pool name. Draw the scaling rules and what the alarm triggers, such as paging or adding workers, in a second diagram.

Event-driven pipeline

Several services publish events to an event bus, three independent consumers react to them, and events that keep failing go to a dead-letter queue.

When to use it. Start here when the request is publish and subscribe: services that emit events without knowing who listens, and consumers that work on their own. It shows the fan-out from one bus, the asynchronous links, and where failed events end up. Start from the queue and worker pattern instead when one service hands a job to a pool of workers.

Id and flavours. event-driven-pipeline, drawn below in its neutral flavour. It also comes in: Google Cloud.

Event-driven pipeline: 11 nodes, 10 connections. Three services publish events to an event bus. Three independent consumers react: one filters the events and archives them to storage, one processes them into a database, and one sends notifications. Events that keep failing go to a dead-letter queue. Every link out of a producer or the bus is asynchronous.
SlotDefaultWhat goes there
producersProducersThe name of the group that holds the services that publish events.
producer-1Orders serviceThe first service that publishes events.
producer-2Payments serviceThe second service that publishes events.
producer-3Inventory serviceThe third service that publishes events.
messagingMessagingThe name of the group that holds the event bus.
busEvent busThe topic or bus that receives every event and hands it to each consumer.
dlqDead-letter queueThe queue that keeps events a consumer could not handle after its retries.
consumersConsumersThe name of the group that holds the independent consumers.
archiverArchive filterThe consumer that keeps only matching events and archives them.
processorEvent processorThe consumer that transforms every event and stores the result.
notifierNotifierThe consumer that turns some events into notifications.
dataData storesThe name of the group that holds the archive and the database.
archiveEvent archiveThe object storage that keeps archived events.
databaseEvents databaseThe database that keeps processed events.
externalThird partyThe name of the group for the service you call but do not run.
emailEmail providerThe outside service that delivers the notifications.

Keep. Keep the dotted arrows from the producers to the bus and from the bus to each consumer, because they say the links are asynchronous, and keep the edge from the bus to the dead-letter queue. Keep the second line of the bus node about as long as it is, because a narrow node makes the three arrows into it bunch at one point.

Rename. Rename the services, the consumers, and the stores through the slots. Add a consumer by adding a node in the consumers group, a dotted edge from the bus, and an edge to what it writes. Pick the gcp flavour to swap the generic glyphs for Google Cloud icons.

Split. Past four producers or four consumers, draw the producers as one node and give each consumer its own diagram, or split by event type. Draw how dead letters are inspected and replayed in a second diagram.

Static site behind a CDN

Visitors resolve a name through DNS and reach a content delivery network with a certificate, which serves files from a storage bucket that a build pipeline updates and clears from the cache.

When to use it. Start here when the request is a static website, a documentation site, or a single-page app served from object storage through a CDN. It shows the name lookup, the HTTPS certificate, the origin, and how new files reach visitors. It does not show dynamic back ends or APIs behind the site.

Id and flavours. static-site-cdn, drawn below in its neutral flavour. It also comes in: AWS.

Static site behind a CDN: 8 nodes, 8 connections. Visitors resolve the site name through DNS and reach a content delivery network that holds a TLS certificate. The network fetches files from a storage bucket that is its origin. A publishing pipeline builds the site, uploads the new files to the bucket, and clears the network cache.
SlotDefaultWhat goes there
visitorsVisitorsWho opens the site: browsers, readers, or customers.
edgePublic edgeThe name of the group that faces visitors.
dnsDNS zoneThe service that turns the site name into the address of the delivery network.
certTLS certificateThe certificate that lets the delivery network answer over HTTPS.
cdnContent delivery networkThe cache that serves the files from locations near visitors.
originOriginThe name of the group that holds the source of the files.
bucketSite bucketThe object storage that holds the built site.
bucket-detailStatic filesA short second line for the bucket, such as what it holds.
pipelinePublishing pipelineThe name of the group that builds and publishes the site.
repositorySource repositoryWhere the site source lives.
buildBuild siteThe step that turns the source into static files.
publishPublish filesThe step that uploads the files and clears the cache.
publish-detailThen clears the cacheA short second line that says what happens after the upload.

Keep. Keep the visitor path as the right column and the pipeline as the left column, the dotted edge from the publish step to the delivery network, and direction=down. Keep one label on each of the two chains that lead to the middle row, so the publish step stays level with the delivery network.

Rename. Rename the services, the bucket, and the pipeline steps through the slots. Add a step to the pipeline by adding a node and an edge before the publish step, and label no more than one edge in the chain. Swap the generic icons for a provider's with the flavour you pick.

Split. Add an API or a function behind the delivery network in a second diagram, and keep this one for the static path. Draw several sites, regions, or environments one per diagram, and show the extra origin here only when it changes how visitors are served.

Data lake and analytics

Sources feed an ingestion stage into a raw zone, a processing stage cleans the data into a curated zone, and a warehouse serves analysts through dashboards, with a catalog that describes the datasets.

When to use it. Start here when the request is a data platform: where data comes from, how it is landed and cleaned, and how people query it. It shows the raw and curated zones as separate stores. It does not show orchestration, access control, or machine learning workloads.

Id and flavours. data-lake-analytics, drawn below in its neutral flavour. It also comes in: Google Cloud.

Data lake and analytics: 11 nodes, 10 connections. An application database, event streams, and file drops feed an ingestion stage that lands data in a raw zone. A processing stage cleans it into a curated zone, a warehouse loads the curated data, and analysts read it through dashboards. A data catalog describes the curated datasets.
SlotDefaultWhat goes there
sourcesData sourcesThe name of the group that holds everything the data comes from.
app-dbApplication databaseThe operational database that the business applications write to.
eventsEvent streamsThe continuous feeds of events, such as clicks, sensor readings, or messages.
filesFile dropsFiles that partners or other teams deliver on a schedule.
ingestIngestionThe stage that reads every source and lands the data unchanged.
lakeData lakeThe name of the group that holds the storage zones and the processing between them.
raw-zoneRaw zoneThe name of the zone that keeps the data exactly as it arrived.
raw-detailData as receivedA short line under the raw zone name that says what the zone guarantees.
raw-storeRaw filesThe storage that holds the raw data.
processClean and transformThe stage that validates, cleans, and reshapes the raw data.
curated-zoneCurated zoneThe name of the zone that holds trusted, ready-to-use data.
curated-detailCleaned and typedA short line under the curated zone name that says what the zone guarantees.
curated-storeCurated tablesThe storage that holds the curated data.
warehouseWarehouseThe analytical database that answers queries over the curated data.
dashboardsDashboardsThe reports and charts that analysts open.
analystsAnalystsThe people who read the data and ask questions of it.
catalogData catalogThe register that describes each dataset: its owner, its meaning, and its schema.

Keep. Keep the single column from ingestion to analysts, the two zones as groups inside the data lake group, and direction=down. Keep the catalog as a leaf with one dotted edge from the curated store, because an edge into the raw zone pulls the whole column out of line.

Rename. Rename the sources, the stages, the zones, and the stores through the slots. Add a source by adding a node in the sources group and an edge to the ingestion stage. Swap the generic icons for a provider's with the flavour you pick.

Split. Past about five sources, group them by kind and show one node per kind. Draw orchestration, access control, and streaming paths in their own diagrams, and add a third zone only if the picture stays one column.

Multi-region failover

A global routing service sends users to a primary region and fails over to a standby region, which holds replicated data and an identical stack.

When to use it. Start here when the request is to survive the loss of a whole region: it shows which region serves normally, what switches, and what is copied. Use it to discuss recovery time, because the replication links are the part that decides how much data a failover loses.

Id and flavours. multi-region-failover, drawn below in its neutral flavour. It also comes in: AWS.

Multi-region failover: 8 nodes, 8 connections. Users reach a global routing service that sends traffic to the primary region and switches to the standby region when health checks fail. Each region runs a load balancer, application servers, and a database, and the primary region replicates its database to the standby.
SlotDefaultWhat goes there
usersUsersWho uses the application.
routingGlobal routingThe service that chooses a region by health, such as DNS routing or a global load balancer.
routing-subHealth-checkedA short second line for the routing service.
primaryPrimary regionThe name of the region that serves traffic normally.
primary-subActiveA short second line for the primary region.
standbyStandby regionThe name of the region that takes over.
standby-subPassiveA short second line for the standby region.
balancerLoad balancerThe balancer in front of the servers of each region.
serversApplication serversThe servers of each region.
databasePrimary databaseThe database in the primary region, which takes the writes.
replicaReplica databaseThe database in the standby region, which follows the primary.
replicationreplicationWhat the dotted link between the two databases carries.

Keep. Keep both regions with the same three nodes in the same order, the dashed failover link beside the solid normal link, and the dotted replication link between the two databases, which stay side by side.

Rename. Rename the regions and the services through the slots. Keep one replicated pair in view: a second pair draws its link across the first, so put it in a second diagram.

Split. Past about five nodes in a region, draw one region alone in its own diagram and keep a single node per region here. Draw the failover procedure as a sequence diagram instead.

CI/CD delivery pipeline with an approval gate

A commit is built, tested, scanned, and stored as an image, then deployed to staging, held for an approval, and released to production.

When to use it. Start here for a continuous integration and delivery flow with a manual gate before production. It shows which steps belong to the pipeline, which environments hold running code, and where people are notified. Draw a different diagram for a pipeline that releases straight to production or for one with many parallel jobs.

Id and flavours. ci-cd-delivery-pipeline, drawn below in its neutral flavour. It also comes in: Azure.

CI/CD delivery pipeline with an approval gate: 12 nodes, 11 connections. A commit is built, tested, and scanned, and the image is stored in a registry. It is deployed to staging, held until a reviewer approves, and then deployed to production. The security scan and the approval request notify people.
SlotDefaultWhat goes there
pipelineDelivery pipelineThe name of the pipeline that builds and checks the code.
sourceSource repositoryWhere the code lives and where a change starts.
source-noteCommit to the main branchA short second line for the repository: what starts the pipeline.
buildBuildThe step that compiles the code and packages it.
build-noteCompile and packageA short second line for the build step.
testTestThe step that runs the automated tests.
test-noteUnit and integrationA short second line for the test step.
scanSecurity scanThe step that checks the code and its dependencies for known problems.
scan-noteCode and dependenciesA short second line for the scan step.
registryImage registryWhere the built image is stored and versioned.
registry-noteVersioned imagesA short second line for the registry.
alertsSecurity channelWho hears about scan findings: a chat channel or a mailing list.
stagingStagingThe name of the pre-production environment.
deploy-stagingDeploy to stagingThe step that puts the image on the staging environment.
staging-appStaging appThe application as it runs in staging.
approvalRelease approvalThe manual gate between staging and production.
approval-noteA reviewer signs offA short second line for the approval: who decides.
reviewersRelease channelWho is asked to approve: a chat channel or a mailing list.
productionProductionThe name of the live environment.
deploy-productionDeploy to productionThe step that puts the approved image on production.
production-appProduction appThe application as it runs in production.

Keep. Keep the order of the steps, the group around the pipeline steps, one group for each environment, and the approval node outside both environments. Keep the dotted arrows for notifications, because they mark a message that nothing waits for.

Rename. Rename the steps, environments, and channels through the slots. Add a step such as a lint or a performance test by adding a node and an edge between its neighbours, inside the pipeline group. Add an environment by copying the staging group and its two edges.

Split. Past about four steps in the pipeline or a third environment, draw the pipeline alone in one diagram and the environments with their rollout in another. Draw rollback and failure paths in a second diagram.

Sign-in with an authorization code and proof key

A browser app signs a person in through an identity provider with the authorization code flow and a proof key, calls a backend API with the access token, and refreshes it when it expires.

When to use it. Start here for the sign-in of a single-page or mobile app that has no client secret and calls its own backend API. It shows where the proof key is made and checked, what the API verifies, and how an expired token turns into a refresh and a retry. Draw a different diagram for a server-rendered app that keeps a client secret, or for machine-to-machine access with no person.

Id and flavours. sign-in-token-flow, drawn below in its neutral flavour. It has no provider flavour.

Sign-in with an authorization code and proof key: 4 participants. A browser app sends a person to an identity provider with a proof key challenge, receives a code, and exchanges it for tokens. It calls a backend API with the access token and uses the refresh token when the access token expires.
SlotDefaultWhat goes there
personPersonWho signs in.
person-noteAt the browserA short second line for the person.
identity-providerIdentity providerThe service that signs the person in and issues tokens.
identity-provider-noteIssues the tokensA short second line for the identity provider.
appBrowser appThe app that has no client secret and starts the sign-in.
app-notePublic clientA short second line for the app.
apiBackend APIThe service that accepts the access token and returns data.
api-noteChecks every tokenA short second line for the API.
api-dataDataWhat the API returns when the token is accepted.

Keep. Keep the order of the messages: the verifier and challenge are made before the redirect, the code travels back by redirect, and only the exchange carries the verifier. Keep the alt block, because the expired branch is the part readers look for, and keep the retry after the refresh.

Rename. Rename the four participants, their second lines, and the data the API returns through the slots. To add a scope or an audience, change the message text by hand. Add a second API as a fifth participant to the right of the first, with its own request and response.

Split. Draw sign-out, a revoked refresh token, and a first sign-in with consent as separate diagrams. Past five participants, draw the backend services on their own in a second diagram and keep one participant for them here.

Multi-tenant application schema

Organizations own projects and an audit log, and users join organizations through a memberships table that carries a role.

When to use it. Start here for a software-as-a-service product where several customers share one database and every row belongs to an organization. It shows the join table for a many-to-many link with a role, the foreign key that scopes each row to its tenant, and an append-only log. Draw a different schema when each customer has its own database or when users belong to no organization.

Id and flavours. database-schema-starter, drawn below in its neutral flavour. It has no provider flavour.

Multi-tenant application schema: 5 tables, 4 relations. Organizations own projects and an audit log. Users join organizations through memberships, a join table that stores each user's role. Every tenant table carries the organization id.
SlotDefaultWhat goes there
organizationsOrganizationsThe label of the tenant table: the customer, team, or account that owns data.
organizations-noteThe tenant that owns dataA short second line for the tenant table.
usersUsersThe label of the table of people who sign in.
users-notePeople who sign inA short second line for the users table.
membershipsMembershipsThe label of the join table between users and tenants.
memberships-noteJoins users to organizationsA short second line for the join table; say what the role controls.
projectsProjectsThe label of the main business table that belongs to a tenant, such as projects, workspaces, or sites.
projects-noteWork owned by one organizationA short second line for that business table.
audit-logAudit logThe label of the append-only table that records who did what.
audit-log-noteAppend-only record of changesA short second line for the audit table.

Keep. Keep the organization_id foreign key on every table that holds tenant data, the pair of foreign keys in the join table, and the nullable flags on columns that are empty for a good reason. Keep the audit table append-only, and keep actor_id without a foreign key so the history survives when a user is deleted.

Rename. Rename the tables and their second lines through the slots. To rename a column, change it in the source by hand, in the table and in every relation that names it. Add business tables the same way projects is drawn: an id, an organization_id foreign key, and a relation to organizations.

Split. Past six tables, draw each area on its own: tenancy and access in one diagram, the business tables in another, and billing in a third. Keep organizations in each one so the foreign keys still have a parent.

5. Adapting a pattern

DoDo not
Rename through slots first, then edit the source for what slots cannot changeRewrite the source from scratch and lose the checked groups and icons
Keep the group tree: cloud, network, zones, tiers, and subnets carry the meaningFlatten groups to save space, or colour them by hand
Keep a replicated pair, such as a primary and a replica, as one pair in a diagramAdd a second replicated pair in the same diagram; draw a second diagram instead
Split a pattern at the line its Split note namesRaise the node count by shrinking text
Give every node the icon of its product, found with search_iconsInvent an icon name; validate_diagram rejects it with the nearest valid one
Run validate_diagram after every edit and fix each warningIgnore a warning because the picture looks fine

A pattern is a starting point, not a template to fill in blindly. If the request names a service that the pattern has no node for, add a node for it with its own icon. If the pattern has a node that the request does not mention, remove it.

See also

DocWhy
Cloud architectureGroup types, provider icons, and the icon pages behind every pattern
Writing diagrams with an agentThe validate-and-fix loop an agent follows
Writing diagramsThe whole language, kind by kind
Tool referencefind_pattern, get_pattern, draw_from_pattern, and the other tools
Language referenceEvery group type, overlay option, arrow, and diagnostic code