Skip to content

Lesson 27 of 28Decisions and evolution

Evolutionary Architecture and Conway's Law

Pick the qualities that matter, guard them with automated fitness functions, shape teams and systems together, and change a live system in small steps.

21 min read0/5 questions

Two years ago your team drew a clean architecture on a whiteboard: API layer, services, domain, a billing module nobody else touches. Today the domain imports from the API layer in a dozen places, catalog reads billing's private tables, and p95 checkout latency has crept from 180 ms to 900 ms. Nobody decided any of this. Each change was small and reasonable, and nothing checked the whole. Evolutionary architecture is the practice of expecting change, deciding which qualities must survive it, and checking those qualities automatically, so the system can keep changing without quietly rotting. It is also where senior engineers spend much of their time: less on drawing the first diagram, more on keeping the tenth year healthy.

Architecture is the stuff that is hard to change

Ralph Johnson's definition, popularised by Martin Fowler, is the useful one at work: architecture is the set of decisions that are expensive to change later. Your choice of web framework, the boundary between billing and orders, whether services share a database, how data is partitioned. Naming a variable is not architecture. Choosing a primary key format that is embedded in every URL, every log, and three partner integrations is.

Those decisions should be driven by architecture characteristics, often called the "-ilities": scalability, availability, deployability, testability, security, auditability, and so on. The trap is wanting all of them. They pull against each other. Strong auditability (every change recorded and immutable) costs write throughput and storage. Extreme availability across regions costs consistency and money. Maximum deployability (many independent services) costs operational simplicity.

So pick the top three for this system, from the business, not from fashion. A payments ledger might choose auditability, correctness, and availability. A marketing site might choose performance, deployability, and cost. Write them down, usually in an ADR (see ADRs and Async Written Updates in the Engineering at Work course), and use them as the tie-breaker in every later argument. "Would this hurt auditability?" ends many debates faster than opinions do.

A characteristic only counts if you can measure it. "Scalable" is a wish. "Handles 3x today's peak with p95 under 300 ms" is a target you can test.

Fitness functions: tests for the architecture

A fitness function, a term from Building Evolutionary Architectures by Neal Ford, Rebecca Parsons and Patrick Kua, is any objective, automated check that tells you whether the system still has a characteristic you care about. Unit tests protect behaviour. Fitness functions protect the shape and qualities of the whole.

CharacteristicFitness functionTooling examples
MaintainabilityDomain never imports from the API layer; no import cyclesimport-linter (Python), dependency-cruiser (JS/TS), ArchUnit (JVM)
ModularityNothing outside billing imports billing's private modulesSame tools, plus CODEOWNERS on boundaries
PerformanceCheckout p95 under 300 ms in a load testk6 or Gatling thresholds in CI
Frontend performanceMain bundle under a size budgetsize-limit, Lighthouse CI
SecurityNo dependency with a known critical vulnerabilityDependabot, Renovate, npm audit, pip-audit
AvailabilityThe system survives losing one instanceChaos experiments in staging

They come in a few flavours, and naming them helps you choose:

  • Atomic checks one thing in one context (a dependency rule). Holistic checks how several characteristics interact (a load test with security middleware switched on, because encryption costs latency).
  • Triggered runs on an event, usually every pull request. Continuous runs all the time in production, like an alert when p95 latency breaks its budget for ten minutes.
  • Static has a fixed pass mark (bundle under 200 kB). Dynamic scales with context (latency budget that depends on payload size).

Here is a dependency rule fitness function, the most common kind, built from Python's own ast module so you can see there is no magic:

Python
import ast # A tiny codebase, as {module: source}. In CI you would read real files.CODE = { "shop.api.orders": "from shop.services import checkout\n", "shop.services.checkout": "from shop.domain import order\nfrom shop.billing import api\n", "shop.domain.order": "from shop.api import orders\n", # domain reaching up "shop.billing.api": "from shop.billing import _ledger\n", "shop.billing._ledger": "", "shop.catalog.search": "from shop.billing import _ledger\n", # reaching into a private module} LAYERS = ["shop.api", "shop.services", "shop.domain"] # top to bottom def imports(src: str) -> list[str]: found = [] for node in ast.walk(ast.parse(src)): if isinstance(node, ast.ImportFrom) and node.module: found += [f"{node.module}.{a.name}" for a in node.names] elif isinstance(node, ast.Import): found += [a.name for a in node.names] return found def layer_of(mod: str) -> int | None: for i, prefix in enumerate(LAYERS): if mod.startswith(prefix): return i return None def violations() -> list[str]: out = [] for mod, src in CODE.items(): for target in imports(src): a, b = layer_of(mod), layer_of(target) if a is not None and b is not None and b < a: out.append(f"layer: {mod} -> {target}") pkg = target.rsplit(".", 1)[0] private = target.rsplit(".", 1)[1].startswith("_") if private and not mod.startswith(pkg): out.append(f"private: {mod} -> {target}") return out found = violations()for v in found: print(v) # Ratchet: the count may go down, never up.BASELINE = 1print(f"{len(found)} violations, baseline {BASELINE}:", "FAIL" if len(found) > BASELINE else "PASS")
Output
Press Run (⌘ Enter) to see what happens.

