DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk7 min

Diagrams as Code: Keep Your Architecture Docs Alive Inside the Repo

Store diagram source beside the code it describes, update it in the same pull request as the architecture change, and choose Mermaid, PlantUML, or Structurizr DSL based on what your docs platform renders.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep the editable source for each architecture diagram in the same repository as the code and documentation it describes, and change that source in the same pull request as the architecture change. Text-based sources give you a diff, a review thread, and a recoverable history. They do not, by themselves, tell you that a diagram still matches the deployed system. That gap is closed by a review habit and, where your toolchain allows it, automated checks.

Whether Mermaid belongs in the application repository depends on one thing first: whether your Git host and documentation platform render it. If they do, Mermaid inside Markdown next to the code is usually the lowest-friction option. If your team needs one architecture model that feeds several views, Structurizr DSL fits better, with an export step added.

As an Amazon Associate I earn from qualifying purchases.

Why architecture diagrams go stale

Most diagrams drift for a mundane reason: they live in a drawing tool, a wiki page, or an exported image that nobody connected to the code. A service gets a new dependency, the pull request merges, and the diagram is still the version from the kickoff meeting. Image files are hard to review because a diff shows nothing useful. Nobody is asked to touch the diagram, so nobody does.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Diagrams as code change that incentive. The diagram is a text file, so editing it is an ordinary commit, and a reviewer can see exactly which node, arrow, or container changed. The practical benefit is that the diagram update can be requested in the same review as the code update.

What a Git repository gives you, and what it does not

A repository provides four things that matter for documentation:

  • A history of every change to the diagram, with author and date.
  • A diff that shows added or removed components and relationships.
  • Review comments attached to the lines that changed.
  • The ability to restore an earlier version when a change turns out to be wrong.

What it does not provide is a link between the diagram and the running system. A diagram can be perfectly versioned and still wrong. Closing that gap takes a review trigger, an owner, and sometimes a rendering or validation check, all described below.

Choose the format your platform renders

The three common options differ mainly in what the source describes and where the output appears. The table compares them on the axes that affect day-to-day maintenance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Option Strong fit Workflow to describe Trade-off to mention
Mermaid Teams that want diagrams embedded in Markdown and rendered by their repository host Commit Markdown containing a Mermaid block, and review it alongside the prose it illustrates Rendering and syntax support depend on the host and on the Mermaid version it runs; confirm both
PlantUML Teams that prefer PlantUML notation or want diagrams kept as separate files Keep the source file in the repository and include or render it through the documentation platform Platform configuration and renderer support must be verified; GitLab documents including PlantUML from separate files
Structurizr DSL Teams that want one architecture model from which several views are produced Author a workspace, version its files, then view it or export views More concepts to learn; exporting to Mermaid or PlantUML adds a step and slows feedback when you need a rendered output

When you compare options for your own team, check them against these criteria:

  • Whether your destination renders the format directly, or needs an export first.
  • Whether you need a shared model with multiple views, or standalone diagrams that each stand alone.
  • How easily a reviewer can read the change in a pull request.
  • How quickly an author sees the rendered result, and how many steps sit between the source and the picture.
  • How cleanly your real architecture can be expressed without awkward workarounds.

Mermaid

Mermaid is the simplest starting point when your documentation is Markdown. The project’s architecture diagram syntax documentation is labeled for v11.1.0 and later, so check that your renderer runs a version that includes the diagram type you plan to use. A minimal flow looks like this:

flowchart LR
  Client --> API[Orders API]
  API --> DB[(Orders database)]

Because the block sits in a Markdown file, a reviewer sees the prose and the diagram in one diff.

PlantUML

PlantUML suits teams that already use its notation, or that want the diagram source as its own file. The GitLab Flavored Markdown reference documents PlantUML support and says PlantUML can be included from separate files. That workflow keeps a large diagram out of a long Markdown page, but it adds one more file to keep in step with the prose that cites it.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Structurizr DSL

