DEV Community

Planchest
Planchest

Posted on

Why ADRs matter: MADR records on a real FastAPI codebase

Most teams agree Architecture Decision Records (ADRs) are useful. Most teams also have zero of them, or five from the week someone got excited, and then nothing. The decisions still got made. They are in the code, in commit messages, in release notes, in someone's head, and each month fewer people remember them.

This post shows what that looks like on a real project. I took a well-known open-source codebase with no ADRs, wrote the decisions down as MADR records, and kept notes on what was missing. The point is not the tooling. It is what an ADR captures that the code cannot, and why the MADR layout is a good way to capture it.

The example: fastapi/full-stack-fastapi-template

The project is fastapi/full-stack-fastapi-template: a FastAPI backend, a React frontend, PostgreSQL, and a Docker Compose deployment. It is MIT-licensed, about 11k lines of Python and TypeScript, and the analysis used commit f8c6c147b12b.

It has no ADR folder. But it has made plenty of decisions. Reading the code, the release notes and the git history turned up 10 candidates. The five that cost the most to reverse, and touch the most of the system, became records:

  1. Serve the React SPA from the FastAPI application.
  2. PostgreSQL with SQLModel and Alembic migrations.
  3. Run database migrations as an explicit pre-deploy step.
  4. Stateless JWT bearer auth with Argon2 password hashing.
  5. Deploy to FastAPI Cloud by default, with Docker Compose and Traefik for self-hosting.

A sixth record, about rate limiting, was written from a discussion instead of the code (more on that below).

What gets lost without the record

Take decision 1. Today the repo builds the React app inside the backend Docker image, and FastAPI serves it (backend/Dockerfile:1-16 builds the SPA with Bun, and :54 copies it into the Python image). If you join the project now, that looks like the obvious way to do it.

