← All articles

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:

George Petropoulos
7 min read

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.

ChangeWhat I would checkEvidence to keep
A service or queue is addedMissing node, owner and incoming pathsDeployment configuration and caller
A call becomes asynchronousArrow label, ordering and failure pathProducer and consumer code
Retries move into the workerRetry destination and exhausted-attempt pathRetry handler and configuration
A database movesWhich service reads or writes itConnection settings and queries
An internal refactorWhether any visible relationship changedDiff 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
    end

This 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.

  1. Check every node against a real component in the intended deployment.
  2. Check each arrow's direction, label and condition against the caller or handler.
  3. Check that deleted paths are actually gone. Adding the new path while keeping the old one tells two stories.
  4. Read long labels at the size people will see on the docs page. Look for overlaps and ambiguous crossings.
  5. 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:

SurfaceOld claimDecision in this example
Architecture diagramFailed work returns to the task queueReplace the retry path
On-call runbookInspect the task queue after retries are exhaustedPoint to the dead-letter queue and its recovery procedure
Help articleBilling failures are retried within a stated windowCheck the window; leave it alone if it did not change
Past incident reportThe queue received failed tasksKeep 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.

Two walkthroughs, from a code change to a reviewed documentation correction.

Try Amendary on your own help center

Connect Notion, GitHub, Zendesk or Intercom and pick the articles to watch. Your first check shows what Amendary would fix, with the change as proof.

Free for 14 days with no card, and every edit waits for your review. Or free forever with your own Anthropic API key. Code is never touched.