Software ArchitectureVol. 13 · Part XIII
0 / 0

Shelves / Software Architecture

SA·142

Architecture Decision Making

How architects decide and record decisions: what makes a decision architectural, the role of the architect, architecture decision records (formats, lifecycle, tooling), trade-off analysis with quality attribute scenarios, utility trees, ATAM-style evaluation and decision matrices, constraints and assumptions, risk identification and risk storming, reversibility (one-way versus two-way doors, last responsible moment, options thinking), technology selection (evaluation criteria, spikes, radar, boring technology), build versus buy, cost modelling with total cost of ownership, fitness functions to keep decisions true, and communicating architecture with C4 diagrams.

36 topics · ~23 min read · 31-question quiz
Updated Suggest a correction

Start here: deciding on purpose, and remembering why

An architectural decision is one that is expensive to reverse: monolith or services, which database, synchronous or event-driven, how modules depend on each other. Architecture work is mostly making those decisions well (explicit options, explicit criteria, evidence) and recording them so the people who live with them later know why. Three tools cover most of it: a trade-off analysis, an architecture decision record (ADR), and fitness functions that keep the decision true in the code.

A trade-off analysis, with a check on its fragility

Three options for the tiffin centre's next year, scored 1–5 on six quality attributes (scores informed by this volume's measurements, e.g. latency from chapter 140's 68 ns vs 273 µs), weighted by what matters to the business:

Text
weights: latency 3, deploy independence 2, operability 3, team autonomy 2, fault isolation 2, cost 3
  modular monolith                 59   ← winner
  monolith + 1 extracted service   56
  microservices                    46

A decision matrix is only as good as its weights, so the next step is a sensitivity analysis: how much must a weight change to flip the result?

Text
latency, operability, cost:                       no change of up to ±7 flips it
deploy independence, team autonomy, fault isolation: 2 → 6 flips it to "monolith + 1 extracted service"

The result is robust to how much you care about latency or cost, but it hinges on how much you value team independence. That is the real conversation to have with stakeholders. With 40 engineers in 6 teams (autonomy and independent deploys weighted 5), the ranking became 77 / 76 / 74, almost a tie, which says the decision should be made on something the matrix doesn't capture, such as the platform team's capacity to run many services.

Recording it: an ADR

Text
ADR-007: Keep a modular monolith; extract only the notifications service
Status: Accepted (2026-10-30)
Context: 2 teams, 8 engineers; p95 checkout budget 200 ms; notifications need independent scaling at lunch peaks.
Decision: One deployable with enforced module boundaries (import-linter contracts in CI); notifications as a separate service fed by the outbox.
Consequences: + simple operations, in-process calls, local transactions. − all teams share one release train; revisit when > 4 teams or deploy queue > 1 day.

An ADR is short, lives next to the code, is never edited after acceptance (a new ADR supersedes it), and names the condition under which to revisit it.

Keeping it true: fitness functions in CI

Text
PASS  dependency rules (hexagonal app)                    Contracts: 1 kept, 0 broken.
PASS  dependency rules (modular monolith)                 Contracts: 2 kept, 0 broken.
PASS  place() in-process budget < 20 µs                   0.5 µs per call
FAIL  no module over 1,000 lines (requests)               largest: models.py 1184 lines
FAIL  no function with complexity grade D or worse        RequestEncodingMixin._encode_files - D (21)
exit code 1

Each check turns a decision ("modules talk only through APIs", "in-process calls stay cheap", "no module grows past a size we can review") into a test. When one fails, the team either fixes the code or consciously changes the decision with a new ADR. Either is fine; drifting silently isn't.

How deep to go in architecture decision making

Volume 17 defines six mastery levels. For this chapter they look like this; the chapter aims at L3 everywhere, and its lab at L4.

Level What you can do
L1 Recognise architectural decisions and read an ADR
L2 Write ADRs for your team's decisions with context and consequences
L3 Run trade-off analyses with quality-attribute scenarios and sensitivity checks
L4 Turn decisions into fitness functions and use failures to revisit decisions
L5 Lead architecture decisions across a system with stakeholders, risks and evolution plans (ATAM-style)
L6 Establish decision processes, review boards and records across an organisation