It was not always this way. Commit e80d924 ("Serve frontend from FastAPI", #2393) removed frontend/Dockerfile and frontend/nginx.conf. Before that, the SPA had its own Nginx container, its own route in the reverse proxy, and cross-origin calls to the API. The commit records the change. It does not say why.

That is the typical loss. The code shows what the system does. The alternatives that were rejected, the constraints at the time, and the trade-offs that were accepted are not in the code. Without them, the next person either re-argues the choice from scratch or never questions it.

How a MADR record holds that context

A MADR record has a fixed set of sections, and each one answers a question a future reader will have. Here is the front of ADR-0001, trimmed:

---
status: accepted
date: 2026-07-30
decision-makers: [project maintainers]
---

# Serve the React SPA from the FastAPI application

## Context and Problem Statement

Previously the SPA had its own container (Nginx), which meant two images,
two routes in the reverse proxy and cross-origin calls between them.
How should the SPA be built and served so that deployment, including to a
single-app PaaS, stays simple?

## Decision Drivers

* One deployable artefact, so the app also fits single-application hosting
* Fewer moving parts in Docker Compose and the reverse proxy
* Same-origin API calls (no CORS setup needed in production)
* Keep the Vite/React developer experience unchanged for local work

## Considered Options

* Build the SPA into the backend image and serve it from FastAPI
* Separate Nginx container serving the SPA (previous approach)
* Host the SPA on a CDN / static host, API separately
Enter fullscreen mode Exit fullscreen mode

Three things make this more useful than a paragraph in a wiki:

  • Drivers come before the answer. The reader sees what the decision was optimising for. If a driver stops being true, the decision can be reopened on purpose.
  • Considered options list real alternatives. Someone who suggests "why not a CDN?" finds that it was on the table and what it would cost.
  • The status and date are in the file. accepted or superseded is visible without asking anyone.

Consequences, including the bad ones

The part most teams skip is the cost. MADR asks for "Good, because" and "Bad, because" lines. ADR-0001 says:

* Good, because one image contains UI + API (`backend/Dockerfile:1-16`, `:54`)
* Bad, because any frontend change rebuilds and redeploys the API image
* Bad, because static assets are served by Python workers instead of a
  CDN/Nginx; heavy traffic to assets competes with API requests
Enter fullscreen mode Exit fullscreen mode

An honest "Bad, because" is what makes the record trustworthy. It also tells you when to revisit the decision: the record ends with "Revisit when: frontend and backend need different release cadences, or static traffic becomes a significant share of backend load."

ADR-0004 (auth) has the same effect on a security-relevant choice. The template uses JWT bearer tokens with Argon2 password hashing. The consequences section lists what you would otherwise only find by auditing: tokens cannot be revoked before they expire, expiry is 8 days (backend/app/core/config.py:25), the SPA keeps the token in localStorage (frontend/src/hooks/useAuth.ts:45), and password-reset tokens use the same key as access tokens with no purpose claim. None of that is hidden in the code, but nobody lists it in one place.

Confirmation: how you know it is still true

MADR 4 adds a Confirmation section: how do you check that the decision is still being followed? For ADR-0001:

### Confirmation

The Docker Compose CI test builds the single backend image, starts it and
requests both the API health check and the root page from the same container
(`.github/workflows/test-docker-compose.yml:26,28`); Playwright e2e tests run
against `http://backend:8000`, proving the SPA is served by the backend.
Enter fullscreen mode Exit fullscreen mode

This turns a document into something you can check. Sometimes the honest answer is "there is nothing". ADR-0003 says a startup check comparing the Alembic head with the database revision "would make this enforceable (not present)". That is a useful finding on its own.

Documented versus inferred

The hardest part of writing ADRs after the fact is that the reasons are often not written down. ADR-0001 above has this line:

Rationale source: Inferred. Commit e80d924 records the change but no written rationale was found in the commit body or the repo docs.

Other records are different. ADR-0003 (migrations as an explicit step) is partly Documented: a release note says "Run database setup explicitly before startup, no need for prestart" (#2426). Its context also draws on an older release note about moving the prestart logic into its own container (#1350). The reasoning on top of that is still labelled inferred.

MADR does not require this label, but it fits the format. A rationale marked Documented links to its source. One marked Inferred tells a maintainer exactly which sentence to confirm or correct. A record without the label looks equally confident everywhere, and that is how invented history gets into a decision log.

ADR-0002 shows another honest limit. The choice of PostgreSQL with SQLModel predates the available git history, so the record's date is the earliest observable date, not the decision date. It also notes that SQLModel is pre-1.0 (sqlmodel>=0.0.46,<1.0.0, backend/pyproject.toml:16), which is a risk you want on record when upgrading.

A decision made in a conversation

Not every decision is in the code. ADR-0006 was written from a discussion instead. I wrote a synthetic conversation for this demo (it is not a real discussion from the project's maintainers): security review found no rate limiting on login and password recovery, and the team compared slowapi in the app, Traefik middleware, and a CDN in front.

The record captures the part that usually evaporates: why the quick option won. It chose slowapi with in-memory storage, 5 requests per minute per IP on login and 3 per hour per email on password recovery, because it was the only option that worked on both deployment targets without new infrastructure. The consequences are explicit:

* Bad, because counters are per worker process (4 workers per container), so
  the effective limit is up to 4x higher per instance, and resets on restart
* Bad, because per-IP limits can affect users behind shared NAT/proxies
Enter fullscreen mode Exit fullscreen mode

Two years later, someone asking "why is the limit not stricter?" has the answer.

What the records turned up

Writing the records forced a look at every claim, and some findings were not obvious from the code:

  • A public admin UI. ADR-0005 notes that the self-hosted Compose stack exposes the Adminer database UI publicly at adminer.<domain> (compose.deploy.yml:41-45). It is recorded as a "Bad, because" and as an open question: should Adminer be excluded from the deploy file or put behind authentication?
  • A vendor relationship. The default deploy target, FastAPI Cloud, is built by the same organisation that maintains the template. The record says so, because readers weighing vendor neutrality should know.
  • Decisions that depend on each other. ADR-0001 (one image) and ADR-0005 (deploy target) point at each other in their "Related" lines, and ADR-0003 builds on the single-artefact setup. Change one and you know which others to reread.

I also modelled the same repo's Compose stack as a C4 container diagram, drawn as a Mermaid flowchart. It shows the same Adminer exposure as ADR-0005 and agrees with ADR-0001 that the SPA is not a separate container. The diagram and the decision records check each other.

What I would take from this

  • Write the options, not just the choice. A rejected alternative is the most useful line in an old record.
  • Write the "Bad, because" lines. A record with only upsides will not be believed, and will not tell you when to revisit.
  • Say where the rationale came from. Documented or inferred, one word makes a record much easier to review.
  • Point at evidence. path:line references are boring and make review fast.
  • Add a confirmation. If you cannot say how the decision is checked, say that, and add it to the open questions.
  • A generated draft is not a substitute for an expert. Some details in the example still needed correcting in review. The point is starting from most of a record with sources, rather than from a blank page or a made-up history.

All six example records are in the repository listed in the references below. Where the "why" is wrong, a maintainer of the project will know, and that is the point of labelling the guess.

Disclosure: this article was drafted with AI assistance and reviewed before publication. The worked-example ADRs were generated by an AI agent following a free, MIT-licensed Claude Code skill that I (Planchest) made, and then checked against the source repository.

References

Sources used to build the worked example above:

Top comments (0)