Documenting architecture: ADRs (format, lifecycle, where they live), C4 diagrams as code, and fitness functions (architecture tests, performance and dependency checks) that keep docs and code aligned.
I use three tools that reinforce each other. Architecture Decision Records capture each significant decision in one short page: context, decision, alternatives, consequences and status. They live in the repo and are reviewed by pull request; when a decision changes, a new ADR supersedes the old one.
The C4 model gives diagrams at the right zoom level: System Context for stakeholders, Containers for engineers, Components where it helps. I keep them as code (Structurizr DSL or Mermaid) so they're versioned.
Fitness functions stop the docs from lying: architecture tests (ArchUnitNET), load tests and dependency checks that fail the build when the code drifts from the decisions.
The trade-off: documentation costs time, so I keep it small and automate the checks instead of writing long documents nobody reads.
"I want architecture documentation that answers two questions for someone joining next year: what does the system look like, and why is it like this? For the 'why', I use Architecture Decision Records. Each ADR is one page in
docs/adrin the repo: the context, the decision, the options we rejected, and the consequences, good and bad. They're reviewed by pull request like code, numbered, and never rewritten; if we change our mind, a new ADR supersedes the old one, so the history stays honest.For the 'what', I use the C4 model. A System Context diagram shows the system, its users and external systems, which is what stakeholders and security reviewers need. A Container diagram shows the deployables and data stores: the API, the worker, Azure SQL, Service Bus. I only go down to Components for complex areas, and almost never to Code. I keep the diagrams as code in Structurizr DSL or Mermaid in the same repo. For example, at [company] our architecture lived in a [Confluence page last updated two years earlier]. I moved it into the repo as [12] ADRs reconstructed with the team, plus C4 context and container diagrams, and linked each key ADR to a fitness function, such as an ArchUnitNET test that Billing can't reference Ordering internals, and a load test enforcing our p95 target. Onboarding time for new engineers went from [about four weeks] to [two], and the architecture tests caught [nine] boundary violations in the first quarter.
The mistake I see is big up-front documents that are out of date in a month. My senior line is: write down decisions, not descriptions, and let automated checks keep the description true."
| Tool | Answers | Audience | Lives in |
|---|---|---|---|
| ADRs | Why is it like this? | Engineers, future maintainers, reviewers | docs/adr/NNNN-title.md |
| C4 diagrams | What does it look like at each zoom level? | Stakeholders (Context), engineers (Containers/Components) | Diagrams as code in the repo |
| Fitness functions | Is it still true? | CI pipeline | Test projects, pipeline steps, monitoring |
| Level | Shows | Use it for |
|---|---|---|
| 1. System Context | System, users, external systems | Stakeholders, security and privacy reviews |
| 2. Containers | Deployables and data stores, protocols | Engineering, operations, threat modelling |
| 3. Components | Major parts inside one container | Complex containers only |
| 4. Code | Classes | Rarely; generate from IDE if needed |
| Decision (ADR) | Fitness function |
|---|---|
| Modules communicate only via contracts | ArchUnitNET test in CI |
| p95 < 300 ms for search | Azure Load Testing run with pass/fail criteria |
| No known critical vulnerabilities | dotnet list package --vulnerable failing the build |
| Personal data stays in Australia East | Azure Policy allowed-locations assignment |
| Availability 99.9% | SLO burn-rate alert in Azure Monitor |
Moving architecture docs into the repo as ADRs and C4-as-code, with fitness functions for the top decisions, halved onboarding time from [four] to [two] weeks and caught [nine] boundary violations in CI in the first quarter.
Checks whether the candidate can make architecture knowledge durable and enforceable, and use documentation to build alignment.
Green flags
Red flags
Code shows what the system does; it rarely shows why. The why is lost first: people leave, chat history disappears. Michael Nygard's ADR format (2011) keeps it lightweight enough that people actually write them.
# 0007. Use a modular monolith on Azure App Service
Status: Accepted (supersedes 0002)
Date: 2026-03-14
## Context
One team of 6, ~40 req/s peak, rules change each budget cycle, data must stay in Australia East.
## Decision
Single deployable with modules per subdomain; schema per module in one Azure SQL database.
## Alternatives considered
Microservices on AKS (rejected: ops cost, team size). Plain layered monolith (rejected: weak boundaries).
## Consequences
+ Low ops cost, simple deploys. - Must enforce boundaries with tests. Revisit if > 3 teams or > 500 req/s.
Statuses: Proposed → Accepted → (Deprecated | Superseded by NNNN). Tooling such as adr-tools or log4brains helps but isn't required.
Architecturally significant ones: hard to reverse, affect quality attributes, cross teams, or surprised someone. Examples: choosing a message broker, data ownership rules, authentication approach, the decision not to use microservices. Skip trivial library choices.
Simon Brown's C4 uses a small vocabulary: people, software systems, containers (deployable or data store, not Docker specifically), components.
Level 1: System Context
[Broker] ──uses──► [Quoting System] ──sends email via──► [SendGrid]
│
└──reads policies from──► [Legacy Policy Admin]
Level 2: Containers (inside Quoting System)
[Web app: Blazor] ──HTTPS/JSON──► [API: ASP.NET Core] ──EF Core──► [Azure SQL]
│
└──AMQP──► [Service Bus] ──► [Worker: .NET]
Diagrams as code (Structurizr DSL, Mermaid C4Context, PlantUML C4) put diagrams under version control and in pull requests. Some teams also generate a live view from telemetry, such as the Application Insights application map, and compare it with the intended container diagram.
From Building Evolutionary Architectures (Ford, Parsons, Kua): an objective function that assesses how close the system is to an architectural characteristic. Kinds:
In .NET: ArchUnitNET or NetArchTest for dependency rules, Roslyn analysers for coding rules, BenchmarkDotNet for micro-performance, Azure Load Testing or k6 for throughput, dotnet list package --vulnerable for supply chain, Azure Policy for infrastructure rules, SLO alerts for availability.
The same decision needs different framing: a one-paragraph business summary for leadership (cost, risk, time), a C4 container diagram for engineers, a threat model for security. Writing an ADR as a Proposed decision and inviting comments by PR is a low-friction way to build consensus and record dissent.
Linking an ADR to a fitness function: an ArchUnitNET test that enforces the module boundary decision.
namespace Quoting.ArchitectureTests;
using ArchUnitNET.Domain;
using ArchUnitNET.Loader;
using ArchUnitNET.xUnit;
using static ArchUnitNET.Fluent.ArchRuleDefinition;
public class ModuleBoundaryTests
{
private static readonly Architecture Architecture = new ArchLoader()
.LoadAssemblies(typeof(Billing.Core.BillingModule).Assembly,
typeof(Ordering.Core.OrderingModule).Assembly)
.Build();
// Enforces ADR-0007: modules communicate only through *.Contracts.
[Fact]
public void Billing_does_not_depend_on_Ordering_internals() =>
Types().That().ResideInNamespace("Billing", useRegularExpressions: false)
.Should().NotDependOnAny(Types().That().ResideInNamespace("Ordering.Core"))
.Because("ADR-0007: modules may only reference other modules' Contracts")
.Check(Architecture);
}
workspace "Quoting" {
model {
broker = person "Broker"
quoting = softwareSystem "Quoting System" {
web = container "Web app" "Blazor"
api = container "API" "ASP.NET Core 10"
db = container "Database" "Azure SQL (Australia East)"
}
broker -> web "Creates quotes"
web -> api "HTTPS/JSON"
api -> db "EF Core"
}
views { container quoting { include * autolayout lr } }
}
# Pipeline fitness function: fail on known vulnerable packages.
- script: |
dotnet list package --vulnerable --include-transitive | tee vuln.txt
! grep -q "has the following vulnerable packages" vuln.txt
displayName: Fail on vulnerable packages
Documentation is an influence tool, not just a record. A Proposed ADR raised as a pull request gives everyone a place to disagree in writing, and the final ADR records the dissent and the reasons. When I disagree with a decision but the team goes another way, I make sure the ADR captures the risk and a revisit trigger, then commit to it fully.
The automation is what makes documentation trustworthy. I aim for every high-impact ADR to have at least one fitness function; if a decision can't be checked automatically, I add it to a lightweight quarterly review.
| Option | When it fits | Cost | When not to |
|---|---|---|---|
| ADRs in repo | Any team making significant decisions | Low | Trivial, easily reversed choices |
| C4 Context + Containers | Every system | Low | — |
| C4 Components | Complex containers, onboarding hot spots | Medium | Simple CRUD services |
| Fitness functions in CI | Rules that can be checked statically or by test | Low-medium | Rules needing human judgement |
| Wiki-only docs | Non-engineering audiences | Low | Anything that must stay in sync with code |
Evolutionary architecture (Ford, Parsons and Kua) is architecture designed to support guided, incremental change, rather than a fixed upfront design. The key tool is fitness functions: automated checks that protect the characteristics you care about, such as dependency rules (architecture tests), latency budgets, or startup time, run in CI or production. Around that, I keep boundaries modular (often a modular monolith first), make decisions reversible where possible and defer irreversible ones to the last responsible moment, record decisions in ADRs, and rely on continuous delivery, feature flags and observability so each change is small and safe.
Make the rules executable at several levels:
internal hides implementation types so other projects can't use them.Microsoft.EntityFrameworkCore", "Billing may only use Orders.Contracts". ArchUnitNET (actively maintained) or NetArchTest (the original is unmaintained since 2021; the eNhancedEdition fork is maintained) inspect compiled assemblies inside a normal test run.DateTime.Now.Roll out with a baseline so legacy violations don't block the build. The trade-off: cheap, fast feedback, but only for static dependencies.
I start from the business drivers, not the technology. I ask what the system must be good at and turn that into a short, ranked list of quality attributes: scalability, availability, modifiability, security, cost. Then I make each one measurable as a quality attribute scenario ("p95 under 300 ms at 500 requests a second"), and I list the constraints I can't change: budget, deadline, compliance such as data staying in Azure Australia East, and the team's size and skills.
The trade-off is always the same: the architecture that best serves the top two attributes will be worse at something else, and I want that cost written down.
How to tell it (STAR)
**S:** At [company] our architecture docs were two years out of date, onboarding took about [four weeks], and modules were calling each other's internals. **T:** I volunteered to make the architecture understandable and enforceable. **A:** I recovered [12] key decisions with the team as ADRs in the repo, drew C4 Context and Container diagrams as code, and linked the main decisions to ArchUnitNET tests and pipeline checks. I added an ADR prompt to the PR template so new decisions get recorded. **R:** Onboarding dropped to about [two weeks], and the tests caught [nine] boundary violations in the first quarter before they merged.
Last updated 23 Nov 2026.