What makes a decision architectural

Not every technical decision is architectural. A useful definition (Grady Booch): architecture represents the significant design decisions that shape a system, where significance is measured by cost of change. Architectural decisions typically:

  • Affect structure (components, boundaries, dependencies) or quality attributes (performance, availability, security, cost).
  • Are expensive to reverse (database choice, synchronous vs event-driven integration, tenancy model, programming language, cloud provider, API style for external clients).
  • Affect many teams or a long time horizon.
  • Carry significant risk or cost.

Choosing a JSON library is usually not architectural; choosing between a modular monolith and microservices, or between PostgreSQL and DynamoDB for the core ledger, is.

The architect's role

Whether the title is "architect", "staff/principal engineer" or simply the team, someone must:

  • Understand requirements and quality attributes (Vol. 12 ch. 121) and business context.
  • Identify architecturally significant decisions and make them explicitly, at the right time.
  • Analyse trade-offs, risks and costs; involve the people affected.
  • Record decisions and rationale; communicate the architecture (diagrams, docs).
  • Ensure decisions are implemented and remain valid (reviews, fitness functions).
  • Evolve the architecture as requirements change.

Modern practice favours architecture as a shared responsibility: decisions made close to the teams that live with them, with lightweight governance (an architecture advisory forum, RFC process, decision records) rather than an ivory-tower review board. Andrew Harmel-Law's "advice process" (Facilitating Software Architecture) captures this: anyone may make an architectural decision, provided they seek advice from those affected and those with expertise.

①trigger ②frame ③options ④analyse ⑤decide+ADR ⑥implement ⑦revisit seek advice from those affected and those with expertise (advice process) context, constraints, quality attribute drivers frame every step
A lightweight architecture decision loop. A need or problem surfaces; the decision maker frames context, constraints and quality attribute drivers; generates options; analyses trade-offs, risks and costs, seeking advice from those affected; decides and records an ADR; implements with fitness functions; and revisits when the context changes.

Architecture Decision Records

What and why

An Architecture Decision Record (ADR) (Michael Nygard, 2011) is a short document capturing one architecturally significant decision: its context, the decision, and its consequences. ADRs:

  • Preserve the why behind decisions for future engineers ("why on earth did they use X?"), preventing both blind acceptance and blind reversal.
  • Force clarity of reasoning and make trade-offs explicit.
  • Create a decision log showing the architecture's evolution.
  • Support onboarding and reviews.

ADRs are immutable once accepted: if a decision changes, write a new ADR that supersedes the old one, keeping history.

Formats

Nygard's original template:

Markdown
# ADR-023: Use event-driven integration between Ordering and Fulfilment

Date: 2026-10-24
Status: Accepted
Deciders: ordering team, fulfilment team, platform architect

## Context
Ordering currently calls Fulfilment synchronously when an order is paid. Fulfilment outages
(4 in Q3) caused checkout failures. Fulfilment processing takes 0.5–30 s. Order volume will
triple before the festive season. Both teams deploy independently.

## Decision
Ordering publishes an OrderPaid integration event via the transactional outbox to Kafka
(topic orders.order-events). Fulfilment consumes it idempotently and publishes
FulfilmentScheduled / FulfilmentFailed. Checkout no longer waits for Fulfilment.

## Consequences
+ Checkout availability no longer depends on Fulfilment.
+ Fulfilment can scale and deploy independently; backlog absorbs spikes.
- Order status is eventually consistent; UI shows "processing" until FulfilmentScheduled.
- Requires outbox relay, consumer idempotency, DLQ handling and lag monitoring.
- Teams must manage event schema evolution via the schema registry (BACKWARD_TRANSITIVE).
Revisit if fulfilment latency becomes a user-facing requirement.

Richer templates add sections for decision drivers, considered options with pros and cons, and confirmation: MADR (Markdown Any Decision Records) is popular:

Markdown
# Use PostgreSQL with Citus for multi-tenant invoicing data