The last two lines are the trick that makes fitness functions survive on a legacy codebase. If you turn on a strict rule and it reports 400 violations, the team disables it within a week. A ratchet records today's count as the baseline and fails only if the count goes up. Every fix lowers the baseline. The architecture improves one pull request at a time, and nobody has to stop for a cleanup sprint.

Predict the outputPython

Someone deletes the import in shop.domain.order, leaving its source as an empty string. What is the last line printed?

CODE["shop.domain.order"] = ""
found = violations()
print(f"{len(found)} violations, baseline {BASELINE}:", "FAIL" if len(found) > BASELINE else "PASS")
Need a nudge? Hints walk you through it.

In a real Python repo you would not write this yourself. import-linter expresses the same rules as config:

.importlinter
[importlinter]
root_package = shop
 
[importlinter:contract:layers]
name = API, services, domain only depend downwards
type = layers
layers =
    shop.api
    shop.services
    shop.domain

And a latency budget looks like this in a k6 load test, where the run fails if the threshold is missed:

load/checkout.js
export const options = {
  thresholds: {
    http_req_duration: ["p(95)<300"], // milliseconds
    http_req_failed: ["rate<0.01"],
  },
};
Match the pairs0/5 matched

Match each architecture characteristic to the fitness function that best protects it.

Choose an item, then its match on the other side.

Decide late, keep it reversible

Agile thinking gives a useful rule for big decisions: make them at the last responsible moment, the latest point at which not deciding would start to cost you. Before then, you know less than you will. After it, you are paying for the delay. This is not procrastination. It means building so that the decision stays open: an interface in front of the search engine, so choosing between Postgres full-text search and a dedicated engine can wait until you have real query data.

Amazon's version is one-way and two-way doors. Most decisions are two-way: if you are wrong, you walk back through. Make those fast, with small teams and little ceremony. A few are one-way, like a public API shape, a data model that partners copy, or deleting data. Those deserve the slow process, the design doc, and the review. A common failure in big companies is treating every decision as one-way, which makes everything slow.

Two design habits keep more doors two-way:

  • Design for replaceability over reuse. A shared library used by twelve services is very hard to change. A thin adapter around your email vendor, used in one place, can be swapped in a day. Ask "how would I rip this out?" before "how could others reuse this?".
  • Accept sacrificial architecture. Fowler's term for code you build knowing it will be replaced when the business outgrows it. A startup's first monolith is meant to be thrown away in parts. Planning for that, with clean module seams, is better than over-building for a scale you may never reach.
Quick check
Your team must choose a message broker for a new feature. Traffic is unknown and you have two weeks. What is the most evolutionary approach?
Need a nudge? A hint rules out a wrong answer.

Conway's law

In 1968 Melvin Conway wrote that organisations which design systems are constrained to produce designs that copy their communication structures. Four teams building a compiler produce a four-pass compiler. This is not a slogan, it is a force. Where two teams talk rarely, an interface appears between their code, whether anyone drew it or not. Where one team owns two "separate" services, those services tend to grow tightly coupled, because talking to yourself is free.

The system copies the org chart
Checkout teamCheckout teamCatalog teamCatalog teamPlatform teamPlatform teamcheckoutcheckoutcatalogcatalogdeploy + observability: paved roaddeploy + observabilitypaved roadshared tablesshared tablesownsownsownsAPI

Three teams. Each one talks mostly to itself and occasionally to the others.

1/5

The inverse Conway manoeuvre uses the law on purpose: if you want a given architecture, shape the teams first, and the code follows. Want billing to be a separate, independently deployable module? Give it a dedicated team with its own backlog. Reorganising without changing the architecture, or the other way round, usually fails, because the two pull each other back.

Team Topologies (Matthew Skelton and Manuel Pais) gives a vocabulary for this that many companies now use:

  • Stream-aligned teams own a slice of the product end to end (checkout, search). Most teams should be this kind.
  • Platform teams provide internal services as self-service products (CI, deploy, observability) so stream teams do not each rebuild them.
  • Enabling teams coach other teams in a skill (testing, performance) for a while, then move on.
  • Complicated-subsystem teams own something that needs rare expertise (a pricing engine, video encoding).

