Describe Architecture with C4
Purpose
Produce clear, consistent C4 views as code so the architecture can be versioned, reviewed and regenerated, and so every audience sees the right level of detail.
When to use
- A design, review or ADR needs context and container diagrams.
- An existing whiteboard sketch or prose description must become maintainable diagrams.
- Onboarding needs a map of a system and its neighbors.
- Diagrams in different documents disagree and need one model.
When not to use
- Sequence or flow diagrams of one interaction only. Use
sequence-flow.
- Non-architecture diagrams (org charts, generic flowcharts). Use
diagram-as-code.
- Domain boundaries and team relationships. Use
bounded-context-map.
Inputs
Required:
- The system in scope and a description of its parts, users and external systems.
Optional:
- Preferred notation (Structurizr DSL, PlantUML with C4-PlantUML, Mermaid C4); default to Structurizr DSL.
- Technologies, protocols, deployment targets.
- Existing diagrams or naming conventions.
If the scope system is unclear, ask which system is being described. Unknown technologies are labeled [TBD].
Process
- Fix the scope: one software system in scope; everything else is a person or external system.
- Build the model first, then views. List elements: people (roles, not names), software systems, containers (separately deployable/runnable units and data stores), and components only where they help a decision.
- For each element, record name, one-line responsibility, technology (containers and components) and owner if known.
- For each relationship, write a verb phrase and, for containers, protocol/format (e.g., "Places orders using [HTTPS/JSON]", "Publishes OrderPlaced to [AMQP]"). Direction follows the dependency or data initiation.
- Create the System Context view: scope system, users, external systems; no technology detail.
- Create the Container view: containers of the scope system plus directly connected people and externals. Show data stores and message brokers as containers or externals consistently.
- Create Component views only for containers with architecturally significant internals; keep to 5-15 components.
- Optionally add a Deployment view mapping containers to environments and nodes.
- Validate: every relationship has a label; no element appears with two names; each view fits in ~20 elements; a legend or key is present.
- Output the diagram code and a short element catalog table; list
[TBD] items as open questions.
- Label every element or relationship inferred rather than stated as
[ASSUMPTION]; if the goal continues, suggest solution-architecture-document, adr or architecture-review.
Output format
# C4 Model – <system>
## Element Catalog
| Element | Type | Responsibility | Technology | Owner |
|---|---|---|---|---|
## Diagram Code (<notation>)
```
workspace { model { ... } views { systemContext ... container ... } }
```
## Notes
- Assumptions and `[TBD]` items
- Open questions
Quality checklist
Common pitfalls
- Using "API" or "Service" as responsibilities. State what the element does for the business.
- Drawing libraries or modules as containers. Containers run or store data separately.
- Bidirectional arrows everywhere. Pick the initiating direction; add a second relationship only if both sides initiate.
Example
Input: "Checkout: web shop and mobile app call checkout API; API stores orders in PostgreSQL, calls payment provider, publishes events to a broker."
Excerpt of output:
customer = person "Customer" "Buys products online"
shop = softwareSystem "Online Shop" {
web = container "Web Shop" "Browsing and checkout UI" "React"
api = container "Checkout API" "Validates carts, creates orders, starts payment" "[TBD language]"
db = container "Order Database" "Stores orders and payment status" "PostgreSQL"
}
psp = softwareSystem "Payment Provider" "Authorizes card payments" "External"
customer -> web "Places orders using" "HTTPS"
web -> api "Submits checkout requests to" "HTTPS/JSON"
api -> psp "Requests payment authorization from" "HTTPS/JSON"
1---2name: c4-model3description: "Describes a software system with the C4 model - system context, container and, where useful, component diagrams - as diagrams-as-code (Structurizr DSL, PlantUML C4 or Mermaid) with consistent element names, responsibilities, technologies and labeled relationships. Use when someone needs architecture diagrams for a design, review, onboarding or documentation, or wants to turn a textual description or existing sketch into C4 views."4license: MIT5metadata:6 source: https://skillmd.com/skills/muratdincer/c4-model7 version: "1.0.0"8 language: en9 category: 04-architecture10 role: solution-architect11 area: design12 title: "Describe architecture with C4"13 related: "solution-architecture-document, diagram-as-code, bounded-context-map, adr, architecture-review"14 prompt: "Create C4 context and container diagrams in Structurizr DSL for our e-commerce checkout: web shop, mobile app, checkout API, payment provider, order DB and message broker."15---1617# Describe Architecture with C41819## Purpose20Produce clear, consistent C4 views as code so the architecture can be versioned, reviewed and regenerated, and so every audience sees the right level of detail.2122## When to use23- A design, review or ADR needs context and container diagrams.24- An existing whiteboard sketch or prose description must become maintainable diagrams.25- Onboarding needs a map of a system and its neighbors.26- Diagrams in different documents disagree and need one model.2728## When not to use29- Sequence or flow diagrams of one interaction only. Use `sequence-flow`.30- Non-architecture diagrams (org charts, generic flowcharts). Use `diagram-as-code`.31- Domain boundaries and team relationships. Use `bounded-context-map`.3233## Inputs34Required:35- The system in scope and a description of its parts, users and external systems.3637Optional:38- Preferred notation (Structurizr DSL, PlantUML with C4-PlantUML, Mermaid C4); default to Structurizr DSL.39- Technologies, protocols, deployment targets.40- Existing diagrams or naming conventions.4142If the scope system is unclear, ask which system is being described. Unknown technologies are labeled `[TBD]`.4344## Process451. Fix the scope: one software system in scope; everything else is a person or external system.462. Build the model first, then views. List elements: people (roles, not names), software systems, containers (separately deployable/runnable units and data stores), and components only where they help a decision.473. For each element, record name, one-line responsibility, technology (containers and components) and owner if known.484. For each relationship, write a verb phrase and, for containers, protocol/format (e.g., "Places orders using [HTTPS/JSON]", "Publishes OrderPlaced to [AMQP]"). Direction follows the dependency or data initiation.495. Create the System Context view: scope system, users, external systems; no technology detail.506. Create the Container view: containers of the scope system plus directly connected people and externals. Show data stores and message brokers as containers or externals consistently.517. Create Component views only for containers with architecturally significant internals; keep to 5-15 components.528. Optionally add a Deployment view mapping containers to environments and nodes.539. Validate: every relationship has a label; no element appears with two names; each view fits in ~20 elements; a legend or key is present.5410. Output the diagram code and a short element catalog table; list `[TBD]` items as open questions.5511. Label every element or relationship inferred rather than stated as `[ASSUMPTION]`; if the goal continues, suggest `solution-architecture-document`, `adr` or `architecture-review`.5657## Output format58````markdown59# C4 Model – <system>60## Element Catalog61| Element | Type | Responsibility | Technology | Owner |62|---|---|---|---|---|6364## Diagram Code (<notation>)65```66workspace { model { ... } views { systemContext ... container ... } }67```6869## Notes70- Assumptions and `[TBD]` items71- Open questions72````7374## Quality checklist75- [ ] Levels are not mixed: no components on the container view, no technology on the context view.76- [ ] Every relationship is directional, labeled with intent and (for containers) protocol.77- [ ] Element names and responsibilities are identical across views and the catalog.78- [ ] Data stores and brokers are shown explicitly.79- [ ] The code is syntactically valid for the chosen notation.80- [ ] All checks pass; if any fails, revise the output and re-run this checklist before answering.8182## Common pitfalls83- Using "API" or "Service" as responsibilities. State what the element does for the business.84- Drawing libraries or modules as containers. Containers run or store data separately.85- Bidirectional arrows everywhere. Pick the initiating direction; add a second relationship only if both sides initiate.8687## Example88Input: "Checkout: web shop and mobile app call checkout API; API stores orders in PostgreSQL, calls payment provider, publishes events to a broker."8990Excerpt of output:91```92customer = person "Customer" "Buys products online"93shop = softwareSystem "Online Shop" {94 web = container "Web Shop" "Browsing and checkout UI" "React"95 api = container "Checkout API" "Validates carts, creates orders, starts payment" "[TBD language]"96 db = container "Order Database" "Stores orders and payment status" "PostgreSQL"97}98psp = softwareSystem "Payment Provider" "Authorizes card payments" "External"99customer -> web "Places orders using" "HTTPS"100web -> api "Submits checkout requests to" "HTTPS/JSON"101api -> psp "Requests payment authorization from" "HTTPS/JSON"102```