Architecture Diagram Instructions

Describe services and systems with boxes, groups, shapes, and icons, and link them with arrows. The editor arranges the diagram and routes its arrows automatically.

Get Started

This is a two-way editor: type source text to update the diagram, or edit the diagram on the canvas to update the source.

  1. Choose New > Architecture to start from a template, or put @architecture on the first non-blank, non-comment line. Copy a complete example using the icon below an image, then paste it into the source editor.
  2. Declare elements with box, give them optional quoted labels, and connect their ids with ->. End each arrow with a colon, followed by an optional label.
  3. On the canvas, drag from a box border onto another box, then confirm the arrow's label in the editor. Double-click a box or arrow to edit its text.
Web app and API inside a cloud group, connected to a database
⎘
@architecture direction right group- cloud "Cloud platform" { box web "Web app" box api "API service" #lightblue } box db "Database" web->api:REST calls api->db:orders\nand payments

Click an element to select only that element. Cmd/Ctrl-click adds or removes an element from the selection. Drag from empty canvas space to select fully enclosed boxes, containers and arrows; each selection rectangle replaces the previous selection. Existing box-border arrow creation and label-drag gestures keep their behavior.

Click empty space or press Escape to clear selection. Escape also cancels the current interaction. Press Delete to remove the selection and incident arrows; one Ctrl-Z restores the entire deletion. Deleting a container keeps its unselected contents and moves them up to the nearest remaining parent. Click in the source editor before using Delete to edit text.

See Editor Instructions for shared toolbar buttons, storage options, presentation modes, undo/redo, and source-editor shortcuts.

Architecture diagrams need Chrome or Edge 119, Firefox 120, Safari 18.2, or later; the IntelliJ plugin needs IntelliJ 2025.3.1 or later. An older browser, or a page that is not allowed to run WebAssembly, shows a message in place of the diagram; sequence diagrams are not affected.

Source Basics

Comments

⎘
# Comments may precede the mode marker @architecture direction right // Connect two automatically created boxes client->server:request

Title

Payment platform title above checkout and payments
⎘
@architecture title Payment platform direction up box checkout box payments checkout->payments:charge

Boxes and Labels

architecture boxes and labels example
⎘
@architecture direction right box gateway "API Gateway" box api "Main API\nPublic endpoint" box database gateway->api: api->database:

Groups and Nesting

nested architecture boxes and groups example
⎘
@architecture direction right group- cloud "Cloud" { box cluster "Cluster" { box api "API" box worker "Worker" } group- data "Data" { box primary "Primary DB" } } box client "Client" client->api: worker->primary:
An expanded Cloud group with a minus sign in its corner beside a collapsed Data group with a plus sign; the arrow to the hidden Primary DB ends on Data
⎘
@architecture direction right group- cloud "Cloud" { box api "API" box worker "Worker" } group+ data "Data" { box primary "Primary DB" } box client "Client" client->api: worker->primary:

Icons

architecture icon families example
⎘
@architecture direction right fontawesome6solid f0c2 solid "Cloud" fontawesome6regular f0f8 regular "Hospital" fontawesome6brands f09b brand "GitHub" materialdesignicons f01bc mdi "Store" solid->regular: regular->brand: brand->mdi:
Every built-in icon with its name below it, in rows
⎘
@architecture direction down icon actor actor icon ai ai icon balancer balancer icon boundary boundary icon browser browser icon cache cache icon client client icon cloud cloud icon control control icon database database icon datalake datalake icon email email icon entity entity icon file file icon firewall firewall icon gateway gateway icon globe globe icon identity identity icon mobile mobile icon monitor monitor icon person person icon queue queue icon schedule schedule icon server server icon storage storage icon stream stream icon vault vault icon warehouse warehouse icon worker worker layoutconstraint { actor, ai, balancer, boundary, browser, cache client, cloud, control, database, datalake, email entity, file, firewall, gateway, globe, identity mobile, monitor, person, queue, schedule, server storage, stream, vault, warehouse, worker }
architecture icon nested in a box container example
⎘
@architecture direction right box data "Data services" { materialdesignicons f01bc primary "Primary DB" } box api "API" api->data:query

Shapes

An actor, a boundary, a control, an entity and a database, each with its label below, joined by arrows
⎘
@architecture direction right actor customer "Customer" boundary web "Web UI" control checkout "Checkout" entity order "Order" database orders "Orders" #lightyellow customer->web: web->checkout: checkout->order: order->orders:

Arrows

architecture arrow directions and line styles example
⎘
@architecture direction down box client "Client" box api "API" box queue "Queue" client->api:request api-->queue:async event queue<-client:consume client<--api:response
Client and API joined by an arrow with a head at each end; API with an open-headed arrow to Queue, a line to Database, and a dashed line to Cache
⎘
@architecture direction right box client "Client" box api "API" box queue "Queue" box db "Database" box cache "Cache" client<->api:session api->>queue:event api--db:reads api---cache:may read

Choose an Arrow's Endpoint Sides

Request enters the API on its west side; query leaves its south side and enters the database on its north side
⎘
@architecture direction right box client "Client" box api "API" box database "Database" client(e)->(w)api:request api(s)->(n)database:query

Inferred, Parallel, and Self-Referencing Arrows

inferred, parallel, and self-referencing architecture arrows example
⎘
@architecture direction down box api "API" api->generated:inferred target api->api:retry api->generated:first event api-->generated:second event

Container Arrows

architecture arrows between containers and nested boxes example
⎘
@architecture direction right group- clients "Clients" { box web box mobile } group- platform "Platform" { box api box worker } clients->platform: web->api: mobile->worker:
clickable architecture arrow label example
⎘
@architecture direction down box docs "Documentation" box api "API" docs->api:<link:https://sequencediagram.org>Open API docs</link>

Element Styling

inline architecture box, group, and arrow styling example
⎘
@architecture direction down box api "API" #lightblue #blue;2;solid group- data "Data layer" #aliceblue #navy;2;dashed { box database "Database" #lightyellow #orange;2;solid } api-[#green;3;dashed]>database:query

Text Styling

architecture label font styling example
⎘
@architecture direction down box styled "**bold** //italic//\n++large++ --small--\n""monospaced"" ~~removed~~\nC\+\+" box formula "H<sub>2</sub>O and x<sup>2</sup>" styled->formula:
architecture label color, alignment, background, stroke, and word-wrap example
⎘
@architecture direction down box client "<color:#blue>Client</color>\n<size:18>larger text</size>\n<align:right>right aligned</align>" box server "<background:#yellow>Server</background>\n<difference><color:#white>contrast</color></difference>" client->server:<stroke:1:#red>outlined</stroke>\n<wordwrap:15>long label wraps automatically</wordwrap>

Named and Type-Based Styles

named and type-based architecture styles example
⎘
@architecture direction down style warning #mistyrose #red;2;solid,<color:#darkred>** boxstyle #whitesmoke #gray;1;solid groupstyle #aliceblue #blue;2;dashed arrowstyle #gray;1;dashed,<color:#gray> group- platform "Platform" { box api "API" box worker "Worker" ##warning } box audit "Audit" #lightyellow #orange;2;solid api->worker:default arrow worker-[##warning]>audit:warning arrow

Layout Direction

architecture layout direction up example
⎘
@architecture direction up box client "Client" box api "API" box database "Database" client->api: api->database:
architecture layout direction down example
⎘
@architecture direction down box client "Client" box api "API" box database "Database" client->api: api->database:
architecture layout direction right example
⎘
@architecture direction right box client "Client" box api "API" box database "Database" client->api: api->database:
architecture layout direction left example
⎘
@architecture direction left box client "Client" box api "API" box database "Database" client->api: api->database:

Automatic Routing

API reaches Database through Orders and through Payments; the arrows to and from Payments bend at right angles
⎘
@architecture direction right routing orthogonal box client "Client" box api "API" box orders "Orders" box payments "Payments" box database "Database" client->api:request api->orders: api->payments: orders->database: payments->database:
API reaches Database through Orders and through Payments; the arrows to and from Payments are S-curves
⎘
@architecture direction right routing curved box client "Client" box api "API" box orders "Orders" box payments "Payments" box database "Database" client->api:request api->orders: api->payments: orders->database: payments->database:
API reaches Database through Orders and through Payments; the arrows to and from Payments have a sloped segment
⎘
@architecture direction right routing polyline box client "Client" box api "API" box orders "Orders" box payments "Payments" box database "Database" client->api:request api->orders: api->payments: orders->database: payments->database:

Element Spacing

Compare the same diagram at compact, default, and roomy spacing:

Gateway connects to Orders and Payments with spacing 0.5
⎘
@architecture direction down hspacing 0.5 vspacing 0.5 box gateway box orders box payments gateway->orders: gateway->payments:
Gateway connects to Orders and Payments with default spacing 1
⎘
@architecture direction down hspacing 1 vspacing 1 box gateway box orders box payments gateway->orders: gateway->payments:
Gateway connects to Orders and Payments with spacing 1.5
⎘
@architecture direction down hspacing 1.5 vspacing 1.5 box gateway box orders box payments gateway->orders: gateway->payments:

Layer and Position

Ingress in the first layer, API first and Workers last in the middle layer, Archive in the last layer
⎘
@architecture direction down box ingress "Ingress" { layer first } box jobs "Workers" { position last } box api "API" { position first } box archive "Archive" { layer last } ingress->api:request ingress->jobs:dispatch api->archive:persist jobs->archive:complete

To keep two elements in the first layer together, give both layer first:

Web and Mobile share the first layer above the API
⎘
@architecture direction down box web "Web" { layer first position first } box mobile "Mobile" { layer first position last } box api "API" web->mobile:sign in web->api:browse mobile->api:browse

Cache shares the gateway's layer, Audit comes before it although the arrow points to Audit, and Payments comes after Orders:

Cache beside Gateway, Audit before Gateway, Payments after Orders
⎘
@architecture direction right box web "Web" box gateway "Gateway" box cache "Cache" { layer with gateway } box audit "Audit" { layer before gateway } box orders "Orders" box payments "Payments" { layer after orders } web->gateway:browse gateway->cache:read gateway->audit:log gateway->orders:order gateway->payments:pay

Payments comes after Orders, and Audit before both of them, all in one layer:

Gateway above Audit, Orders and Payments in one layer, in that order from left to right
⎘
@architecture direction down box gateway "Gateway" box orders "Orders" box payments "Payments" { position after orders } box audit "Audit" { position before orders,payments } gateway->orders:order gateway->payments:pay gateway->audit:log

C4 Architecture Examples

The C4 model describes a system at four levels: system context, containers, components, and code. Use the levels that help explain your system; you do not need all four for every project.

The examples below show the system context, containers, and components of one order platform. Each is a separate, complete diagram using ordinary architecture syntax. Types such as [Software system] and [Component: Java] are display labels, not special keywords.

System Context

Show the customer and external systems around the order platform. Keep this view focused on responsibilities, leaving implementation details for the next level.

Customer uses the Order platform, which takes payments through a Payment provider and sends confirmations through an Email service
⎘
@architecture title Order platform - System context direction down style system #1168bd #0b4884;1;solid,<color:#white> style external #777777 #555555;1;solid,<color:#white> fontawesome6solid f007 customer "Customer\n[Person]\nPlaces and tracks orders" box shop "Order platform\n[Software system]\nSells products online" ##system box payments "Payment provider\n[Software system]\nProcesses card payments" ##external box email "Email service\n[Software system]\nDelivers email" ##external customer-->shop:Places and tracks orders shop-->payments:Takes payments shop-->email:Sends order confirmations

Containers

Open up the order platform to show its web application, API, and database. The customer and payment provider stay outside its group. This view focuses on ordering and payment; email delivery is omitted. It shows applications and data stores, rather than deployment machines.

Order platform boundary contains a Web app, Orders API, and Orders database; a Customer uses the app and the API calls an external Payment provider
⎘
@architecture title Order platform - Containers direction down style container #438dd5 #2e6295;1;solid,<color:#white> style external #777777 #555555;1;solid,<color:#white> fontawesome6solid f007 customer "Customer\n[Person]\nPlaces and tracks orders" group- shop "Order platform [Software system]" { box web "Web app\n[Container: JavaScript]\nProvides the shopping UI" ##container box api "Orders API\n[Container: Java]\nPlaces and tracks orders" ##container box database "Orders database\n[Container: PostgreSQL]\nStores orders" ##container } box payments "Payment provider\n[Software system]\nProcesses card payments" ##external customer-->web:Uses\n[HTTPS] web-->api:Places and queries orders\n[JSON/HTTPS] api-->database:Reads and writes orders\n[SQL/TCP] api-->payments:Charges cards\n[JSON/HTTPS]

Components

Open up just the Orders API. Its components appear inside the API boundary, with the web app, database, and payment provider outside. Each component label explains its responsibility.

Orders API contains an Order controller, Order service, and Payment adapter, connected to the Web app, Orders database, and Payment provider
⎘
@architecture title Orders API - Components direction down style container #438dd5 #2e6295;1;solid,<color:#white> style component #85bbf0 #5f8dd3;1;solid,<color:#black> style external #777777 #555555;1;solid,<color:#white> box web "Web app\n[Container: JavaScript]\nProvides the shopping UI" ##container group- api "Orders API [Container: Java]" { box controller "Order controller\n[Component: Java]\nExposes order endpoints" ##component box orders "Order service\n[Component: Java]\nValidates and places orders" ##component box gateway "Payment adapter\n[Component: Java]\nCalls the payment provider" ##component } box database "Orders database\n[Container: PostgreSQL]\nStores orders" ##container box payments "Payment provider\n[Software system]\nProcesses card payments" ##external web-->controller:Places and queries orders\n[JSON/HTTPS] controller-->orders:Calls\n[Java] orders-->database:Reads and writes orders\n[JDBC] orders-->gateway:Requests payment\n[Java] gateway-->payments:Charges cards\n[JSON/HTTPS]

All levels in one diagram

Put the levels in one diagram with collapsible groups: the order platform is a group+ around its containers, and the Orders API a group+ around its components. Write each arrow at its deepest level; while its end is hidden, it ends on the collapsed group with its label.

Customer uses the collapsed Order platform, which charges cards through a Payment provider and sends order confirmations through an Email service
⎘
@architecture title Order platform - All levels direction down style container #438dd5 #2e6295;1;solid,<color:#white> style component #85bbf0 #5f8dd3;1;solid,<color:#black> style external #777777 #555555;1;solid,<color:#white> fontawesome6solid f007 customer "Customer\n[Person]\nPlaces and tracks orders" group+ shop "Order platform\n[Software system]\nSells products online" { box web "Web app\n[Container: JavaScript]\nProvides the shopping UI" ##container group+ api "Orders API\n[Container: Java]\nPlaces and tracks orders" { box controller "Order controller\n[Component: Java]\nExposes order endpoints" ##component box orders "Order service\n[Component: Java]\nValidates and places orders" ##component box gateway "Payment adapter\n[Component: Java]\nCalls the payment provider" ##component } box database "Orders database\n[Container: PostgreSQL]\nStores orders" ##container } box payments "Payment provider\n[Software system]\nProcesses card payments" ##external box email "Email service\n[Software system]\nDelivers email" ##external customer-->web:Uses\n[HTTPS] web-->controller:Places and queries orders\n[JSON/HTTPS] controller-->orders:Calls\n[Java] orders-->database:Reads and writes orders\n[JDBC] orders-->gateway:Requests payment\n[Java] gateway-->payments:Charges cards\n[JSON/HTTPS] orders-->email:Sends order confirmations\n[JSON/HTTPS]

Click the platform's + to open its containers, then the Orders API's + to open its components.

Large Examples

A commerce platform with three client applications, an API gateway, services, data stores, background workers, and external providers. Solid arrows show requests; dashed arrows show events. Named styles distinguish the roles of the elements.

Commerce platform with web, mobile and admin clients, four application services, database and cache, event-driven workers, and payment, warehouse and email providers
⎘
@architecture direction down hspacing 1 vspacing 1 style client #eff6ff #3b82f6;1;solid style gateway #1d4ed8 #1e40af;1;solid,<color:#white> style service #ecfdf5 #059669;1;solid style data #fff7ed #d97706;1;solid style event #f5f3ff #7c3aed;1;solid style external #f1f5f9 #64748b;1;solid groupstyle #white #94a3b8;1;dashed,<color:#475569> group- clients "Client applications" { box web "Web storefront" ##client box mobile "Mobile app" ##client box admin "Admin portal" ##client } group- platform "Commerce platform" { box gateway "API gateway\nRouting & rate limits" ##gateway group- services "Application services" { box identity "Identity service" ##service box catalog "Catalog service" ##service box orders "Order service" ##service box payments "Payment service" ##service } group- data "Data stores" { box cache "Product cache\nRedis" ##data box database "Orders & inventory\nPostgreSQL" ##data } group- background "Background processing" { box events "Order events\nEvent stream" ##event box fulfillment "Fulfillment worker" ##event box notifications "Notification worker" ##event } } group- providers "External providers" { box paymentProvider "Payment provider" ##external box warehouse "Warehouse API" ##external box email "Email provider" ##external } web->gateway:HTTPS mobile->gateway:HTTPS admin->gateway:HTTPS gateway->identity:validate token gateway->catalog:browse products gateway->orders:place order catalog->cache:cached products catalog->database:read inventory orders->database:save order orders->payments:authorize payments->paymentProvider:charge card orders-->events:order placed events-->fulfillment:reserve stock events-->notifications:order confirmation fulfillment->warehouse:dispatch shipment notifications->email:send receipt

A creative platform drawn with routing curved: three client applications, a cloud platform group that nests microservices, event processing and storage, and external services. Named styles form a design system that colors the elements by role; colored arrows mark client traffic and model inference, dashed arrows the asynchronous jobs.

AI creative platform with web, mobile and admin clients, an API gateway, microservices, an event bus and GPU workers, databases and object storage, and foundation models and a CDN, joined by curved arrows
⎘
@architecture title AI-Powered Creative Platform direction down routing curved // Design system style client #e0f2fe #0284c7;2;solid style gateway #0f172a #38bdf8;2;solid,<color:#ffffff> style service #ede9fe #7c3aed;2;solid style ai #fae8ff #c026d3;2;solid style event #fce7f3 #db2777;2;solid style data #ffedd5 #ea580c;2;solid style external #f1f5f9 #64748b;2;solid groupstyle #f8fafc #94a3b8;1;dashed // Clients group- clients "01 / CLIENT EXPERIENCE" { box web "**Web Studio**\nNext.js + React" ##client box mobile "**Mobile App**\niOS / Android" ##client box admin "**Admin Console**\nMonitoring Dashboard" ##client } // Cloud platform group- cloud "02 / NOVA CLOUD PLATFORM" { box gateway "**API GATEWAY**\nAuthentication | Routing\nRate Limiting" ##gateway group- services "MICROSERVICES" { box auth "**Identity Service**\nOAuth 2.0 / JWT" ##service box projects "**Project Service**\nWorkspace Management" ##service box orchestrator "**AI Orchestrator**\nPrompt Processing\nModel Routing" ##ai } group- async "EVENT-DRIVEN PROCESSING" { box events "**Event Bus**\nApache Kafka" ##event box workers "**GPU Workers**\nAI Inference\nMedia Rendering" ##ai } group- storage "DATA & STORAGE" { database postgres "**PostgreSQL**\nUsers + Projects" ##data database vector "**Vector Database**\nEmbeddings" ##data box objects "**Object Storage**\nGenerated Assets" ##data } } // External services group- providers "03 / EXTERNAL SERVICES" { box models "**Foundation Models**\nLLM / Image Models" ##external box cdn "**Global CDN**\nMedia Delivery" ##external } // Client traffic web-[#0284c7;2]>gateway: HTTPS / WebSocket mobile-[#0284c7;2]>gateway: HTTPS admin-[#0284c7;2]>gateway: Admin API // Requests and data access gateway->auth: Validate JWT gateway->projects: REST API gateway->orchestrator: Generate Content auth->postgres: User Lookup projects->postgres: Read / Write projects->objects: Upload Assets orchestrator->vector: Semantic Search orchestrator-[#c026d3;2]>models: Model Inference // Asynchronous jobs and delivery orchestrator-[#db2777;2;dashed]>events: Publish Job events-[#db2777;2;dashed]>workers: Process Job workers->objects: Store Results objects->cdn: Publish Media cdn->web: Deliver Assets