## Context and Problem Statement
Invoicing data grows 2 TB/year; largest tenants exceed single-node write capacity by 2027.

## Decision Drivers
* Strong consistency for invoice numbering per tenant
* Team expertise in PostgreSQL
* Data residency per region
* Operational cost

## Considered Options
* PostgreSQL + Citus (distributed by tenant_id)
* CockroachDB
* DynamoDB

## Decision Outcome
Chosen option: "PostgreSQL + Citus", because it preserves SQL/transactions per tenant,
uses existing skills, and scales writes by tenant colocation.

### Consequences
* Good: single-tenant transactions remain local; existing tooling works.
* Bad: cross-tenant analytics need a separate warehouse; shard rebalancing must be planned.

### Confirmation
Load test at 3× projected 2027 volume before migration; ArchUnit rule that all
invoicing queries include tenant_id.

## Pros and Cons of the Options
### CockroachDB
* Good: automatic sharding and multi-region survival goals
* Bad: new technology for the team; higher latency for some transactions; licensing review needed
### DynamoDB
* Good: fully managed, effortless scaling
* Bad: invoice numbering and reporting queries need redesign; no SQL

Other formats: Y-statements ("In the context of …, facing …, we decided for … and neglected …, to achieve …, accepting that …"), Tyree & Akerman's detailed template, design-doc sections.

Practice

  • Store ADRs in the repository (docs/adr/0023-event-driven-fulfilment.md) next to the code they affect, reviewed via pull requests; or in a shared decision log for cross-cutting decisions.
  • Statuses: Proposed → Accepted → (Deprecated | Superseded by ADR-NNN); Rejected decisions are worth recording too.
  • Keep them short (one to two pages); link to longer design docs, spikes and benchmarks.
  • Tooling: adr-tools, Log4brains (static site), Backstage ADR plugin, simple Markdown with an index.
  • Write the ADR when the decision is made, not months later.

Trade-off analysis