Structurizr describes itself as a models-as-code tool for the C4 model, and says the approach is friendly to version control (Structurizr documentation home). In this model you describe a workspace once: systems, containers, components, and relationships. Several views are then drawn from that one model, which helps when the same system appears in a context view, a container view, and a deployment view. The Structurizr guide to exporting diagrams describes storing DSL workspace files in version control and exporting views to Mermaid or PlantUML, which is the route for hosts that do not render Structurizr output directly.

The Structurizr project’s own comparison of diagrams as code, which is vendor-authored and should be read with that in mind, calls out an initial learning curve and describes compatibility with pull-request development (Structurizr: as code). It also notes that export adds feedback delay when you need rendered output.

Where the source should live

Put the source where the people who change that part of the system will see it. A diagram of one service’s request flow belongs beside that service’s documentation, because the author who changes the service will open that folder. A system-wide context or container view belongs in a clearly named architecture documentation directory, because no single service owns it. Placement is an editorial judgment, not a requirement of any tool.

Mermaid in the application repository is a reasonable default when the diagram describes that codebase and your host renders Mermaid in its Markdown. Move the source out when one diagram describes several repositories, or when it has to be shared across teams with separate release cycles.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A workflow your team can adopt

  1. Choose the smallest useful scope. Start with a system context, a container or service view, a deployment view, or a focused request or data flow. Avoid one diagram that tries to show everything, since large diagrams are hard to review and quickly stop being read.
  2. Place the editable source according to the rules above, next to the code or documentation it explains.
  3. Update the diagram in the same pull request as the architecture change. Review the source diff and, where your toolchain shows it, the rendered output.
  4. Add a render or syntax check to CI if your format and host make it practical (see the next section).
  5. Name an owner for each high-level diagram, and write down the review trigger. Revisit the diagram when interfaces, dependencies, deployment boundaries, or data flows change.
  6. Keep the decisions and rationale in prose next to the picture. A diagram shows structure; it rarely records why the structure is the way it is. Structurizr’s documentation also describes embedding workspace diagrams in supplementary technical documentation, which keeps the explanation and the picture together.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Keep diagram changes visible in review

The workflow works only if reviewers notice when a change touches architecture. A few concrete habits make that happen:

  • Add a checklist item to the pull request template asking whether interfaces, dependencies, deployment boundaries, or data flows changed, and if so whether the relevant diagram changed too.
  • Ask reviewers to read the diagram source diff for architecture-affecting pull requests, not only the code.
  • Keep the diagram owner listed in the documentation folder so that questions have an obvious recipient.
  • Treat a diagram that was not updated after a change as a review finding, the same way a missing test would be treated.

Automated checks, where practical

A render or syntax check can catch broken diagrams before merge. Whether this is practical depends on your format and host. The sources behind this guidance establish how Mermaid, PlantUML, and Structurizr are embedded, rendered, and exported. They do not establish one universal validation setup, so treat the following as options to evaluate rather than a standard.

  • Parse each diagram source with the same tool version your documentation host uses, and fail the job on a syntax error.
  • For Structurizr workspaces, run the export step in CI and fail if it errors, so that a broken model is caught when it is changed rather than when someone opens the page.
  • Keep the check fast. A slow check gets skipped, and a skipped check is worse than none because it creates false confidence.

A passing check shows the syntax is valid and, at most, that the diagram renders. It does not show that the diagram describes the current system.

When this approach is a poor fit

  • Your documentation lives outside Git, and the people who maintain it do not work through repository changes.
  • The architecture changes so often that a diagram is out of date before it is reviewed. In that case, generate diagrams from the system itself where your tooling allows, rather than hand-editing them.
  • A single diagram needs precise manual layout that the text notation cannot express without workarounds. Keep a rendered image for that case, and store its source alongside it if the tool allows.
  • The team is not willing to make diagram updates part of the review. Text sources in a repository without a review habit are just another folder of files.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.