Skip to content

Architecture documentation: ADRs and the C4 model

B2Bnetwork team · · 6 min

Technology and trends

In brief

Architecture documentation that keeps up with the system usually consists of two parts: architectural decision records (ADRs) and diagrams based on the C4 model. An ADR is a short file describing one decision, its context, the options considered and the consequences. Simon Brown's C4 model describes a system at four levels of detail: context, containers, components and code. You keep both in the repository next to the code and change them in the same pull request, so the documentation ages together with the system rather than separately.

Why classic architecture documentation dies

A typical architecture document is written at the start of a project, runs to dozens of pages and, six months later, describes a system that no longer exists. The causes repeat:

  • the document lives somewhere other than the code, so nobody updates it when things change;
  • it describes the state, not the decisions, so a newcomer sees how things are but not why;
  • the diagrams mix levels: partner systems, classes and tables all on one drawing;
  • nobody is responsible for keeping it current.

The effects show up when the team changes or an audit comes. A new engineer reconstructs decisions from code and conversations, and the team repeats discussions that already happened once. How to cope with a system whose authors are gone is covered in the article on documenting a legacy system.

ADR: a record of one decision

The adr.github.io site defines an architectural decision as a justified design choice that addresses a functional or non-functional requirement that is architecturally significant. An ADR (architectural decision record) captures one such decision together with its rationale, trade-offs and consequences. A project's collection of ADRs forms its decision log. The concept was popularized by Michael Nygard in 2011.

A sample template in the Nygard style, saved as `docs/adr/0007-queue-for-notifications.md`:

# 7. A queue for notifications instead of synchronous calls

Status: accepted (2026-11-12), supersedes ADR 3

## Context
The orders module calls the notification service synchronously.
At peak time, an SMS gateway outage stops order placement.

## Decision
Orders publish an event to a queue, and notifications consume it.

## Options considered
1. Retries with a timeout in the synchronous call.
2. A queue with a separate consumer (chosen).

## Consequences
A notification may arrive with a delay. Queue length monitoring is needed.

Rules that keep ADRs alive:

  1. One decision, one file, numbered sequentially.
  2. Immutable records. When a decision changes, a new ADR is created with the status “supersedes ADR 3”, and the old one gets the status “superseded”. The history stays readable.
  3. The ADR goes in the same pull request as the change the decision introduces. The reviewer sees the rationale next to the code.
  4. Keep it short. One page is enough. If a decision needs a ten-page analysis, link the analysis and record the outcome in the ADR.
  5. Negative decisions too. “We are not adopting microservices, because…” saves the same discussion a year from now.

An alternative to the Nygard template is the Y-statement format, in which one compound sentence describes the decision: in the context of what, facing which concern, we chose what, to achieve which goal, accepting which cost.

The C4 model: four levels of diagrams

The C4 model describes architecture at four levels, like a map at different scales:

LevelWhat it showsAudienceExample from a banking system
1. System contextthe system as one box, its users and external systemseveryone, including the businessonline banking, customers, core banking system, credit bureau
2. Containersapplications and data stores deployed separatelyarchitects, developers, operationsweb app, API, PostgreSQL database, queue
3. Componentsthe main parts of one container and their responsibilitiesthe team building the containertransfers module, authorization module, core system adapter
4. Codeclasses and their relationshipsdevelopersusually generated from code or skipped

The C4 model also has supplementary diagrams: the system landscape, a dynamic diagram for the flow of a single process, and a deployment diagram. The model is notation independent and tooling independent, so what matters more than the shapes is that every diagram has a title, a legend and labeled arrows: what flows and over which protocol.

In practice most teams maintain levels 1 and 2 for the whole system and level 3 only for the most complex containers. Level 4 is rarely worth drawing by hand, because code changes faster than the drawing.

Documentation next to the code

ADRs and C4 diagrams are best kept in the repository, in a `docs/` directory, in a text format. Diagrams as code (a text description from which a tool generates the drawing) bring three benefits: a diagram change goes through review like any other change, history shows when the architecture changed, and the pipeline can generate current drawings for the documentation portal on its own.

A practical layout:

  • `docs/adr/`: numbered decision records;
  • `docs/architektura/`: C4 level 1 and 2 diagrams, plus a deployment diagram;
  • in each module, a file describing its responsibility, with a level 3 diagram if needed;
  • a question in the pull request template: “does this change need a new ADR or a diagram update?”.

The boundaries in C4 diagrams map well onto Domain-Driven Design contexts and the modules of a modular monolith, so one drawing can serve both conversations about architecture and about how work is split between teams.

How to start on an existing project

You do not have to document everything at once. A two-week plan:

  1. Draw the context diagram (level 1) in one meeting with the team and the business.
  2. Draw the container diagram (level 2) based on what is actually deployed.
  3. Write three to five retrospective ADRs for the decisions newcomers ask about most often: the choice of database, the integration approach, the authentication model.
  4. From then on, every new architectural decision gets an ADR in the pull request.

Documentation like this makes knowledge transfer when the team changes and preparing for an IT audit easier. B2Bnetwork engineers maintain it on maintenance and modernization projects; see What we do.

Questions and answers

Who should write ADRs?

The person proposing the decision, usually the developer or architect leading the change. An ADR goes through review like code: the people affected by the decision comment, and the architecture owner or the team approves it. When only the architect writes ADRs, it is easy to end up with documents detached from what the team actually does.

Which decisions deserve an ADR?

Those that are hard to reverse or that affect many parts of the system: the choice of database, the communication style between modules, the authentication model, the deployment approach, the split into services. Picking a date formatting library usually does not need an ADR. A good test is whether someone will ask “why did we do it this way” a year from now.

How does the C4 model differ from UML?

UML is a notation with many diagram types and strict symbol semantics. The C4 model is a set of abstraction levels that does not impose a notation: you can draw it with simple boxes and arrows, or in UML. C4 says what to show at each level and for whom, not what the symbols look like.

Where should ADRs live: in the repository or a wiki?

In the repository, next to the code they concern. That way an ADR is reviewed together with the change, shares history with the code and does not get lost when tools are migrated. A wiki can display the collected ADRs, for example generated automatically from the repository, but the repository should be the source of truth.

What it looks like in a project

Considering a new technology for your system? Talk to an engineer.

Let's talk

Read more: Technology and trends