Markdown Editor

C4 Architecture Document Template (C4 Model)

C4 model document with Mermaid C4 diagrams – context, containers, components, code, landscape, dynamic, deployment, element catalogues

Архітектура та системний дизайнПовнийC4 modeldiagram

Як використовувати: Teams that want diagrams developers actually maintain. Draw context and container levels first; add component diagrams only for one or two complex containers. The main pitfall is boxes without descriptions and lines labelled only "uses".

Перегляд

C4 Architecture Document: [System name]

Architecture document organised around the C4 model by Simon Brown (c4model.com): system context, containers, components and code, plus supplementary landscape, dynamic and deployment diagrams. Diagrams use Mermaid C4 syntax so they live next to the text. Replace every [bracketed] value and every row marked Example.

Document control

FieldValue
Document ID[C4-SYSTEM-001]
Software system[System name]
System release described[vX.Y / current state as of YYYY-MM-DD]
Version[0.1]
Status[Draft / In review / Approved]
Author / owner[@architect]
Classification[Internal / Confidential / Public]
Last updatedYYYY-MM-DD

Approvals

RoleNameDecisionDate
Lead architect[@name][Approved / Approved with comments / Rejected]YYYY-MM-DD
Engineering lead[@name][Decision]YYYY-MM-DD
Security architect[@name][Decision]YYYY-MM-DD
Operations lead[@name][Decision]YYYY-MM-DD

Revision history

VersionDateAuthorChange summary
0.1YYYY-MM-DD[@name]Context and container diagrams
0.2YYYY-MM-DD[@name]Example: Component diagram for the API application; deployment diagram
1.0YYYY-MM-DD[@name]Example: Baseline approved at architecture review

Contents

1. Introduction

1.1 Purpose and audience

This document describes the software architecture of [System name] for [developers joining the team, architects reviewing changes, operations and security reviewers]. It uses the C4 model's hierarchy of abstractions, so each audience can stop at the level of detail they need.

1.2 System summary

[Two or three sentences: what the system does, for whom, and its business value. Example: "The online shop lets retail customers browse the catalogue, place orders and track deliveries. It handles around 8,000 orders per day and integrates with the warehouse and payment provider."]

1.3 Diagram inventory

DiagramLevel / typeAudienceSection
System contextLevel 1Everyone3
ContainersLevel 2Technical staff4
Components of [API application]Level 3Developers5.1
Components of [Worker]Level 3Developers5.2
System landscapeSupplementaryArchitects, management7.1
Dynamic: [Place order]SupplementaryDevelopers, testers7.2
Deployment: ProductionSupplementaryOperations7.3

2. Notation and conventions

ElementMeaningDescription required
PersonA human user or roleRole and goal
Software systemSomething that delivers value to users; owned by one teamPurpose
External systemA software system outside the scope of this documentPurpose and owner
ContainerA separately runnable or deployable unit (application, data store)Technology and responsibility
ComponentA grouping of related functionality behind an interface inside a containerTechnology and responsibility
RelationshipUni-directional dependency or data flowVerb phrase and, at level 2 and below, protocol

Conventions used here: [relationship labels describe intent ("Places orders using"), not just "uses"; technology appears in square brackets; external systems are shown grey in the rendered diagrams].

2.1 Diagram review checklist

Run this checklist on every diagram before a review. A "no" is a defect to fix, not a style preference.

CheckQuestion
TitleDoes the diagram have a title that names its type and scope?
KeyIs the meaning of every shape, colour, line style and acronym clear from the key or the conventions above?
ElementsDoes every element have a name, a type and a one-sentence description?
TechnologyAt level 2 and below, does every container and component state its technology?
RelationshipsDoes every line have a direction and a label that says what happens, not only "uses"?
ProtocolsAt level 2 and below, does every relationship crossing a process boundary name its protocol?
ConsistencyDo names match exactly across levels, so a container in section 4 is the boundary in section 5?
SizeIs the diagram small enough to read without zooming (about 15 elements or fewer)?

2.2 Keeping diagrams current

PracticeHow it is applied here
Diagrams as codeDiagrams are Mermaid text in this document, reviewed in the same pull request as the change they describe
Owner per diagram[The team owning the container owns its component diagram]
Review trigger[Any new container, new external system, or changed protocol updates sections 3 and 4]
Model tooling[Optional: a modelling tool generates views from one model; this document links to them]

3. Level 1: System context

3.1 Diagram

The system context diagram shows [System name] with its users and the external systems it relies on.

3.2 Element catalogue

ElementTypeDescriptionOwner
Example: CustomerPersonRetail customer on web or mobile browsern/a
Example: Online shopSoftware system (in scope)Catalogue, basket, checkout, order trackingTeam Shop
Example: Payment providerExternal systemCard authorisation and capture[Vendor]
Example: Warehouse systemExternal systemFulfilment and shipment statusLogistics IT
[Element][Type][Description][Owner]

4. Level 2: Containers

4.1 Diagram

The container diagram shows the deployable units inside the online shop.

4.2 Element catalogue

ContainerTechnologyResponsibilityData ownedTeam
Example: Web applicationTypeScript, ReactCustomer UI, served as static filesNone (browser storage for basket)Team Shop
Example: API applicationJava 21, Spring BootOrders, catalogue, payments orchestrationShop databaseTeam Shop
Example: Fulfilment workerJava 21Hand-off to warehouse with retriesNoneTeam Logistics
Example: Shop databasePostgreSQL 16System of recordProducts, customers, ordersTeam Shop
[Container][Technology][Responsibility][Data][Team]