Their key signal is cognitive load. If one team must hold six services, three languages and on-call for all of them in their heads, that boundary is wrong, however neat the diagram looks. Right-sized boundaries are ones a single team can fully understand.

Quick check
Two services were split for independence, but every release needs both teams to coordinate, and they share a database. What does Conway's law suggest is the most likely root cause?
Need a nudge? A hint rules out a wrong answer.

Changing a running system in small steps

Evolution needs mechanics that let you change production without a big-bang release. You have met some of these elsewhere. Here they are together, as a toolkit:

  • Feature flags separate deploying code from releasing it. Ship dark, turn on for staff, then 5% of users. Keep flags short-lived and give each one an owner and an expiry date, or they become the next layer of debt.
  • Dark launches run new code on real traffic without showing the result. Mirror requests to the new path and compare outputs and latency.
  • Canary releases send a small slice of traffic to the new version and promote it only if error rates and latency stay inside their budget. This is a continuous fitness function wired to the deploy.
  • Branch by abstraction puts an interface in front of the thing you are replacing, so old and new implementations live side by side in main.
  • The strangler fig, from Monolith vs Microservices, applies the same idea at the routing level for whole capabilities.
  • Expand and contract migrations change a database schema without downtime, the same pattern you would use for an API field rename.
Put it in order6 steps

Order the steps to move a name column into separate first_name and last_name columns with zero downtime.

  1. Tap the steps below in the right order.
Need a nudge? A hint shows where it starts.

Governance without an ivory tower

Someone still has to keep the big picture coherent. The old model, an architecture board approving designs from above, is slow and gets bypassed. What works better in most companies combines a few lightweight pieces:

  • Paved roads (Netflix's term) or golden paths (Spotify's): a supported, documented default way to build a service, with CI, logging, auth and deploys already wired. Teams can leave the road, but then they own the cost. Most stay, and consistency follows without a mandate.
  • RFCs and design docs for one-way-door decisions, with open review, and ADRs to record what was decided and why. The Engineering at Work course teaches both, in Design Docs and RFCs and ADRs and Async Written Updates.
  • A tech radar, popularised by Thoughtworks, listing tools as adopt, trial, assess or hold, so teams know what is supported.
  • Guilds or an architecture forum where engineers from different teams share patterns and spot problems that cross team lines.
  • Fitness functions in shared CI templates, so the important rules apply everywhere automatically.

The shift is from architects as gatekeepers to architects as people who make the right thing the easy thing.

A case: one monolith, four years

How a shop's architecture evolved
  1. Year 0

    One monolith

    Five engineers, one FastAPI app, one Postgres. ADR-001: start as a monolith, top characteristics are speed of change, correctness, cost.

  2. Year 1

    Modules with teeth

    Fifteen engineers. Code split into orders, billing and catalog modules, each owning its tables. ADR-007 adds import-linter contracts with a ratchet, starting at 38 violations.

  3. Year 2

    Billing becomes a team

    A payments provider needs PCI-scoped deploys, and billing gets a dedicated team. ADR-012: extract billing as a service via strangler fig, canary at 1%, then 100%.

  4. Year 3

    A decision not to split

    Notifications is proposed for extraction. ADR-015 rejects it: one team owns it, it scales with orders, and the split adds cost without independence.

  5. Year 4

    Still evolving

    Two services, a modular monolith and a platform team running the paved road. Violations are at 0. Checkout p95 is guarded by a k6 budget in CI.

Notice what drove each change: team growth, a compliance need, a measured problem. Never "microservices are modern". And notice the ADR in year 3 that said no. Deciding not to change, and writing down why, is as much a part of evolutionary architecture as the splits.

That case quietly used most of this course: modules with owned data, dependency rules, the strangler fig, ADRs and a fitness function. The wrap-up that follows walks through one job of your own in the same way, from the first smell to a design that keeps itself honest.

Key terms
architecture characteristic
A quality the system must have, such as scalability or auditability, chosen from business needs and made measurable.
fitness function
An automated, objective check that the system still has an architecture characteristic, run in CI or production.
ratchet
A check that records the current number of violations and fails only if it rises, so a legacy codebase improves gradually.
last responsible moment
The latest point to make a decision before delay starts to cost more than deciding with less information.
Conway's law
Systems tend to copy the communication structure of the organisation that builds them.
inverse Conway manoeuvre
Shaping teams to match the architecture you want, so the system grows that way.
paved road
A supported default way to build and run a service, which makes the consistent choice the easy one.