Deciding what to document and for whom
Choose what goes into an architecture document by starting from its readers and their questions, keep it lean with a few arc42 sections, write by hand only what code and tools cannot produce, and trace quality goals to the design so reviewers can follow them.
Contentsand lesson path
On this page
- Why it matters
- Start from readers and their questions
- A lean arc42: twelve drawers, most of them small
- Write the why, generate the what, link the rest
- Trace quality goals to the design
- Check your understanding
- Apply it
- Review prompt
Lessons of C4 & Architecture Documentation
- Abstractions first: people, systems, containers, components Concept · 20 min
- Diagramming a ride-booking system at three zoom levels Worked example · 25 min
- Deployment and dynamic views, and where UML still helps Concept · 20 min
- Diagrams as code in a docs-as-code workflow Lab · 25 min
- Deciding what to document and for whom Concept · 15 min
- Diagram review check Knowledge check · 6 questions
What you will learn
- Assemble a lean architecture document (for example arc42 sections) kept as code next to the system it describes.
01. Why it matters
Every page of documentation has two costs: the time to write it, and the time to keep it true for as long as it exists. A page that nobody reads still has the second cost, and a page that has gone stale is worse than no page, because people act on it. The arc42 FAQ puts it bluntly: do not fill in everything; document what your stakeholders need, and ask them what that is.
So the useful question is not "which template sections do we have?" but "who will read this, and what do they need to decide or do?". This lesson gives you a way to answer that question and to keep the answer small enough to maintain.
02. Start from readers and their questions
An international standard for architecture descriptions, ISO/IEC/IEEE 42010:2022, gives this idea precise words. A stakeholder is anyone with an interest in the system. A concern is a matter that is important to a stakeholder, such as cost, security or how to deploy. A viewpoint is a set of conventions for building one kind of view, and it frames particular concerns. A view applies a viewpoint to your system. In this skill, the C4 diagram types roughly play the role of viewpoints. Note what the standard does not do: it says what an architecture description should identify and how the parts relate, but it does not prescribe a method, a notation, a tool or a file format. It is not a design method, and "compliant" documentation can use C4, UML or plain prose.
In practice, list the readers and their questions before you write anything. For the ride-booking system it might look like this:
- New developers: what are the parts, and where does my change go? The container view, the component view of the Booking API, and the runtime view of a ride request.
- On-call engineers: what runs where, and what breaks when a part fails? The deployment views, plus links to runbooks and dashboards.
- Security reviewers: where does personal data live, and where does it cross trust boundaries? The context view, the data stores in the container view and the payment flow. The skill Threat Modeling adds data-flow diagrams for this.
- Product owners: what does the system depend on, and what are its quality goals? The context view and the goals section.
Two things fall out of the list. First, a handful of views serves everyone, because the same container view answers several questions. Second, a question that no part answers is a gap you have found before a reader hit it.
03. A lean arc42: twelve drawers, most of them small
arc42 is a free template that sorts architecture information into twelve sections: introduction and goals, constraints, context and scope, solution strategy, building block view, runtime view, deployment view, crosscutting concepts, architectural decisions, quality requirements, risks and technical debt, and a glossary. Treat it as a set of drawers that tells everyone where a kind of information goes, not as a form to complete.
The arc42 FAQ says there is no general minimum, but suggests always covering a few things: three to five central quality requirements written as scenarios, the context with its external interfaces, a short solution strategy with the most important decisions, the first level of the building block view, and the most important crosscutting concepts. C4 fits into those drawers directly. The context diagram goes in context and scope, and the container and component diagrams are levels 1 and 2 of the building block view. Dynamic views belong in the runtime view, and deployment views in the deployment view. The lab in lesson 4 put its C4 views into these drawers (sections 3, 5, 6 and 7) and added the goals and one decision record. A real document would also add a short solution strategy and its key crosscutting concepts, and would write the quality goals as full scenarios.
04. Write the why, generate the what, link the rest
Sort every piece of information by where it can come from:
- Write by hand what only people know: goals, constraints, the options you rejected and why, trade-offs, known risks. Code cannot tell a reader why the dispatch worker is separate; a decision record can. The skill Architecture Decision Records covers how to write them.
- Generate what tools can produce from a source of truth: diagrams from the model, API references from an OpenAPI file, class diagrams from an IDE when someone asks.
- Link what already lives elsewhere and has an owner: runbooks, dashboards, the threat model, the product roadmap.
The C4 FAQ adds a useful rule of thumb about how fast each level changes. Context diagrams change slowly, and container diagrams change slowly unless the system adds many services or functions. Component diagrams can change every sprint, and code diagrams go stale almost at once. Hand-drawn detail at the fast-changing levels is the first to drift, so generate it or leave it out.
05. Trace quality goals to the design
Reviewers often ask "how does this design meet goal X?". The answer is a trace: from the goal to the elements that carry it, the decision that explains it, and the test or monitor that checks it. (The lesson From fast and secure to testable scenarios shows how to write goals that can be checked.) If the goals live in a small file next to the model, a script can report broken traces, just as check_docs.py reports drift. Run this in the ride-docs folder from the lab, after ./check-docs.sh has produced build/workspace.json.
# Quality goals from section 1, traced to the model, decisions and checks.
[[goal]]
id = "Q1"
text = "A rider sees a fare quote within 2 s for 95% of requests."
elements = ["Booking API", "Fare quoter", "Maps client"]
decisions = ["1"]
checks = ["load test: quote p95 under 2 s at 300 req/s, nightly"]
[[goal]]
id = "Q2"
text = "No trip is charged twice, even when a request is retried."
elements = ["Payment client", "Trip database"]
decisions = []
checks = ["test_capture_is_idempotent"]
[[goal]]
id = "Q3"
text = "A new developer runs the whole system locally in one hour."
elements = ["Developer laptop"]
decisions = []
checks = []"""Report quality goals whose trace to the model, a decision or a check is broken."""
import json
import sys
import tomllib
from pathlib import Path
def model_index(workspace: dict) -> tuple[set[str], set[str]]:
names, decisions = set(), set()
stack = list(workspace["model"].get("people", []))
stack += workspace["model"].get("softwareSystems", [])
while stack:
element = stack.pop()
names.add(element["name"])
stack += element.get("containers", []) + element.get("components", [])
for decision in element.get("documentation", {}).get("decisions", []):
decisions.add(decision["id"])
return names, decisions
def main(workspace_json: str, goals_toml: str) -> int:
workspace = json.loads(Path(workspace_json).read_text(encoding="utf-8"))
goals = tomllib.loads(Path(goals_toml).read_text(encoding="utf-8"))["goal"]
names, decisions = model_index(workspace)
gaps = 0
for goal in goals:
problems = [f"'{e}' is not in the model" for e in goal["elements"]
if e not in names]
problems += [f"decision {d} does not exist" for d in goal["decisions"]
if d not in decisions]
if not goal["decisions"]:
problems.append("no decision explains how it is met")
if not goal["checks"]:
problems.append("nothing checks it")
if problems:
gaps += 1
for problem in problems:
print(f"{goal['id']} GAP: {problem}")
else:
print(f"{goal['id']} ok")
print(f"{len(goals) - gaps} of {len(goals)} goals fully traced")
return 1 if gaps else 0
if __name__ == "__main__":
sys.exit(main(sys.argv[1], sys.argv[2]))python tools/trace_check.py build/workspace.json docs/architecture/quality.tomlQ1 ok
Q2 GAP: no decision explains how it is met
Q3 GAP: 'Developer laptop' is not in the model
Q3 GAP: no decision explains how it is met
Q3 GAP: nothing checks it
1 of 3 goals fully tracedOnly Q1 is fully traced. Q2, "no trip is charged twice", has a test but no decision. Somebody must decide how retries stay safe, for example with an idempotency key sent to the payment provider, and that decision deserves a record. Q3 names "Developer laptop", which is not in the model. Either add a development deployment environment to the model, or admit that nobody has designed for this goal yet. Nothing checks it either, and an unchecked goal is a wish.
The script took a few minutes to write, and it turns a reviewer's question into a list of concrete gaps. That is what a lean document is for: a small amount of hand-written text that tells you where to look, with the tools proving the rest.
06. Check your understanding
07. Apply it
Write a one-page documentation plan for the system you modelled in the lab, and keep it in the repository next to the model:
- List three to five reader groups and the two most important questions of each.
- For each question, name the section or view that answers it, or mark it as a gap.
- Mark each part as written by hand, generated or linked, and give each hand-written part an owner.
- Add a
quality.tomlfor your top three quality goals and runtrace_check.pyon it. Close at least one gap it reports.
08. Review prompt
Without looking back: explain stakeholder, concern, viewpoint and view in one sentence each, and say what ISO/IEC/IEEE 42010 does not prescribe. Name the parts of an arc42 document that the arc42 FAQ suggests covering first, and where each C4 diagram fits. Then give one example each of information you would write by hand, generate and link.
References
- arc42 FAQ B-1: Which parts of arc42 are essential?
- arc42 FAQ B-4: What is the minimal amount of an arc42 documentation?
- arc42 template overview
- ISO/IEC/IEEE 42010:2022 Software, systems and enterprise — Architecture description
- The C4 model: Frequently asked questions (C4 and arc42)
- The C4 model: Diagrams FAQ (how fast each level goes out of date)
Your progress
Reading state
Sign in to save that you finished reading this lesson.
Prove this skill
6 questions · about 5 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.