<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Planchest</title>
    <description>The latest articles on DEV Community by Planchest (@planchest).</description>
    <link>https://dev.to/planchest</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4277224%2Ff412049d-92f0-421d-a04d-0aaa11371f17.png</url>
      <title>DEV Community: Planchest</title>
      <link>https://dev.to/planchest</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/planchest"/>
    <language>en</language>
    <item>
      <title>Why ADRs matter: MADR records on a real FastAPI codebase</title>
      <dc:creator>Planchest</dc:creator>
      <pubDate>Wed, 02 Dec 2026 00:26:51 +0000</pubDate>
      <link>https://dev.to/planchest/why-adrs-matter-madr-records-on-a-real-fastapi-codebase-54gc</link>
      <guid>https://dev.to/planchest/why-adrs-matter-madr-records-on-a-real-fastapi-codebase-54gc</guid>
      <description>&lt;p&gt;Most teams agree &lt;a href="https://www.cognitect.com/blog/2011/11/15/documenting-architecture-decisions" rel="noopener noreferrer"&gt;Architecture Decision Records&lt;/a&gt; (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.&lt;/p&gt;

&lt;p&gt;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 &lt;a href="https://adr.github.io/madr/" rel="noopener noreferrer"&gt;MADR&lt;/a&gt; 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.&lt;/p&gt;

&lt;h2&gt;
  
  
  The example: fastapi/full-stack-fastapi-template
&lt;/h2&gt;

&lt;p&gt;The project is &lt;a href="https://github.com/fastapi/full-stack-fastapi-template" rel="noopener noreferrer"&gt;fastapi/full-stack-fastapi-template&lt;/a&gt;: 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 &lt;code&gt;f8c6c147b12b&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;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:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Serve the React SPA from the FastAPI application.&lt;/li&gt;
&lt;li&gt;PostgreSQL with SQLModel and Alembic migrations.&lt;/li&gt;
&lt;li&gt;Run database migrations as an explicit pre-deploy step.&lt;/li&gt;
&lt;li&gt;Stateless JWT bearer auth with Argon2 password hashing.&lt;/li&gt;
&lt;li&gt;Deploy to FastAPI Cloud by default, with Docker Compose and Traefik for self-hosting.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A sixth record, about rate limiting, was written from a discussion instead of the code (more on that below).&lt;/p&gt;

&lt;h2&gt;
  
  
  What gets lost without the record
&lt;/h2&gt;

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

&lt;p&gt;It was not always this way. Commit &lt;code&gt;e80d924&lt;/code&gt; ("Serve frontend from FastAPI", #2393) removed &lt;code&gt;frontend/Dockerfile&lt;/code&gt; and &lt;code&gt;frontend/nginx.conf&lt;/code&gt;. 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.&lt;/p&gt;

&lt;p&gt;That is the typical loss. The code shows &lt;strong&gt;what&lt;/strong&gt; 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.&lt;/p&gt;

&lt;h2&gt;
  
  
  How a MADR record holds that context
&lt;/h2&gt;

&lt;p&gt;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:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;---
status: accepted
date: 2026-07-30
decision-makers: [project maintainers]
---

&lt;span class="gu"&gt;# Serve the React SPA from the FastAPI application
&lt;/span&gt;
&lt;span class="gu"&gt;## Context and Problem Statement
&lt;/span&gt;
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?

&lt;span class="gu"&gt;## Decision Drivers
&lt;/span&gt;
&lt;span class="k"&gt;* &lt;/span&gt;One deployable artefact, so the app also fits single-application hosting
&lt;span class="k"&gt;* &lt;/span&gt;Fewer moving parts in Docker Compose and the reverse proxy
&lt;span class="k"&gt;* &lt;/span&gt;Same-origin API calls (no CORS setup needed in production)
&lt;span class="k"&gt;* &lt;/span&gt;Keep the Vite/React developer experience unchanged for local work

&lt;span class="gu"&gt;## Considered Options
&lt;/span&gt;
&lt;span class="k"&gt;* &lt;/span&gt;Build the SPA into the backend image and serve it from FastAPI
&lt;span class="k"&gt;* &lt;/span&gt;Separate Nginx container serving the SPA (previous approach)
&lt;span class="k"&gt;* &lt;/span&gt;Host the SPA on a CDN / static host, API separately
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three things make this more useful than a paragraph in a wiki:&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Consequences, including the bad ones
&lt;/h3&gt;

&lt;p&gt;The part most teams skip is the cost. MADR asks for "Good, because" and "Bad, because" lines. ADR-0001 says:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="k"&gt;* &lt;/span&gt;Good, because one image contains UI + API (&lt;span class="sb"&gt;`backend/Dockerfile:1-16`&lt;/span&gt;, &lt;span class="sb"&gt;`:54`&lt;/span&gt;)
&lt;span class="k"&gt;* &lt;/span&gt;Bad, because any frontend change rebuilds and redeploys the API image
&lt;span class="k"&gt;* &lt;/span&gt;Bad, because static assets are served by Python workers instead of a
  CDN/Nginx; heavy traffic to assets competes with API requests
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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."&lt;/p&gt;

&lt;p&gt;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 (&lt;code&gt;backend/app/core/config.py:25&lt;/code&gt;), the SPA keeps the token in &lt;code&gt;localStorage&lt;/code&gt; (&lt;code&gt;frontend/src/hooks/useAuth.ts:45&lt;/code&gt;), 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.&lt;/p&gt;

&lt;h3&gt;
  
  
  Confirmation: how you know it is still true
&lt;/h3&gt;

&lt;p&gt;MADR 4 adds a &lt;strong&gt;Confirmation&lt;/strong&gt; section: how do you check that the decision is still being followed? For ADR-0001:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;### Confirmation
&lt;/span&gt;
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
(&lt;span class="sb"&gt;`.github/workflows/test-docker-compose.yml:26,28`&lt;/span&gt;); Playwright e2e tests run
against &lt;span class="sb"&gt;`http://backend:8000`&lt;/span&gt;, proving the SPA is served by the backend.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Documented versus inferred
&lt;/h2&gt;

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

&lt;blockquote&gt;
&lt;p&gt;Rationale source: &lt;strong&gt;Inferred&lt;/strong&gt;. Commit &lt;code&gt;e80d924&lt;/code&gt; records the change but no written rationale was found in the commit body or the repo docs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Other records are different. ADR-0003 (migrations as an explicit step) is partly &lt;strong&gt;Documented&lt;/strong&gt;: 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.&lt;/p&gt;

&lt;p&gt;MADR does not require this label, but it fits the format. A rationale marked &lt;strong&gt;Documented&lt;/strong&gt; links to its source. One marked &lt;strong&gt;Inferred&lt;/strong&gt; 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.&lt;/p&gt;

&lt;p&gt;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 (&lt;code&gt;sqlmodel&amp;gt;=0.0.46,&amp;lt;1.0.0&lt;/code&gt;, &lt;code&gt;backend/pyproject.toml:16&lt;/code&gt;), which is a risk you want on record when upgrading.&lt;/p&gt;

&lt;h2&gt;
  
  
  A decision made in a conversation
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="k"&gt;* &lt;/span&gt;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
&lt;span class="k"&gt;* &lt;/span&gt;Bad, because per-IP limits can affect users behind shared NAT/proxies
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two years later, someone asking "why is the limit not stricter?" has the answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the records turned up
&lt;/h2&gt;

&lt;p&gt;Writing the records forced a look at every claim, and some findings were not obvious from the code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A public admin UI.&lt;/strong&gt; ADR-0005 notes that the self-hosted Compose stack exposes the Adminer database UI publicly at &lt;code&gt;adminer.&amp;lt;domain&amp;gt;&lt;/code&gt; (&lt;code&gt;compose.deploy.yml:41-45&lt;/code&gt;). It is recorded as a "Bad, because" and as an open question: should Adminer be excluded from the deploy file or put behind authentication?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A vendor relationship.&lt;/strong&gt; 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.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decisions that depend on each other.&lt;/strong&gt; 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.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I also modelled the same repo's Compose stack as a &lt;a href="https://c4model.com/" rel="noopener noreferrer"&gt;C4&lt;/a&gt; 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.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I would take from this
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Write the options, not just the choice.&lt;/strong&gt; A rejected alternative is the most useful line in an old record.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write the "Bad, because" lines.&lt;/strong&gt; A record with only upsides will not be believed, and will not tell you when to revisit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Say where the rationale came from.&lt;/strong&gt; Documented or inferred, one word makes a record much easier to review.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Point at evidence.&lt;/strong&gt; &lt;code&gt;path:line&lt;/code&gt; references are boring and make review fast.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add a confirmation.&lt;/strong&gt; If you cannot say how the decision is checked, say that, and add it to the open questions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A generated draft is not a substitute for an expert.&lt;/strong&gt; 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.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;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.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;Sources used to build the worked example above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Codebase analysed: &lt;a href="https://github.com/fastapi/full-stack-fastapi-template" rel="noopener noreferrer"&gt;fastapi/full-stack-fastapi-template&lt;/a&gt; (MIT), at commit &lt;a href="https://github.com/fastapi/full-stack-fastapi-template/tree/f8c6c147b12bb1c4d3253cc1b06f8b5ef81b10dd" rel="noopener noreferrer"&gt;&lt;code&gt;f8c6c147b12b&lt;/code&gt;&lt;/a&gt; (26 Nov 2026).&lt;/li&gt;
&lt;li&gt;Change cited in ADR-0001: commit &lt;a href="https://github.com/fastapi/full-stack-fastapi-template/commit/e80d92452ec289e7bbf6f1a380fec7cfaa547950" rel="noopener noreferrer"&gt;&lt;code&gt;e80d924&lt;/code&gt;&lt;/a&gt;, "Serve frontend from FastAPI" (&lt;a href="https://github.com/fastapi/full-stack-fastapi-template/pull/2393" rel="noopener noreferrer"&gt;#2393&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;Skills that generated the ADRs and the C4 model: &lt;a href="https://github.com/planchest-dev/architecture-pack-claude-code" rel="noopener noreferrer"&gt;planchest-dev/architecture-pack-claude-code&lt;/a&gt;, run as &lt;a href="https://code.claude.com/docs/en/skills" rel="noopener noreferrer"&gt;Claude Code skills&lt;/a&gt;. The generated records are in its &lt;a href="https://github.com/planchest-dev/architecture-pack-claude-code/tree/main/examples" rel="noopener noreferrer"&gt;&lt;code&gt;examples/&lt;/code&gt;&lt;/a&gt; folder. ADR-0006 there comes from a synthetic discussion written for the demo, not from the project's maintainers.&lt;/li&gt;
&lt;li&gt;ADR format: &lt;a href="https://github.com/adr/madr/releases/tag/4.0.0" rel="noopener noreferrer"&gt;MADR 4.0.0&lt;/a&gt; (&lt;a href="https://adr.github.io/madr/" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;Diagram model: the &lt;a href="https://c4model.com/" rel="noopener noreferrer"&gt;C4 model&lt;/a&gt;. The diagram is a &lt;a href="https://mermaid.js.org/syntax/flowchart.html" rel="noopener noreferrer"&gt;Mermaid flowchart&lt;/a&gt;, with syntax checked using &lt;a href="https://github.com/mermaid-js/mermaid-cli" rel="noopener noreferrer"&gt;mermaid-cli&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>architecture</category>
      <category>documentation</category>
      <category>adr</category>
      <category>madr</category>
    </item>
  </channel>
</rss>
