Tool Alternatives

Python diagrams library alternative: when the .py file becomes the thing that rots

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

The diagrams library by mingrammer is the reason a lot of engineers stopped opening drawing tools. Write Python, get a clean cloud diagram with official provider icons, keep it in version control, review it in a pull request. It was built for prototyping a new architecture without design tools, and at that job it is very hard to beat. The trouble starts when the prototype becomes the system and the .py file becomes documentation.

6 min readFor teams whose architecture diagram is a Python file nobody has run this quarter

See it as a diagram

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

145/20003 credits left
Try:

No account needed · Editable canvas, not a picture

Why the library earned its place

Four properties explain the adoption. Diagrams are code, so they diff, review, and version like everything else. The node catalog is wide: AWS, Azure, Google Cloud, IBM, Oracle Cloud, Alibaba Cloud, DigitalOcean, OpenStack, Firebase, Elastic, Kubernetes, on-premise, SaaS, programming frameworks, and a C4 set, all with official icons, so the picture looks like the deck it will end up in. Cluster blocks give you grouping without fighting a layout engine. And it costs nothing.

For prototyping, the loop is genuinely fast: sketch a topology in twenty lines, render, adjust, paste into an RFC. That is the use case the project states for itself, and pages that criticize the library for not being a documentation platform are criticizing the wrong tool.

The three frictions in production use

Graphviz. The project states it plainly: it renders through Graphviz, so Graphviz has to be installed to use diagrams at all, on top of Python 3.9 or higher. Every machine that regenerates the picture needs both, CI runners and the laptop of whoever inherits the repo included. It is a small dependency that becomes a small ritual, and small rituals are the ones that stop happening.

Layout. Because the layout comes from Graphviz, controlling it means learning graph attributes, ranks, and invisible edges. Teams end up with a file where half the lines exist to make the picture come out straight, which makes the file harder to keep truthful.

The second source of truth. This is the one that matters. The .py file is not the infrastructure; it is a hand-written claim about the infrastructure that happens to be written in Python. Terraform can add a Redis cluster, a Helm chart can add a sidecar, and the diagram script stays green because it never looked. Diagram-as-code gives you a versioned history of the claim, not a check on the claim.

Written out as the sequence it actually is, the cost is easier to judge. Four of the five steps below are automatable. The one that is not is the one that fails.

# keeping a diagrams.py picture current, in full
brew install graphviz               # or apt-get install graphviz, on every machine
pip install diagrams                # Python 3.9 or higher
python architecture.py              # writes architecture.png
git add architecture.py architecture.png
git commit -m "docs: redraw after the redis cache landed"

# the step nothing schedules and nothing enforces:
# noticing that the redis cache landed at all

The alternative: derive the picture from the repository

Datadef connects to the repository read-only on GitHub, GitLab, or Azure DevOps, reads the architecture-dense files (infrastructure as code, containers and orchestration, schemas and dbt models, API specs, CI pipelines, manifests), and generates the diagram plus an architecture.md. A daily sync regenerates both when the code moves, and you can refresh from the app or from a coding agent over MCP.

The icons carry over. The catalog holds more than 2000 marks, among them 438 AWS, 624 Azure, and 226 Google Cloud, so an S3 bucket looks like S3 and a dbt model looks like dbt, which is what made the Python library pleasant in the first place. A type the catalog does not recognise gets a neutral mark rather than a plausible wrong logo. The canvas is editable when the generated result needs a human touch, and exports as PNG or JPEG.

Regeneration is not a fresh drawing every morning either. Each sync hashes what actually feeds the diagram, so a commit that only touched a README, a test, or a comment leaves that hash unchanged and nothing is redrawn. When the structure did change, the previous ids, labels, and zones are handed back to the generator with instructions to reuse everything that still exists, and any node someone dragged keeps its coordinates. A one-resource change reads as a one-node change, which is a property a committed PNG never had.

The distribution model is different too. Rather than committing a rendered image next to the script, you embed a live image in the README, and the picture in the README is the current one by default.

Keep the library for what it is good at

For a proposed architecture that does not exist yet, there is nothing to derive from, and a twenty-line Python file remains the fastest path from idea to picture. The same goes for teaching material and for diagrams that need to say something the code does not contain, like a migration plan in three phases.

The rule of thumb: if the diagram describes something that exists in a repository, generate it. If it describes something that does not exist yet, draw it, from Python or from a prompt.

FAQ

Do I need Graphviz or any local dependency for Datadef?

No. The diagrams library needs Graphviz installed on every machine that renders, plus Python 3.9 or higher. Datadef parses the repository server side after a read-only connection and renders the diagram in the browser, so there is nothing to install, and a reader opening the embedded image needs no toolchain and no account.

Can I keep using the diagrams library alongside a generated diagram?

Yes, and the split usually works well: the Python file for proposed or illustrative architecture, the generated diagram for the as-built system that has to stay accurate. They answer different questions and do not conflict, and the library is explicit that prototyping a design without design tools is what it was built for.

Does the generated diagram use the same official provider icons?

It draws from a catalog of more than 2000 real icons, including 438 AWS marks, 624 Azure, and 226 Google Cloud, alongside Kubernetes and data tooling. Resources render with the logos readers recognize rather than generic boxes, and a type the catalog does not know gets a neutral mark instead of a wrong guess.

How does a generated diagram get into a pull request review?

The usual pattern is a live embed line in the README or an architecture page, so reviewers see the current diagram in context. The diagram itself is regenerated by the sync rather than committed, which avoids a rendered image changing on unrelated commits.

What if my repository is not infrastructure code at all?

Generation is grounded in the architecture-dense files it can find, including container and orchestration files, schemas, API specs, CI pipelines, and manifests. A repository with none of those will produce a thin diagram, and describing the system in a prompt is the better route.