Docs Automation Guide

Generate architecture.md from a repository: one read, two artifacts

By the engineer who builds Datadef, from client work on data platforms · Reviewed August 21, 2026

ARCHITECTURE.md is the file everyone agrees should exist and nobody volunteers to write. It has no compiler, no test, and no owner, so it gets postponed until a new hire asks a question, then written once and never touched again. Generating it from the repository changes the economics: the blank page disappears, and the file refreshes on the same schedule as the code it describes.

7 min readFor maintainers who keep meaning to write ARCHITECTURE.md and never do

See it as a diagram

Everything below, as a diagram you can edit. Describe yours and see it in seconds.

188/20003 credits left
Try:

No account needed · Editable canvas, not a picture

Why the file never gets written, and then never gets updated

Two separate failures wear the same name. The first is the blank page: an architecture overview is the document that pays back the least at the exact moment somebody has to write it, because the author already knows the system. The second is silent decay. Prose has no type checker. A component removed in March leaves its paragraph behind, and the paragraph reads exactly as confidently as it did when it was true.

Both failures share a cause. The doc is a hand transcription of information that already exists somewhere machine-readable: Dockerfiles, compose files, Kubernetes manifests, IaC, CI workflows, package manifests. Transcription by hand is expensive once and wrong forever after.

What a generated architecture.md actually contains

The section set is fixed rather than improvised, which is what makes two docs from two repositories comparable. The default shape is an overview, a component inventory with a one-line role each, the data flow through the system, how it builds and deploys, and short notes per notable directory.

At the first sync Datadef asks one question: should this repository be documented as the system around the code, or as what the code does. The architecture answer produces components, infrastructure, build and deployment, and directory notes. The content answer produces data models, data flow, logic notes, and directory notes instead. The proposal is composed from the file counts in the repository, so a repo full of Terraform and a repo full of dbt models get different suggestions without a model guessing.

The directory notes section is the one readers use most and the one nobody writes by hand. It is a short line per notable directory saying what lives there, which is precisely the map a person needs before their first pull request.

architecture focus          content focus            terraform repository
-------------------------   ----------------------   --------------------------
# Architecture              # Overview               # Architecture
## Diagram                  ## Diagram               ## Diagram
## Components               ## Data models           ## Stacks and environments
## Infrastructure           ## Data flow             ## What gets provisioned
## Build and deployment     ## Logic notes           ## How it wires together
## Directory notes          ## Directory notes       ## Operations
                                                     ## Module reference

Grounding: what the generator is allowed to read

The whole repository does not fit in a prompt and does not need to. Selection walks the tree once and takes files in priority order: infrastructure as code first, then containers and orchestration, then data (dbt projects, SQL DDL, Prisma schemas, sampled migrations), then API specs, then CI workflows, then package manifests, then README and docs prose. It stops at 40 files or 250KB, whichever comes first, truncating anything over 30KB with a visible marker.

Per-class ceilings stop one noisy category from crowding out the rest, and they move with the focus. Under the architecture focus the read allows 16 infrastructure files, 14 Kubernetes manifests, 10 CI workflows, and 3 dbt models; under the content focus that inverts to 18 dbt models, 14 SQL files, 12 API definitions, and 3 infrastructure files. A repository holding two hundred models cannot push the Dockerfiles out of the budget either way. Migrations are the one class sampled from both ends, half from the oldest and half from the newest, because the first files show the initial schema and the last show the current direction of change.

A compact summary of the top three directory levels rides along, so the writer sees the shape of what was not included rather than assuming the selection was the whole repository. Lockfiles, binaries, and directories like node_modules, vendor, .terraform, and dist are never candidates at all.

The writing rules are strict about invention. Every statement has to be grounded in the provided files, nothing may be invented that the files do not show, and a section the files do not answer gets one line saying so rather than a plausible paragraph. The practical consequence is worth stating plainly: architecture that lives nowhere in the repository will not appear in the doc.

Read-only, nothing executed

The connection is a read-only token on GitHub, GitLab, or Azure DevOps, and public repositories need none. Nothing is built, run, or deployed to produce the doc. See how repository sync works.

The Diagram section is not written by the model

One section of the generated doc is composed in code rather than written by the model, and it is inserted at a fixed position: immediately after the overview, before the first model-written heading, so a reader sees the shape before the prose. A model asked to produce an embed URL will invent a slug that resolves to nothing, which is the failure this removes. The URL is either real or replaced by the instruction for making it real.

From the Canvas tab of the right-hand panel you can copy or download the markdown, so committing the file next to the code is a two-step operation. The diagram itself exports as PNG or JPEG when someone needs a still image for a slide.

That section is also rebuilt on every sync, including the ones that skip regeneration because the structure has not moved. Switching a project to link sharing puts the real embed line into the document on the next pass without touching a single model-written sentence, and switching it back replaces the line with the instruction again. Both states look like this.

<!-- project shared by link: the URL is real -->
## Diagram

![Acme platform](https://datadef.io/api/embed/acme-platform-4f2c)

This image stays current with the canvas: every sync renders the latest diagram.

<!-- project not shared: no invented URL, just the way to get one -->
## Diagram

To embed the live diagram here, open the project in Datadef, click Embed,
switch on Anyone with the link, and the markdown line to paste will be there.

FAQ

What sections does the generated architecture.md have?

A fixed set, chosen by the focus picked at first sync. The architecture focus produces an overview, a diagram section, a component inventory, an infrastructure section, a build and deployment section, and directory notes. The content focus swaps in data models, data flow, and logic notes. Terraform repositories get stacks and environments, what gets provisioned, how it wires together, operations, and a generated module reference table.

Does it read my entire repository?

No. It selects up to 40 files or 250KB in priority order, infrastructure as code first and prose last, truncating any file over 30KB with a marker, and adds a summary of the top three directory levels. Binaries, lockfiles, and vendor directories such as node_modules are skipped entirely.

Can the generated doc describe services we do not actually have?

The writing step is instructed to ground every statement in the files it was given and to state plainly when the files do not answer a section rather than guessing. The trade-off runs the other way: architecture that appears nowhere in the selected files will be missing from the doc rather than invented into it.

How do I get the markdown file into my repository?

The doc is shown in the Canvas tab of the diagram, with copy and download controls. It is plain markdown, so committing it as ARCHITECTURE.md next to the code works normally. The embed line inside it renders the current diagram wherever markdown renders images.

How often is the doc regenerated?

On the daily sync of the linked diagram, on a manual refresh, or when an agent triggers a refresh over MCP. Each sync resolves the head commit of the tracked branch or tag first, and if it has not moved, nothing is regenerated.