Architecture docs decay the moment they're drawn, and ADRs don't get written because the options analysis is a chore.
Tier: Foundation · Workflow area: Runbooks, docs & knowledge
This playbook derives diagrams-as-code (Mermaid/D2) and narrative directly from your IaC — so the source of truth generates the picture, not the other way round — schedules a drift check so the diagram stays honest, and scaffolds ADRs with AI-drafted options analysis while keeping the decision itself unambiguously human.
Skip AI for a whiteboard conversation — generate durable artifacts, not throwaway sketches.
Generate the diagram from IaC, with an explicit scope.
Read infra/ (Terraform) and helm/. Produce a Mermaid architecture diagram at
the level of: VPCs/networks, compute (clusters, node groups), data stores,
queues/topics, load balancers/gateways, and external SaaS dependencies.
Rules:
- Only include resources that exist in the code. No idealized components.
- Group by subsystem; label edges with protocol/purpose (HTTPS, SQS, gRPC).
- Omit per-environment duplication: draw prod, note diffs for staging below.
- After the diagram, list any resources you could not classify.
Verify against the source, not your memory. Walk each node and edge back to a Terraform resource (ask the assistant to emit a node→resource-address mapping table). Delete anything unmapped. Render the diagram and fix syntax before committing.
Add the narrative. One page: what talks to what and why, blast-radius notes, and the three things newcomers always get wrong. The assistant drafts from the diagram + code; you correct intent — the code shows what, only humans know why.
Commit next to the IaC and wire the drift check. Put docs/architecture.md in the same repo. Add a scheduled CI job (weekly, or on merge to infra paths) that re-runs step 1 and diffs the node→resource mapping against the committed one; a mismatch opens an issue or a draft PR with the regenerated diagram. Diagram drift is now visible instead of silent.
Scaffold the ADR when a decision looms.
Draft an ADR: "Choose a message bus for order events" using our ADR template.
Options to analyze: SQS+SNS, MSK (Kafka), self-managed NATS.
For each option: operational burden for a 4-person platform team, lock-in,
failure modes, migration path, and rough monthly cost (I will supply
Infracost/pricing numbers — leave placeholders).
Then: a comparison table, and the questions we must answer before deciding.
Do NOT write the Decision section.
Fill in real numbers, decide, and record. Run infracost breakdown on candidate configs (or pull vendor pricing) and replace the placeholders — never let the model guess prices. Discuss with the team, write the Decision and Consequences sections yourself, and merge the ADR with named deciders and a date.
Asking for a node→resource-address mapping table alongside the diagram turns diagram review from squinting into a mechanical checklist — and it is exactly what the scheduled drift check diffs later.
d2 CLI and commit the SVG next to the source.IaC reveals your (or your client's) entire attack surface:
A rendered architecture diagram in a public or org-wide repo is reconnaissance gold — review its audience before you automate publishing it.