AI and diagrams
Keep architecture diagrams in sync with your code
Keep architecture diagrams current with a release checklist, a worked retry example, review rules and checks for the runbooks that tell the same story.
Last checked:
To keep architecture diagrams up to date, keep an editable source, give each diagram an owner and review its relationships when the code changes. Check the rendered result and the docs that repeat the same claims. A diagram that still renders can still send the next engineer to the wrong service.
In my earlier experiment, I spent a lot of time getting boxes and arrows right. Once I had something readable, the harder question was what would happen after the next release. Here is the process I would use, starting with the billing worker from that example.
What changes should trigger an architecture diagram update?
I would review a diagram when a change affects a component, a connection or a promise the diagram makes. Renaming a local variable probably needs no edit. Moving retries into a worker does.
Start with the diagram's scope. Does it describe the default branch, production or a proposed design? A merged change behind a disabled flag may belong in the first view and still be wrong in the second.
| Change | What I would check | Evidence to keep |
|---|---|---|
| A service or queue is added | Missing node, owner and incoming paths | Deployment configuration and caller |
| A call becomes asynchronous | Arrow label, ordering and failure path | Producer and consumer code |
| Retries move into the worker | Retry destination and exhausted-attempt path | Retry handler and configuration |
| A database moves | Which service reads or writes it | Connection settings and queries |
| An internal refactor | Whether any visible relationship changed | Diff showing unchanged behaviour |
This is a review trigger list, not a rule that every release needs a new picture. Record “checked, no relationship changed” when that is the answer.
Where should architecture diagrams live?
Keep the editable definition next to the explanation it supports. For a repository guide, I would put it under the same docs folder and review it with the code change. GitHub can render a fenced Mermaid block in Markdown; check the result in GitHub as well as in your local preview because renderer versions can differ.
For a diagram embedded in Notion, keep a link to its editable source beside the image. I would add four small pieces of context: owner, scope, source and last reviewed revision. A date alone tells me when someone looked, but not which version they checked.
For example: “Billing failure flow. Owner: payments team. Scope: production after release X. Source: docs/billing-flow. Reviewed against: deployment X.”
I prefer an editable graph for this work. If all I have is an exported image, I can correct the picture once, but the next edit starts with the same problem. My Mermaid and Excalidraw experiment explains that trade-off.
How do you update a diagram after a code change?
Imagine a release changes the billing worker like this: it used to return failed tasks to the task queue; now it retries locally and sends exhausted tasks to a dead-letter queue.
Before editing the graph, I would answer three questions from the code: what counts as a retryable failure, how many total attempts are allowed, and where the final failure goes. “Three retries” and “three total attempts” are different. I would leave the number out until the code and configuration settle it.
The smallest useful change is to remove the old return-to-queue relationship, add the local retry and add the exhausted-attempt path. Keep the successful path in view so the reviewer can see that it still exists.
sequenceDiagram
participant Queue as Task queue
participant Worker as Billing worker
participant Billing as Billing API
participant DLQ as Dead-letter queue
Queue->>Worker: Deliver task
loop Until success or attempt limit
Worker->>Billing: Attempt billing request
end
alt Attempts exhausted
Worker->>DLQ: Store failed task
else Succeeded
Worker->>Worker: Continue success handling
endThis sequence shows retry ownership. It deliberately leaves out backoff timing, acknowledgements and the rest of the success path. Add those only if this diagram is meant to answer those questions. A simplified flow should say what it leaves out.
What should you check before approving an updated diagram?
Read the relationships before adjusting the layout. Then open the rendered diagram and follow one successful task, one recoverable failure and one exhausted task with your finger. If I cannot explain where each one goes, I am not finished.
- Check every node against a real component in the intended deployment.
- Check each arrow's direction, label and condition against the caller or handler.
- Check that deleted paths are actually gone. Adding the new path while keeping the old one tells two stories.
- Read long labels at the size people will see on the docs page. Look for overlaps and ambiguous crossings.
- Get the component owner to review the changed behaviour, then record the revision they checked.
For CI, I would start with a syntax/render check for the diagram files and a reviewer reminder when the relevant service or infrastructure files change. That can catch a broken definition or a missed review. It cannot prove that a valid arrow describes production correctly. Avoid a rule that demands a diagram diff for every code diff.
How do you keep diagrams and runbooks consistent?
The picture is usually only one copy of the claim. In this example, the on-call runbook might still tell someone to inspect the task queue after repeated billing failures. Search for the queue name, “retry”, “failed payment” and the customer task, then read each match in context.
I would keep a short review record:
| Surface | Old claim | Decision in this example |
|---|---|---|
| Architecture diagram | Failed work returns to the task queue | Replace the retry path |
| On-call runbook | Inspect the task queue after retries are exhausted | Point to the dead-letter queue and its recovery procedure |
| Help article | Billing failures are retried within a stated window | Check the window; leave it alone if it did not change |
| Past incident report | The queue received failed tasks | Keep the historical description |
A broad search-and-replace would get at least one of those wrong. Keeping docs in sync with code is about this same problem: deciding which statement became false.
Can Amendary keep architecture diagrams up to date?
Amendary's diagram feature is early access and needs to be enabled for your team. On a mapped Notion page, you can request a new diagram or an update to an existing one. Both wait in the Queue for review and use generation credits unless you bring your own Anthropic key. Diagram updates are requested separately from daily correction checks.
The checks establish that labels appear in the supplied page or code. A person still checks the relationships. See the diagram guide for the current workflow.
I would try the process manually on one release first. Pick one diagram, find one changed relationship, fix it, and check the runbook that describes the same failure. That gives you a useful baseline before adding more automation.
Architecture diagram maintenance FAQ
How often should architecture diagrams be updated?
Review them when the behaviour they describe changes. I would also include a quick check in release review for critical flows, so a missed trigger has somewhere to surface. A fixed monthly schedule alone can leave the diagram wrong between reviews.
Can you generate architecture diagrams from code?
Code can provide candidates for components and connections. You still need to choose the scope and verify configuration, feature flags and external systems. A dependency graph and a useful explanation of the deployed system answer different questions.
Can Claude Code or Codex draw an architecture diagram as code?
Yes, they can write Mermaid from your repository, and the first draft is often decent. The hard part comes later. Keeping that diagram right after the next change still needs a trigger and a review, so the steps above apply either way.
Is Mermaid enough for architecture documentation?
For a small flow, it is often enough for me. Keep a larger diagram split by the questions readers ask. I would rather maintain a clear billing flow and a clear deployment view than make one huge picture cover both.
Should old architecture diagrams be deleted?
Keep a dated diagram if it explains a past incident or decision. Label it as historical and link to the current view. Replace stale images on pages that promise to describe today's system.
Sources and review date
Checked 25 November 2026: GitHub's diagram rendering guide, Mermaid sequence diagram syntax and Amendary's diagram guide. The review checklist and retry scenario are my suggested workflow, not benchmark results.