What you'll learn: By the end of this lesson you will be able to decide which decisions deserve a written record, write one in the Nygard, MADR or Y-statement form, keep an append-only decision log where a changed decision is superseded rather than edited, draw C4 context and container diagrams that can stand alone, and link the two so the map and the reasons never drift apart.
A house has a wall in an odd place. A new owner knocks it down and finds out why: it carried the roof. If the builder had left a note, "load-bearing, do not remove, see the beam above", the discovery would have cost nothing. Software systems have load-bearing walls too. The code shows where the wall is. It rarely says why.
Two kinds of document fix this. A decision record keeps the reason. A diagram shows where things are. Each is weak alone: a diagram without reasons invites "simplifications" that remove a wall, and reasons without a map are hard to place. Choosing between options is the job of trade-off analysis; this lesson covers what you do with the answer. The next lesson, reviewing designs and staff expectations, uses these documents as review inputs.
The other side of this topic: the front end records its own decisions (rendering, state, design system); see the front-end lesson on architecture decision records and documentation.
Verified on 2026-12-02 against adr.github.io, Nygard's 2011 post, the MADR site, the AWS and Azure ADR guidance and c4model.com. No code was run. ShopStream names and numbers are illustrative.
The core idea
An architecture decision record (ADR) captures one decision and its reasons. The C4 model draws a system at four levels of zoom. Records answer "why is it like this?", diagrams answer "what is it and where?", and the two together let a newcomer change the system without guessing.
Three examples run through the lesson: a minimal example (a one-sentence Y-statement), a realistic example (a full record for an order-event outbox, with its C4 diagrams) and a failure example (a stale diagram and a missing record lead to a removed load-bearing piece).
What deserves a record
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", and an architecturally significant requirement as one "that has a measurable effect on the architecture and quality of a software and/or hardware system". An ADR "captures a single AD and its rationale", and the collection of them in a project "constitute its decision log".
The Azure Well-Architected guidance gives a practical filter: include only choices that affect the system's structure or key quality attributes, or that are difficult to reverse. The AWS Prescriptive Guidance names five areas: structure, non-functional requirements, dependencies, interfaces and construction techniques such as libraries and frameworks. Naming a variable does not qualify; choosing how orders reach the payment service does.
Anatomy of a record
Three formats are in common use. adr.github.io lists them side by side.
Nygard's format has five parts: title, status, context, decision and consequences (the trade-off lesson summarised it). Two more points from his post: records are numbered sequentially and numbers are never reused, and a reversed decision is not deleted but marked superseded, because it is still useful to know what was decided.
MADR (Markdown Architectural Decision Records) is a Markdown template with a title, status, context and problem statement, optional decision drivers, considered options, decision outcome, consequences, an optional confirmation of how compliance will be checked, and pros and cons of each option. The alternatives are first-class, so a reader sees what was rejected.
The Y-statement compresses a decision into one sentence. adr.github.io gives the short form as "In the context of <use case/user story>, facing <concern> we decided for <option> to achieve <quality>, accepting <downside>." The long form adds the options not chosen and an extra "because" for further reasoning.
Minimal example (illustrative). A Y-statement for ShopStream:
In the context of publishing an event whenever an order is saved, facing the risk that the database commit succeeds but the broker publish fails, we decided for a transactional outbox table polled by a relay, to achieve no lost order events, accepting extra latency and a table to maintain.
One sentence gives the use case, the concern, the choice, the quality gained and the price paid. It is a good summary line at the top of a full record.
Nygard asks for one or two pages, written in full sentences as a conversation with a future developer. The Azure page adds: always include context and rationale, because "a record without justification loses its value"; do not hide consequences; keep the record from becoming a design guide; and record the confidence level, since a low-confidence decision is a candidate for reconsideration.
The decision log
The decision log, the whole collection, is what lets a project be understood. Three habits keep it trustworthy.
Append-only. Azure says the ADR "serves as an append-only log" and that you should not go back and edit accepted records: "write a new record that supersedes the original and link the two together". AWS says the same: once accepted, a record is immutable, and a new one supersedes it.
A lifecycle. The AWS process gives records states. An owner proposes one, the team reviews it, and the outcome is accepted, reworked (it stays proposed) or rejected, with the reason recorded so the discussion is not repeated.
Figure 1. The states of a record. How to read this: rework loops back to proposed, so a record that is still being argued over is visibly not yet a decision. Accepted records are never edited; they end by being superseded.
Next to the code. Nygard stored records in the project repository (he used a doc/arch/ path and Markdown). Azure asks for the log to be stored openly with the workload documentation, warning that an unrecorded decision "will likely be forgotten, leading to repeated debates". A record in the same pull request as the change puts the reasons and the code in front of the same reviewers.
Figure 2. A record goes through review like code does. How to read this: the owner writes a proposed record, the team reads and comments, and an accepted record is merged into the log. The AWS process then uses accepted records as a reference: a code reviewer who finds a change that breaks one asks the author to update the code and shares the link.
C4: a map at four zoom levels
The C4 model is described on c4model.com as "an easy to learn, developer friendly approach to software architecture diagramming". It is built on four hierarchical abstractions: software systems, containers, components and code. Each has a matching diagram, and a software system is "the highest level of abstraction", something that delivers value to its users, human or not. The site suggests thinking of it as something a single development team builds and owns.
The word container needs care. The site's definition: a container "represents an application or a data store", "essentially a runtime boundary around some code that is being executed or some data that is being stored", and the page opens with "Not Docker!". A web application, a mobile app, a serverless function and a database schema are all containers; a JAR file or a module is not, because it organises code inside a container.
| Diagram | Scope | Shows | Audience | Recommended? |
|---|---|---|---|---|
| System context | One software system | The system, the people who use it, the external systems it connects to | Everybody, technical or not | Yes, for all teams |
| Container | One software system | The containers inside it and how they connect | Technical people | Yes, for all teams |
| Component | One container | The components inside the container | Architects and developers | No, only if it adds value |
| Code | One component | Code elements such as classes, functions or tables | Architects and developers | No, particularly for long-lived documentation |
The rows come from the individual diagram pages. The site adds that you do not need all four levels, "only those that add value", and that the context and container diagrams "are sufficient for most software development teams"; for the code level it notes that most IDEs can generate that detail on demand. Three supporting diagrams exist: system landscape, dynamic (a feature as numbered interactions, used sparingly) and deployment (the nodes where container instances run).
Level 1: system context
The context diagram has the system in the middle and, around it, people and directly connected external systems. The site's hint is to keep it high-level and to focus "on people (actors, roles, personas, etc) and software systems" rather than technologies.
Figure 3. Level 1, the context of ShopStream (illustrative). How to read this: ShopStream is one box. Three kinds of people use it and two external systems sit outside its boundary. Nothing here says how it is built, which is why a product manager can read it.
Level 2: containers
The container diagram opens the box. Its scope is still one software system; its primary elements are the containers, and its audience is technical.
Figure 4. Level 2, the containers of ShopStream (illustrative). How to read this: the zone is the system boundary from Figure 3. Each box is an application or a data store. A real C4 container diagram also states each container's technology; this figure leaves it out because the technology choices are what the decision records hold.
Notation: make a diagram stand alone
The notation page says C4 "doesn't prescribe any particular notation", and gives a test: can the diagram "stand alone, and be (mostly) understood without a narrative"? Its checklist: a title naming the type and scope and a key or legend; a type and short description on every element; a technology on every container and component; every line unidirectional and labelled, avoiding vague labels such as "Uses"; the protocol on container-level lines.
a closer look?"} Q2 -->|yes| C3["Add a component diagram
for that container only"] Q2 -->|no| Q3{"Complicated feature
or environment question?"} C3 --> Q3 Q3 -->|feature| D1["Dynamic diagram"] Q3 -->|environment| D2["Deployment diagram"] Q3 -->|neither| E2["Done"]
Figure 5. Start small, zoom only where it pays. How to read this: the first two diagrams are the default. Each further diagram is added for a reason, and the reason is a question somebody is asking.
Joining the map and the reasons
The sources do not prescribe how to connect the two; this is a working convention. Put the record number on the element it affects ("see ADR 14" in the Orders service's description), and name the diagram element in the record's context. When a record is superseded, change the diagram in the same pull request.
Trade-offs
| Approach | Gain | Cost | Wrong when |
|---|---|---|---|
| One-sentence Y-statement | Fast, easy to scan | Little room for context or options | The decision needs a real argument |
| Nygard five-part record | Short, easy to write | Alternatives are not required | The team keeps relitigating rejected options |
| Full MADR | Options, drivers and confirmation are explicit | Longer, so some will skip it | Decisions are small and frequent |
| Context plus container diagrams | Cheap, enough for most teams | Hide internal structure | A container's inside is the question |
| Component and code diagrams | Detail for developers | Go stale quickly | Nobody will regenerate them |
Failure example: the load-bearing wall nobody marked
A diagram shows Orders writing to its database and publishing to the broker. It omits the outbox table, and no record explains it. A newcomer removes the apparently pointless table. Every test passes. Months later a broker outage leaves orders saved with no event, and nothing failed loudly.
In practice: relitigating the order-event outbox
This is an educational scenario on ShopStream with illustrative numbers.
This is a realistic scenario, not a case history.
The situation
This is the realistic example. ShopStream's checkout, in the stage described in the order pipeline lesson, saves an order and must tell the rest of the system. The shared peak figure is about 58 checkouts per second (illustrative). The team agreed in a meeting to publish through an outbox table and built it, but wrote nothing down. Six months on, two engineers join; one asks why the Orders service has an extra table, a relay and a clean-up job, and proposes removing them as dead weight.
Starting architecture
The only artefact is a container diagram drawn before the outbox existed.
It shows two direct writes, the shape the outbox was introduced to avoid.
Options considered
| Option | Gain | Cost | Wrong when |
|---|---|---|---|
| A. Direct publish after commit | Simplest code | A crash between commit and publish loses the event | Every order event must be delivered |
| B. Outbox table plus relay | Order and event commit together | A table, a relay and clean-up to run | The team cannot operate the relay |
The decision
Before anyone removes anything, the team writes the record after the fact; the Azure guidance says a record can be generated retroactively from known past decisions. It is ADR 14 (the number is illustrative), in the Nygard form with MADR's options table: context (a commit and a publish cannot be one atomic step), decision ("We will write events to an outbox table in the same transaction as the order and publish them from there"), consequences (duplicate events are possible, so consumers must be idempotent; the relay and its lag are new things to monitor) and a trigger to revisit if a database-log connector becomes available to the team. Status: accepted, with a note that confidence is medium. The record sits in the repository at the path the team chose for the decision log.
# 14. Publish order events through a transactional outbox
Status: accepted
## Context
Saving an order and publishing its event are two writes to two systems.
A crash between them loses the event.
## Decision
We will insert the event into an outbox table in the same transaction
as the order. A relay publishes rows from that table.
## Consequences
Events are published at least once, so consumers must tolerate duplicates.
The relay and its lag need monitoring. Revisit if a log-reading connector
becomes available to the team.
Rollout and verification
Update the container diagram so the outbox and relay appear and the Orders description reads "see ADR 14", and review both in one pull request. Check that a new engineer can answer "why does this table exist?" from the diagram and record alone.
The 2 a.m. failure
The page reads: "Orders accepted, no events for 12 minutes". It comes from a sibling service whose outbox was never recorded: a clean-up removed the relay, and a broker outage then left orders saved without events.
First checks: compare saved orders with published events, and check the broker's health. Mitigation: re-publish from the order table. Follow-up: restore the outbox, write the missing record, and add a review step that checks changes against the log, as the AWS process does.
Architect's notes
- Write the record when the decision is made, while the alternatives are fresh, and record the rejected options: they are the next engineer's questions.
- Mark confidence and a revisit trigger, or a shaky decision is argued forever.
- Draw context and container first, and add lower levels only where someone is asking a question.
Common mistakes
- Recording what was built, not why. AWS says the format's value is the reason for the decision rather than how it was implemented.
- Editing old records to match what happened, which destroys the evidence.
- Reading "container" as Docker. In C4 it is an application or a data store.
- Unlabelled arrows, or the label "Uses", so the diagram needs a narrative.
- Drawing all four C4 levels for everything.
Key takeaways
- An ADR captures one architecturally significant decision and its rationale; the collection is the decision log.
- Nygard, MADR and the Y-statement differ in length and in how much they say about options.
- Accepted records are not rewritten: a changed decision is superseded by a new record.
- C4 has four levels; context and container diagrams are enough for most teams.
- A C4 container is an application or a data store, not a Docker container.
- Link diagram elements to records, and change both in the same pull request.
Practice exercises
Exercise 1 (20 min). Write a Y-statement for a decision your current project made, such as choosing a message broker or a database. If the "accepting" part is empty, the decision has no recorded downside; find it.
Exercise 2 (45 min). Draw the context and container diagrams for a system you know, following the notation checklist: title, key, element types and descriptions, labelled unidirectional lines. Give them to someone who has not seen the system and note which questions they ask.
Exercise 3 (45 min). Write the superseding record for the day a log-reading connector replaces the relay. Which sections of the old record change? (None should.)
Related reading
- Trade-off analysis: how to compare the options before you record the decision.
- ShopStream order pipeline: the outbox, broker and saga used in the example.
- ShopStream services: the containers shown in the diagrams.
- Design any system: where a decision record fits the repeatable method.
- Reviewing designs and staff expectations: the next lesson, on using these documents in design review.
Official documentation
- adr.github.io: Architectural Decision Records and its templates page.
- Michael Nygard, Documenting Architecture Decisions (2011).
- MADR: Markdown Architectural Decision Records.
- AWS Prescriptive Guidance: Architectural decision record process.
- Microsoft Azure Well-Architected Framework: Maintain an architecture decision record.
- c4model.com: overview, container and notation.