"Everything in software architecture is a trade-off" (Richards & Ford's first law), and "why is more important than how" (their second law). Trade-off analysis makes the competing forces explicit.

Identify the drivers

Decision drivers come from:

  • Quality attributes ranked for this system (Vol. 12 ch. 121): availability, latency, consistency, security, cost, time to market, maintainability.
  • Constraints (below).
  • Business goals and risks.

Express key drivers as quality attribute scenarios (stimulus → environment → response → measure): "When a payment provider times out (stimulus) at peak load (environment), checkout completes or fails cleanly (response) within 3 s for 99.9% of requests (measure)."

Utility tree

A utility tree (from the SEI's ATAM) decomposes "utility" into quality attributes, refined attributes and concrete scenarios, each rated by business importance and technical difficulty (High/Medium/Low). Scenarios rated (H, H) get the most attention in design and evaluation:

Text
Utility
├── Performance
│   └── Latency: checkout p99 < 400 ms at 2,000 rps ............................ (H, M)
├── Availability
│   ├── Zone failure: checkout continues with < 1 min of errors .................. (H, H)
│   └── Payment provider outage: fail over to second provider within 30 s ........ (H, H)
├── Modifiability
│   └── Add a new payment method in < 2 weeks with one team ...................... (M, M)
├── Security
│   └── Card data never touches our servers (PCI scope minimised) ................ (H, L)
└── Cost
    └── Infra cost ≤ ₹2 per order at 3× current volume .......................... (M, H)

Evaluating options

Methods, from lightweight to formal:

  • Pros/cons lists per option against drivers (as in MADR).
  • Decision matrix (weighted scoring): weight each driver, score each option (1–5), compute weighted totals. Useful for structure and discussion; the numbers are not objective truth, so use them to surface disagreements ("why did you score operability 2?") and sanity-check the outcome.
  • Architecture Tradeoff Analysis Method (ATAM): a structured workshop evaluating an architecture against prioritised scenarios, identifying sensitivity points (decisions that strongly affect one quality attribute), trade-off points (decisions affecting several attributes in opposite directions), risks and non-risks. Heavier, useful for high-stakes systems; lightweight variants exist.
  • Prototypes and spikes: build the riskiest part quickly to replace opinions with evidence (benchmark, failure test, developer experience trial).
Driver (weight) PostgreSQL + Citus CockroachDB DynamoDB
Transactional consistency per tenant (5) 5 5 3
Team expertise / operability (4) 5 2 3
Write scalability (4) 4 5 5
Reporting/SQL flexibility (3) 5 4 2
Multi-region residency (3) 3 5 4
Cost at projected scale (3) 4 3 3
Weighted total 97 89 74

Trade-off thinking patterns

  • No best, only least-worst for this context: an option strong on everything usually has a hidden cost; find it.
  • Second-order effects: microservices improve deployability but worsen testability and data consistency; caches improve latency but add staleness and invalidation complexity.
  • Fallacies: "it worked at Netflix/Google" ignores different scale and context; resumé-driven design; sunk-cost reasoning.
  • Time: what's right for 10 engineers and 10k users may be wrong for 200 engineers and 100M users, and vice versa. Decide for the foreseeable horizon and design for evolution.

Constraints

Constraints are non-negotiable limits on the solution space (Vol. 12 ch. 121): budget, deadlines, team size and skills, regulations, existing systems and contracts, mandated technologies, licensing, data residency, hardware.

  • Distinguish real constraints from assumed ones ("we must use Oracle" may be a historical habit, not a contract). Challenge assumed constraints; write down real ones.
  • Constraints often decide the architecture before trade-off analysis begins (a two-person team can't operate thirty services; PCI requirements dictate tokenisation).
  • Record constraints in ADRs' context sections; when constraints change (a new regulation, a bigger team), revisit affected decisions.

Risk

Identifying risk

Architectural risk is the probability and impact of a decision or uncertainty causing failure to meet requirements. Common risk categories: performance/scalability unknowns, availability single points of failure, security exposures, data loss, integration with unfamiliar external systems, new technology, team skills, vendor dependency, cost overruns, regulatory changes.

Techniques:

  • Risk assessment matrix: likelihood × impact (low/medium/high) per component or area.
  • Risk storming (Simon Brown): team members independently mark risks on the architecture diagram (C4) with sticky notes coloured by severity, then discuss clusters and disagreements; fast and collaborative.
  • Pre-mortem: "it's a year from now and this project failed; why?" surfaces risks people hesitate to raise.
  • Threat modelling for security risks (Vol. 10 ch. 113).
impact highmedlow lowmediumhigh · likelihood new DB at 3× scale→ spike now single paymentprovider team new to Kafka→ training logging cost growth mitigateplanaccept
A risk matrix. Each architectural risk is placed by likelihood and impact; high-likelihood, high-impact risks need mitigation before committing, medium risks need monitoring or a spike, and low risks are accepted. Examples include an unproven database at the projected scale, a single payment provider, and the team's lack of Kafka experience.

Responding to risk

Mitigate (redundancy, spikes, prototypes, phased rollout, training), transfer (managed services, insurance, contracts), avoid (choose a different option), or accept (document it in the ADR with an owner and a trigger for revisiting). The architecture should reduce the biggest risks early: prototype the scariest integration first, load-test the unproven datastore before committing data to it.

Reversibility

One-way and two-way doors

Jeff Bezos' distinction: two-way doors (reversible decisions) should be made quickly by individuals or small teams; one-way doors (irreversible or very costly to reverse) deserve careful deliberation. Much organisational slowness comes from treating two-way doors like one-way doors.

Usually reversible (two-way) Usually costly to reverse (one-way-ish)
Internal library choice behind an interface Public API contracts with external clients
Feature flags, UI experiments Primary database for core data at scale
Internal service decomposition inside a modular monolith Data model for event-sourced history
Cloud instance types, managed service tiers Programming language/platform for a large codebase
CI tooling Tenancy model and data residency architecture
Logging format (with migration) Contracts with vendors (multi-year commitments)

Making decisions more reversible

  • Isolate decisions behind boundaries: ports and adapters (chapter 139), anti-corruption layers, abstraction of vendor SDKs, so changing an implementation doesn't ripple.
  • Prefer standards and portable formats (SQL, OpenTelemetry, OCI containers, Kubernetes APIs, open file formats like Parquet/Iceberg, OpenAPI) over proprietary ones when lock-in risk matters.
  • Incremental rollout with feature flags, canaries and parallel runs; strangler fig for migrations.
  • Data portability: export paths, CDC pipelines, schema evolution discipline.

Timing: the last responsible moment

Decide at the last responsible moment: the point at which delaying further would eliminate important options or cause costly rework. Deciding too early locks in choices with little information; deciding too late lets decisions be made implicitly by default (the codebase quietly commits to something). Meanwhile, keep options open cheaply (abstractions at known boundaries, spikes to gather information). This is real-options thinking: invest a little to preserve the option to choose later, when the cost of keeping the option open is lower than the expected value of better information.

Technology selection

Evaluation criteria

When choosing a language, framework, database, message broker, cloud service or SaaS product, evaluate:

Criterion Questions
Fit to requirements Does it meet functional needs and key quality attribute scenarios (measured, not assumed)?
Maturity and stability Production use at similar scale? Release cadence, breaking-change history, LTS policy?
Community and ecosystem Libraries, integrations, documentation, hiring market, Stack Overflow/issue activity
Vendor/project health Governance (foundation-backed like CNCF/Apache/Linux Foundation vs single vendor), funding, licence (and licence-change risk: Elasticsearch/OpenSearch, Redis/Valkey, Terraform/OpenTofu all changed in recent years)
Team skills Can the team build and operate it? Training cost?
Operability Monitoring, backups, upgrades, scaling, failure modes; managed offering availability
Security and compliance Vulnerability track record, certifications, data residency, supply chain
Cost Licences, infrastructure, operations effort, migration cost (TCO, below)
Lock-in and exit Standards support, data export, migration paths
Integration Fits existing platform, identity, observability, CI/CD

Process

  1. Define the problem and decision drivers (not "we want to use X").
  2. Shortlist 2–4 options (including "extend what we already have").
  3. Desk research, then spikes/proofs of concept on the riskiest criteria (performance under realistic load, a failure scenario, developer experience).
  4. Score, discuss, decide, record an ADR (including why alternatives lost).
  5. Pilot in a limited scope; expand with a migration plan.

Choose boring technology

Dan McKinley's "Choose Boring Technology": each organisation has a limited number of innovation tokens. Spending them on novel infrastructure (a new database, a new language) consumes attention on unknown failure modes rather than on the product. Prefer well-understood technologies whose failure modes are known, unless the new one solves a problem the boring ones genuinely can't. Corollary: minimise the number of different technologies (each adds operational and cognitive cost).

Technology radars (ThoughtWorks' public radar, internal radars) classify technologies as Adopt / Trial / Assess / Hold to guide teams and share experience across an organisation.

Build versus buy

For each capability, choose among build (custom software), buy (commercial product or SaaS), adopt (open source, self-hosted or managed), or compose (integrate platforms with custom glue).

Use the subdomain classification (chapter 138) as the first filter:

  • Core domain (competitive differentiator): build, invest deeply.
  • Supporting subdomain: build simply or buy/adapt if a good fit exists.
  • Generic subdomain (identity, payments processing, email delivery, observability, CRM, accounting, search infrastructure, feature flags): buy or adopt, almost always.

Factors:

Factor Favouring build Favouring buy/adopt
Strategic value Differentiates the business Commodity capability
Fit Requirements are unique Off-the-shelf meets 80%+
Time to market Can wait Needed now
Expertise Have/want deep expertise Specialised domain (e.g. payments compliance, identity security)
Total cost Volume makes vendor pricing prohibitive Building + operating + maintaining costs more
Control and lock-in Need full control over roadmap/data Acceptable vendor dependency with exit path
Compliance Vendor can't meet requirements Vendor certified (SOC 2, PCI DSS, ISO 27001) reduces your burden

Hidden costs of building: ongoing maintenance, security patching, on-call, documentation, staff turnover, opportunity cost of not building the core product. Hidden costs of buying: integration and customisation, per-seat/usage pricing at scale, vendor lock-in, data access limitations, vendor roadmap mismatch, vendor risk (acquisition, shutdown, price increases), compliance review. Mitigate buy risks with abstraction layers (adapters), data export guarantees and exit plans.

Cost modelling

Total cost of ownership

Compare options on total cost of ownership (TCO) over a realistic horizon (3–5 years), not just sticker price:

Cost element Examples
Infrastructure Compute, storage, network/egress, managed service fees, licences
People Development, operations/on-call, platform engineering, training, hiring premium for rare skills
Migration Data migration, dual running, retraining, rewriting integrations
Ongoing change Upgrades, security patches, vendor-driven changes
Risk Expected cost of outages, data loss, security incidents (likelihood × impact)
Opportunity cost Product work not done because engineers maintain undifferentiated systems
Exit Cost to leave (data egress, contract penalties, rewrite)
Python
# A tiny TCO model: make assumptions explicit and compare options under scenarios
from dataclasses import dataclass

@dataclass
class Option:
    name: str
    infra_per_month: float          # ₹ at today's volume
    infra_elasticity: float         # infra cost grows as volume ** elasticity (1.0 = linear, 0 = flat)
    ops_fte: float                  # engineers needed to operate it
    build_engineer_months: float    # one-off setup/migration effort
    licence_per_year: float = 0.0

FTE_MONTH = 3_00_000                # ₹ fully loaded cost per engineer-month (assumption)

def tco(o: Option, years: int = 3, growth_per_year: float = 2.0) -> float:
    total = o.build_engineer_months * FTE_MONTH
    volume = 1.0
    for _ in range(years):
        total += o.infra_per_month * 12 * volume ** o.infra_elasticity
        total += o.licence_per_year + o.ops_fte * 12 * FTE_MONTH
        volume *= growth_per_year
    return total

options = [
    Option("Self-hosted Kafka", infra_per_month=1_50_000, infra_elasticity=0.8, ops_fte=1.0, build_engineer_months=3),
    Option("Managed Kafka (vendor)", infra_per_month=3_50_000, infra_elasticity=1.0, ops_fte=0.2, build_engineer_months=1),
]
for o in options:
    print(f"{o.name:24} 3-year TCO ≈ ₹{tco(o) / 1e7:.1f} crore")
# Self-hosted Kafka        3-year TCO ≈ ₹2.2 crore
# Managed Kafka (vendor)   3-year TCO ≈ ₹3.2 crore
# With these assumptions self-hosting wins; price in on-call burden, hiring risk or slower growth
# and the answer can flip. The point is that the assumptions are visible and testable.

(The model is deliberately simple; what matters is writing assumptions down so they can be challenged, varying them to see which ones dominate, and updating them with real data.)

Cost as an architectural characteristic

  • Make cost a quality attribute with targets (cost per order, per active user, per GB processed).
  • Architecture drives cost: data transfer between regions/AZs, chatty microservices, over-replication, unbounded logs and metrics cardinality, idle provisioned capacity, premium managed services.
  • FinOps practices (Vol. 7 ch. 91): tagging and allocation by team/service, budgets and anomaly alerts, unit economics dashboards, rightsizing, commitments for steady workloads, spot/preemptible capacity for tolerant workloads.
  • Revisit decisions as scale changes: managed services win at small scale; at very large scale, self-operation or architecture changes may pay off (and the reverse when teams are small).

Keeping decisions true: fitness functions

An architectural fitness function (Ford, Parsons, Kua, Building Evolutionary Architectures) is an automated check that an architectural characteristic still holds. Fitness functions turn decisions into executable guardrails:

Characteristic Fitness function
Module boundaries ArchUnit/Spring Modulith/import-linter/Nx rules in CI (chapter 140)
Layering / dependency rule Tests forbidding domain packages from importing frameworks
Performance Load test thresholds in CI (k6 p95 < 300 ms), benchmark regression checks
Availability Chaos experiments with steady-state probes on a schedule
Security Dependency vulnerability gates, secret scanning, policy-as-code (OPA) on infrastructure
API compatibility buf breaking, oasdiff, schema registry compatibility checks
Cost Budget alerts; infrastructure cost estimates in pull requests (Infracost)
Observability Lint that every service exports required metrics/traces; SLOs defined in the catalogue
Java
// Fitness function as a test: the ledger module must never call payment providers synchronously
@ArchTest
static final ArchRule ledgerIsolatedFromProviders = noClasses()
    .that().resideInAPackage("com.shop.ledger..")
    .should().dependOnClassesThat().resideInAnyPackage("com.shop.payments.providers..", "com.stripe..", "com.razorpay..")
    .because("ADR-031: the ledger records facts from events only; provider calls belong to payments");

Communicating architecture

Decisions only help if people understand the resulting architecture.

The C4 model

Simon Brown's C4 model describes software architecture at four zoom levels, with simple notation:

  1. System context: the system as a box, its users (people) and external systems it interacts with.
  2. Containers: deployable/runnable units (web app, mobile app, API service, database, message broker) and how they communicate.
  3. Components: major components inside a container (modules, controllers, services, repositories).
  4. Code: classes/functions (rarely drawn by hand; generate from code if needed).

Plus supplementary diagrams: deployment, dynamic (sequence of interactions for a use case), system landscape.

① contextcustomershop systempayment PSP ② containersweb appAPIdatabasebroker ③ componentscontrollersorderingrepositories ④ codeclasses,functions(generated) zoom in for the audience: executives ① · developers ②③ · rarely ④
The C4 model's zoom levels. The system context shows the system, its users and external systems; zooming in, the container diagram shows applications, services and data stores; zooming into one container, the component diagram shows its major components; the code level is usually generated rather than drawn.

Tools: Structurizr (DSL, diagrams as code from one model), PlantUML C4, Mermaid C4 diagrams, IcePanel, LikeC4. Keep diagrams as code next to the system, version-controlled, with a title, legend, and key to every box and arrow (technology and purpose on relationships).

Documentation

  • arc42 template: a comprehensive structure for architecture documentation (context, constraints, solution strategy, building blocks, runtime and deployment views, crosscutting concepts, decisions, quality requirements, risks, glossary). Use the sections you need.
  • Living documentation: README per service/module, ADR index, C4 diagrams, API specs, runbooks, service catalogue entries, generated module documentation (Spring Modulith, Structurizr from code).
  • Architecture katas (practice exercises designing for a brief with constraints) and design reviews build shared judgement across a team.

Lab: a sensitivity-checked decision and a fitness-function suite

Python 3.13 on the lab machine: a weighted decision matrix with automatic sensitivity analysis, and a fitness-function runner combining import-linter (the projects from chapters 139 and 140), a performance budget, and size and complexity limits checked with radon 6.0 against the requests source from chapter 135.

Experiment 1: decision matrix and sensitivity

Attribute (weight) Modular monolith Microservices Monolith + 1 service
latency (3) 5 2 4
deploy independence (2) 2 5 3
operability (3) 5 2 4
team autonomy (2) 3 5 4
fault isolation (2) 2 4 3
cost (3) 5 2 4
total 59 46 56
Text
sensitivity (smallest single-weight change that changes the winner):
  latency, operability, cost: none within ±7
  deploy independence 2 → 6, team autonomy 2 → 6, fault isolation 2 → 6: → monolith + 1 extracted service
with autonomy 5 and deploy independence 5:  77 / 76 / 74 (near tie)

Two cautions about matrices. Scores on a 1–5 scale hide magnitudes: chapter 140 measured a 4,000× latency difference, which a "5 vs 2" can't express, so keep the raw evidence next to the scores. And correlated attributes (autonomy and deploy independence both measure team independence) double-count; merging them would make the flip harder. The ATAM method (Architecture Tradeoff Analysis Method, SEI) formalises this into utility trees of prioritised quality scenarios, sensitivity points and trade-off points; a matrix with a sensitivity check is its lightweight cousin.

Experiment 2: fitness functions as one CI step

Python
check("dependency rules", subprocess.run(["lint-imports"], cwd=proj).returncode == 0, ...)
check("place() in-process budget < 20 µs", us < 20, f"{us:.1f} µs per call")
check("no module over 1,000 lines", biggest[0] <= 1000, ...)
check("no function with complexity grade D or worse", not worst, ...)
sys.exit(0 if all(ok for _, ok, _ in results) else 1)
Fitness function Result Evidence
dependency rules (hexagonal app) PASS 1 kept, 0 broken
dependency rules (modular monolith) PASS 2 kept, 0 broken
in-process place() < 20 µs PASS 0.5 µs
no module > 1,000 lines (requests) FAIL models.py 1,184 lines
no function grade D or worse (requests) FAIL _encode_files D (21)

The two failures are on purpose: thresholds applied to code that predates them. Teams introducing fitness functions to an existing codebase usually ratchet: record today's worst values as the limit and fail only if things get worse, tightening over time. Kinds of fitness functions worth having: structural (dependency rules, cycles, layer violations), operational (latency and error budgets from load tests, Volume 11 chapter 119), security (no secrets, dependency scanning, Volume 10 chapter 112), data (no cross-module schema access), and evolutionary (build time, deploy frequency).

Experiment 3: an ADR log that stays useful

Store ADRs as Markdown in docs/adr/NNNN-title.md (Michael Nygard's format, or MADR), number them, and link superseded ones. Practical tests of a healthy log: a new engineer can answer "why don't we use microservices?" from it in five minutes; every fitness function names the ADR it protects; and every ADR has a revisit condition that someone checks.

Try it yourself

  1. Add a fourth option (serverless functions) to the matrix with your own evidence-backed scores and rerun the sensitivity analysis.
  2. Merge "team autonomy" and "deploy independence" into one attribute and see how far a weight must move to flip the result.
  3. Change the size and complexity checks to ratchets that read their limits from a committed baseline file.
  4. Write ADR-008 superseding ADR-007 under the condition "6 teams", and the fitness functions that the new decision needs.

Revision sheet: architecture decision making

Key ideas

  • Architectural decisions: costly to reverse, system-wide in effect (structure, technology, integration, data, deployment).
  • The architect's role: make trade-offs explicit, gather evidence, involve stakeholders, record decisions, keep them true; "last responsible moment" for irreversible choices.
  • Quality attribute scenarios: stimulus, environment, response, measure (e.g. "at 100 orders/s, p95 checkout < 200 ms").
  • Trade-off analysis: options × criteria with evidence; sensitivity analysis; ATAM's utility tree, sensitivity and trade-off points.
  • ADRs: context, decision, status, consequences, revisit conditions; immutable once accepted; superseded, not edited.
  • Fitness functions: automated checks of architectural properties in CI; ratchets for legacy code.
  • Reversibility: prefer decisions that are cheap to undo (two-way doors) and invest analysis in one-way doors.

Numbers to remember

  • Lab: base matrix 59 / 56 / 46; a single weight change 2 → 6 flipped the winner; team-heavy weights made it a near tie (77/76/74).
  • Lab: fitness suite 3 PASS / 2 FAIL (models.py 1,184 lines; _encode_files CCN 21).

Pitfalls

  • Decisions by fashion or résumé; missing alternatives.
  • Matrices treated as objective; no sensitivity check; double-counted criteria.
  • Decisions recorded nowhere, or in chat threads.
  • ADRs edited after the fact; no revisit conditions.
  • Rules without fitness functions (or fitness functions silenced when they fail).
  • Analysis paralysis on reversible decisions.

Glossary

  • ATAM: SEI's Architecture Tradeoff Analysis Method.
  • Utility tree: prioritised quality-attribute scenarios.
  • Sensitivity point: a parameter a quality attribute strongly depends on.
  • One-way / two-way door: irreversible / reversible decision.
  • Ratchet: a limit that may only tighten.