Leer en español · Lire en français · Auf Deutsch lesen
Section 4.1 of 4.8 · Intermediate · 18 min read
Why and how much to document
Video lesson
5 min · narrated, with captionsListen only (audio)
Read the transcript
Every system has an architecture, whether or not anyone writes it down. In this lesson you'll see who reads architecture documentation, and how to decide what is worth writing.
Think of the paperwork for a house. A buyer wants a floor plan, an electrician wants the wiring diagram, and an insurer wants the survey. Nobody wants a list of every brick. And a plan that shows a wall that has since been knocked down is worse than no plan at all. The person who renovates it in twenty years wants to know why that wall was never moved. Architecture documentation is the same: a few accurate documents, explaining what the code cannot show.
The architecture description is the set of documents, diagrams and records through which people share an architecture. In a team of three who sit together, much of it can live in their heads. As the team grows and people leave, that becomes a risk. The book Views and Beyond names three uses. Documentation educates newcomers, it carries communication among stakeholders, and it is the basis for analysis. A document that serves none of these is waste.
The reader decides whether documentation worked, and different readers bring different questions. A newcomer asks what the system does, and where to start. A one-page overview and a context diagram serve them best. Operations staff ask where it runs, what it depends on, how it fails and how to recover. They need a deployment view and runbooks. Auditors want to see that decisions were made deliberately and that changes can be traced: decision records with dates and owners. And future maintainers ask why on earth this was done. Above all, they need the rationale.
The Agile Manifesto of 2001 values working software over comprehensive documentation. It's often quoted as permission not to document at all. But its authors say the documentation still has value. It's a priority for when the two compete. What it rejects is documentation for its own sake: hundreds of pages signed off before any code, then abandoned. So aim for just enough. A two-person prototype needs a read me file and perhaps one diagram. A regulated payments platform run by eight teams needs far more. And if newcomers keep asking the same question, write the answer down.
This grid helps you decide how to document any piece of information. The upward axis asks whether it can be recovered from the code. The bottom axis asks how often it changes. Top left are things the code cannot tell you, which change rarely: context and scope, quality goals, and decisions with their reasons. Write these by hand, and keep them. Top right are things that change more often, such as container and deployment views and key runtime scenarios. Keep them next to the code, and review them with every change. Bottom right is what the code already states and changes often, such as class diagrams and interface references. Generate these in the pipeline, so they cannot drift. Bottom left is what you can read in the code that rarely changes, like the technology stack or the build commands. A brief pointer is enough.
Let's apply this to a food-delivery platform with thirty engineers in five teams, and an audit coming up. The architect proposes a short overview: purpose, users, quality goals in priority order, and a reading order for newcomers. It has a named owner and a quarterly review. There are two C4 diagrams, for the system context and the containers, generated from a model kept in the repository. There's a decision log of about forty short records. When a decision changes, a new record supersedes the old one. There's a deployment view for each environment, sequence diagrams for the four flows that matter most, and a runbook for every alert. And class diagrams, endpoint lists and schemas are generated, not written by hand. Every item has a reader, an owner and an update trigger.
Views and Beyond sets out seven rules for sound documentation, and almost every failure breaks one. The most common is the stale wiki: hundreds of pages, partly true, and impossible to tell which part. The big-bang document is a hundred and twenty page specification, approved once and never read again. Diagrams without keys let every reader invent a meaning. And one diagram that mixes a mobile app, a single class and a business process is several views jammed together. Finally, the what without the why: a full description of the structure, with no rationale. Future teams can't tell which constraints are essential and which were accidents.
The full section sets out all seven rules, docs as code, and a guide to what to write down. Next, in Section four point two, we see why one diagram is never enough. See you there.
What you need to know
- An architecture description is the set of documents, diagrams and records through which people share an architecture; it serves education, communication among stakeholders and analysis.
- Different readers (newcomers, developers, operations, security, auditors, future maintainers and decision makers) bring different questions, so documentation should be organised around readers and their tasks.
- The Agile Manifesto values working software over comprehensive documentation, but explicitly says the documentation still has value; it rejects documentation for its own sake, not documentation.
- Write by hand what cannot be recovered from the code (context, quality goals, decisions and their reasons, principles); generate what the code already states and changes often.
- Views and Beyond's seven rules: write for the reader, avoid unnecessary repetition, avoid ambiguity, use a standard organisation, record rationale, keep documentation current but not too current, and review it for fitness of purpose.
- Docs-as-code and living documentation keep documentation in version control, reviewed with code changes and derived from the system where possible, which is the most reliable defence against staleness.
- Common anti-patterns are the stale wiki, the big-bang document nobody reads, diagrams without keys, mixed abstraction levels and descriptions that omit the why.
Why an architecture needs writing down
Every system has an architecture whether or not anyone describes it (see Section 1.1). The architecture description is a separate thing: the documents, diagrams, models and decision records through which people share an understanding of that architecture. In a team of three who sit together and wrote every line, much of the description can live in their heads. As soon as the team grows, people leave, a second team joins, an auditor arrives or the system outlives its authors, knowledge that exists only in heads becomes a risk. Ralph Johnson's definition of architecture as the shared understanding of the expert developers carries a warning: an understanding that is not written down can be shared only by talking, and talking does not scale.
Documenting Software Architectures: Views and Beyond (Paul Clements and colleagues at the Software Engineering Institute, 2nd edition, 2010) names three uses for architecture documentation, and they remain the clearest way to think about why it is worth the effort. It educates: it introduces new team members, external reviewers and new architects to the system. It is the main vehicle for communication among stakeholders: developers, operators, security staff and managers argue about the system through it, and decisions reached in one meeting reach people who were not there. And it is the basis for analysis and construction: it tells implementers what they may and may not do, and it is what an evaluator examines when asking whether the system will meet its quality goals (the evaluation methods of Chapter 11 need a description to work from).
Two consequences follow. First, documentation is a means, not an end: a document that serves none of these uses is waste, however well formatted. Second, the reader decides whether it worked. A description that its author finds complete but that a newcomer cannot use has failed at education, and a diagram the operations team cannot map to real servers has failed at analysis.
Who reads architecture documentation, and what they need
| Reader | Questions they bring | What serves them best |
|---|---|---|
| Newcomers (new developers, contractors, a new architect) | What does this system do, for whom, and where do I start? What are the main parts and the words people use? | A one-page overview, a system context diagram, a container diagram, a glossary and a short reading order |
| Current developers | Where does this new feature belong? What may I depend on? Why is it built this way, and may I change it? | Module or component structure, conventions, cross-cutting concepts (error handling, security, logging) and decision records |
| Operations and SRE staff | Where does it run, what does it depend on, how does it fail and how do we recover? | Deployment view per environment, external dependencies, runbooks, monitoring and recovery objectives |
| Security and privacy staff | Where are the trust boundaries? Where does personal data flow and rest? Who can call what? | Context and data-flow views, identity and access concept, list of third-party services |
| Auditors and regulators | Can you show that the controls exist, that decisions were made deliberately and that changes are traceable? | Decision records with dates and owners, traceability from requirements to design and tests, version history |
| Future maintainers | Why on earth was this done? Which constraints still apply? What is safe to remove? | Rationale above all: decisions with their context, the options rejected and the assumptions made |
| Decision makers (sponsors, product and engineering managers) | What are the risks, costs and options? What do I need to decide, and by when? | A one-page summary, quality goals, top risks and technical debt, decisions awaiting an owner |
Working software over comprehensive documentation
The Agile Manifesto (2001) lists four value pairs, one of which is Working software over comprehensive documentation
. It is quoted, often, as permission not to document at all. Read in full, the manifesto says something narrower. Its authors state that while there is value in the items on the right, they value the items on the left more. The value is a priority for when the two compete, not a rejection of documentation.
What the value rejects is the documentation-driven project of the 1990s: hundreds of pages of specifications signed off before code is written, treated as progress in themselves, and abandoned once the code diverges. The word that matters is comprehensive: documentation that tries to describe everything, for its own sake, and is valued more than the running system. Nothing in the manifesto argues against a context diagram, a short record of why the team chose asynchronous messaging, or a runbook that lets the on-call engineer restore service at three in the morning.
Practitioners do disagree about how far to go. Some agile coaches argue that conversation and tests are almost always enough, and that written architecture documentation goes stale faster than it pays back. Others, especially those who maintain long-lived systems or work in regulated sectors, point out that the people who most need the documentation (successors, auditors, the operations team) are exactly those absent from the conversations. Both positions agree on the underlying economics: documentation has a cost to write, a cost to keep current and a cost to read, and it is worth producing only where its value to readers exceeds those costs.
Just enough documentation
Scott Ambler's phrase "just barely good enough" describes the target: a model or document is sufficient when it serves its purpose for its audience, and effort beyond that point costs more than it returns. His point that the audience, not the author, decides whether an artefact is sufficient is the same principle as writing for the reader. George Fairbanks makes the equivalent argument for architecture work as a whole in Just Enough Software Architecture (2010): do as much as the risks justify (see Section 1.8).
Just-enough documentation is therefore not a fixed quantity. It grows with the size and lifetime of the system, the number of teams, the turnover of people, the cost of failure and the demands of regulators. A two-person prototype needs a README and perhaps one diagram. A payments platform run by eight teams under financial regulation needs context, container and deployment views, a decision log going back years, documented security concepts and evidence that the documents are reviewed.
A practical signal is the repeated question. If newcomers ask the same thing in their first week, or the same design argument recurs every few months, the answer belongs in writing. Another is the expensive mistake: if a team broke an unwritten rule ("never call the payment provider from the restaurant app") because nobody told them, the rule was architecture and should have been written down.
What is worth documenting, and what is not
Information differs in two ways that decide how it should be documented. The first is whether it can be recovered from the code. Class names, method signatures and database tables can be read from the source at any time; the reasons a decision was made, the quality goals the system serves and the options that were rejected cannot, because they were never in the code. The second is how often it changes. The system's purpose and its main external partners change rarely; the list of classes in a module changes weekly.
Hand-written architecture documentation should concentrate on what is both important and not recoverable from code: the system's context and scope (who uses it and which other systems it depends on), its quality goals and constraints, the key decisions and their reasons, the coarse-grained structure (the main deployable parts and their responsibilities), the deployment onto infrastructure, the important runtime scenarios, and the cross-cutting concepts that every part must follow, such as how errors are handled, how users are authenticated and how personal data is protected. This list is close to the structure of the arc42 template, covered in Section 4.6.
What is not worth writing by hand is anything the code or the tools already state precisely and that changes often: class diagrams of a whole codebase, lists of endpoints that an OpenAPI file already holds, or descriptions of each function. Where such views are useful, generate them from the source in the build pipeline so they cannot drift. Also omit aspirational content (diagrams of how the system ought to look, presented as if it already did), minutes of meetings whose outcome is captured elsewhere, and duplicated text, which will eventually contradict its copy.
Deciding how to document a piece of information
Seven rules for sound documentation
Views and Beyond sets out seven rules for sound documentation. They are worth knowing by heart because almost every documentation failure breaks one of them.
- 1. Write for the readerDocumentation is written once and read many times, so optimise for the reader. Decide who the readers are and what they will try to do with the document, organise it for lookup rather than for linear reading, and avoid private jargon. A sign that this rule is broken: the document is organised in the order the author thought of things.
- 2. Avoid unnecessary repetitionEach piece of information should have one home, with links from elsewhere. Repetition makes documents longer and, worse, lets copies drift apart until readers cannot tell which is true. Deliberate repetition for the reader's convenience, such as a summary, is fine if it is clearly marked.
- 3. Avoid ambiguityA box-and-line diagram with no key can be read in several ways: is a line a call, a data flow or a deployment dependency? Define the notation in a key, use one name for one thing, and state what each element and relation means.
- 4. Use a standard organisationA known structure (a template such as arc42 or the Views and Beyond template) tells readers where to look and shows authors what is missing. An empty section marked "not applicable, because..." is more informative than a silent gap.
- 5. Record rationaleWrite down why, including the options rejected. Future maintainers can usually work out what was built; they cannot work out why, and without the why they either fear changing anything or undo a decision whose reasons still hold. Decision records exist for this.
- 6. Keep it current, but not too currentOut-of-date documentation misleads. But updating every document for every half-formed idea creates churn; record decisions once they are made and update the description on a predictable rhythm, such as with each release or each significant change.
- 7. Review it for fitness of purposeOnly the intended readers can say whether a document works. Ask a newcomer to set up and explain the system from the documents, or ask an on-call engineer to use the deployment view in a drill, and fix what they stumble over.
Living documentation and docs-as-code
The traditional failure of architecture documentation is staleness: the description is written at the start, the system changes, and nobody updates the document because it lives somewhere separate from the work. Two related ideas attack this problem at its root.
Docs-as-code, a practice promoted by the Write the Docs community, means treating documentation like source code: written in plain-text formats such as Markdown or AsciiDoc, kept in version control (usually in the same repository as the code it describes), changed through the same pull requests, reviewed by the same people and built and published by the same pipeline. A pull request that changes how orders are dispatched can then be required to update the runtime view in the same commit, and the reviewer sees both.
Living documentation, a term popularised by Cyrille Martraire's book of the same name (2019), goes further: wherever possible, documentation should be derived from the system itself so that it cannot drift. Dependency diagrams generated from the code, API references generated from OpenAPI files, architecture rules checked by automated tests, and diagrams generated from a model kept next to the code are all examples. Hand-written text is reserved for what cannot be derived, chiefly intent and rationale.
Neither idea removes the need for judgement about what to write. Section 4.7, Diagrams as code, covers the tools and habits in detail.
Decision guide
Decision guide: should we write this down?
Ask these questions in order about a piece of architectural knowledge.
- Would someone make a costly mistake, or ask the same question repeatedly, if this were not written down?YesContinue: it is a candidate for documentation.NoLeave it to conversation and the code for now; revisit if the question starts recurring.
- Can it be read reliably from the code, configuration or a tool?YesGenerate it, or link to where it lives; do not copy it by hand.NoContinue: it needs to be written by a person.
- Is it a decision with reasons and rejected options?YesWrite a decision record (see Section 4.5).NoContinue.
- Will it change with most releases?YesKeep it in the repository next to the code it describes and make updating it part of the pull request.NoPut it in the architecture overview or the appropriate template section and review it on a fixed rhythm.
Worked example
Worked example: a just-enough documentation set for the food-delivery platform
A food-delivery company runs a platform with a customer app, a restaurant app, a courier app, ordering, dispatch and notification services, and an external payment provider. It has 30 engineers in five teams and is preparing for an audit by a card-payment assessor. The architect proposes this documentation set, all kept in a single documentation repository or alongside the code, and none of it longer than it needs to be.
| Architecture overview (2 to 3 pages) | Purpose, main users, quality goals in priority order (for example: never lose or double-charge an order; order confirmation p99 under 1.5 seconds at peak; restaurant app usable on poor connections), key constraints, and a reading order for newcomers. Owner: the architect. Reviewed each quarter. |
|---|---|
| System context and container diagrams | Two C4 diagrams (Section 4.3) with keys, generated from a model in the repository. Updated in the pull request that adds or removes a container or an external dependency. |
| Decision log | About 40 short decision records, numbered, in the repository: asynchronous order events, the choice of payment provider, one database per service, and so on. Never rewritten; superseded when a decision changes. |
| Deployment view | One diagram and a table per environment: regions, clusters, managed databases, the message broker and the network boundary around card data. Owned by the platform team. |
| Runtime scenarios | Sequence diagrams for the four flows that matter most: place order, restaurant rejects, courier assignment, refund. Each fits on one screen. |
| Cross-cutting concepts | One page each for authentication, idempotency and retries, logging and personal data. These are the rules every team must follow. |
| Runbooks | One per alert that can wake someone up, linked from the alert itself. |
| Not written by hand | Class diagrams, endpoint lists and database schemas (generated in the pipeline); meeting notes; the history of how the system grew (the decision log and version history already tell it). |
Every item has a named reader, an owner and an update trigger. Documentation without an owner decays first.
The audit is served by the decision log, the deployment view and the version history, not by a separate audit document that would have to be kept consistent with them.
The whole set can be read in about two hours, which makes it plausible that newcomers will actually read it.
Questions people ask
Our code is clean and well tested. Is that not documentation enough?
Clean code and tests are excellent documentation of what the system does at a fine-grained level. They do not show the big picture across services and repositories, the quality goals, the constraints from outside the code, or why the structure is the way it is. Those are exactly what architecture documentation is for.
Who should write the architecture documentation?
The people who make and live with the decisions, which in most modern teams means engineers as well as architects. The architect usually owns the overall structure and consistency, and teams own the parts that describe their services. What matters most is that every document has a named owner.
How do we stop documentation going stale?
Keep it small, keep it next to the code, make updating it part of the definition of done for changes that affect it, generate what can be generated, and review it on a fixed rhythm. Section 4.7 covers these habits in detail.
Check your understanding
Name the three uses of architecture documentation identified in Views and Beyond.
Education (introducing people to the system), communication among stakeholders, and serving as the basis for analysis and construction.
Does "working software over comprehensive documentation" mean agile teams should not document their architecture?
No. The manifesto states that the items on the right still have value; it sets a priority when the two compete and rejects documentation produced for its own sake, not useful documentation.
Why should rationale be documented by hand while class diagrams generally should not?
Rationale cannot be recovered from the code and changes rarely, so it must be written by a person. Class structure can be read or generated from the code and changes often, so a hand-drawn copy quickly drifts.
What does "keep documentation current, but not too current" warn against?
Both stale documentation that misleads readers and constant churn from updating documents for every unsettled idea; update on a predictable rhythm once decisions are made.
Sources and further reading
Have a question about this section? ArchitectBot, the course’s AI study assistant, answers from the course first.
Ask: “We have a 300-page Confluence space nobody trusts. How do I decide what to keep, what to delete and what to rewrite?”