4.3 Inter-container communication

FromToProtocolSync / asyncAuthenticationNotes
Example: Web applicationAPI applicationHTTPS, JSONSyncOAuth 2.0 bearer tokenRate limited per user
Example: API applicationMessage brokerAMQP over TLSAsyncService credentialsAt-least-once delivery
[From][To][Protocol][Mode][AuthN][Notes]

4.4 Data ownership and security boundaries

Each data store has exactly one owning container. Other containers read its data only through the owner's API or events.

Data storeOwning containerReaders (via)Personal dataEncryption at restBackup
Example: Shop databaseAPI applicationFulfilment worker (order paid events)Yes: names, addresses, emailYes, provider-managed keysDaily snapshot, 35 days
Example: Message brokerAPI application (publisher)Fulfilment workerOrder ID and addressTLS in transit, disk encryptionNot backed up; replayable from outbox
[Store][Owner][Readers][Yes / No: fields][Yes / No][Policy]

5. Level 3: Components

5.1 Components of the API application

The API application is decomposed into components that each own one area of the business logic.

ComponentResponsibilityInterfaceTechnology
Example: Order controllerRequest validation, mapping to commandsPOST /orders, GET /orders/{id}Spring MVC
Example: Order servicePricing, stock check, state transitionsplaceOrder(command)Plain Java
Example: Payment gatewayIdempotent payment calls, error mappingauthorise(orderId, amount)HTTP client with retry
[Component][Responsibility][Interface][Technology]

5.2 Components of [second container]

[Repeat the diagram and table for a second container only if readers need it, for example the fulfilment worker's retry and dead-letter handling.]

ComponentResponsibilityInterfaceTechnology
Example: Order event listenerConsumes order paid eventsAMQP queue orders.paidSpring AMQP
Example: Shipment clientCreates shipments, handles 429 and 5xx with backoffcreateShipment(order)HTTP client
[Component][Responsibility][Interface][Technology]

6. Level 4: Code

Code diagrams for [System name] are generated from the source on demand rather than maintained by hand. This section records the conventions that map components to code.

ComponentPackage / moduleKey typesNotes
Example: Order servicecom.example.shop.ordersOrder, OrderService, PricingPolicyDomain types have no framework annotations
Example: Payment gatewaycom.example.shop.paymentsPaymentGateway, ProviderClientOnly package allowed to call the provider SDK
[Component][Package][Types][Notes]

Rules enforced in the build: [for example "architecture tests fail the build when a controller calls a repository directly"].

7. Supplementary diagrams

7.1 System landscape

The landscape shows the online shop among the other systems of [Company].

SystemOwnerRelevance to this document
Example: Product information systemMerchandising ITSource of catalogue data
[System][Owner][Relevance]

7.2 Dynamic diagram: place order

The dynamic diagram shows the runtime order of interactions when a customer places an order.

StepFromToDescriptionFailure handling
1CustomerWeb applicationSubmits the basketClient-side validation
2Web applicationAPI applicationCreates the order with an idempotency keyRetry safe on timeout
3API applicationPayment providerAuthorises the amountDeclined returns 402, order stays unpaid
4API applicationShop databaseStores order and outbox event in one transactionRollback, payment voided

7.3 Deployment diagram: production

The deployment diagram maps containers to production infrastructure.

Deployment nodeInfrastructureInstancesScalingRecovery
Example: Kubernetes clusterManaged Kubernetes, 3 zones3 API, 2 worker podsHPA on CPU 70%Pods rescheduled automatically
Example: Managed databasePostgreSQL 16Primary and 1 replicaVerticalAutomatic failover, RPO 5 min
[Node][Infrastructure][Instances][Scaling][Recovery]

8. Architecture decisions and quality attributes

8.1 Key decisions

IDDecisionDiagram affectedStatusRecord
ADR-001Example: Single-page application served from a CDNContainers, deploymentAccepted[link]
ADR-002Example: Asynchronous hand-off to the warehouse via a brokerContainers, dynamicAccepted[link]
[ADR-nnn][Decision][Diagram][Status][link]

8.2 Quality attributes

AttributeTargetAchieved byContainer
Example: Availability99.9% monthly for checkout3 API replicas across zones, managed database failoverAPI, database
Example: Performancep95 checkout under 800 msPayment call is the only synchronous external callAPI
[Attribute][Target][Mechanism][Container]

9. Risks, open questions and glossary

9.1 Risks and open questions

IDItemTypeAffected elementOwnerDue
RK-01Example: Broker is a single cluster without cross-region replicationRiskMessage broker@nameYYYY-MM-DD
OQ-01Example: Should the worker call the warehouse in batches?QuestionFulfilment worker@nameYYYY-MM-DD
[ID][Item][Risk / Question][Element][@name]YYYY-MM-DD

9.2 Glossary

TermMeaning
Software systemHighest level of abstraction; delivers value and is owned by one team
ContainerA runnable or deployable unit such as an application or a data store (not only a Docker container)
ComponentA group of related functionality behind an interface inside one container
[Term][Meaning]

Standard and licence note

Based on the C4 model for visualising software architecture by Simon Brown (https://c4model.com): system context, container, component and code levels, plus system landscape, dynamic and deployment diagrams. This template is original text written for this collection and reproduces no text from the C4 website. Template licence: MIT.

Схожі шаблони