Diagram as Code
github.com
github.com
Even worse, a small change to the structure will typically cause a full re-layout, and place nodes completely differently to the previous output, making visual/mental comparisons between versions quite taxing.
Given that autolayout is likely never going to be as good as someone doing some amount of manual layout or at least hinting, it'd be nice if there was some way to allow explicit placement of items and track it as metadata independently of the model changes.
I think Structurizr[1] has some capabilities along these lines, but the editor wasn't great the last time I tried it, and I think largely requires their SaaS for tracking that layout info.
Another option might be to feed it all into some flavour of graph DB with interactive querying/filtering and layout, and let users produce just the diffs / bits that they care about, if practical.
I would rather spend the extra time making something that's more readable and has a better layout.
The only exception for me would be for something that changes frequently where any diagram made by hand would go out of date quickly or be burdensome to maintain (not that diagrams usually get maintained...)
I've dabbled in the past with trying to do auto-layout of new items while preserving explicit changes by hacking at some of the Cytoscape.js layout providers to heavily penalise moves to manually positioned nodes, but I've never managed to make anything close to what I'd call acceptable for general use.
I think there is something of a truism here... hand-made diagrams don't get updated because they are so hard to maintained.
However, I agree auto diagraming some random topology doesn't work nearly as well, and worse if it is a complex one. They tend to look like a spaghetti mess.
How are you generating the templates/base topology structures for that?
Diagrams as Code 2.0 • Simon Brown • GOTO 2021: https://www.youtube.com/watch?v=Za1-v4Zkq5E&t=1847s
The C4 model for visualising software architecture: https://c4model.com/
Intro to Structurizr: https://www.baeldung.com/structurizr
The Python→Go port was discussed on Sep 27, 2020 — https://news.ycombinator.com/item?id=24603926
Someone was also working on a web editor (maybe with Electron), but I forgot the name of the repository.
However, these days I prefer to just have diagrams generated from the source code itself, like:
- https://github.com/cycloidio/inframap
- https://graphviz.org/Gallery/directed/bazel.html
In order to make a compelling use case out of having to maintain a parallel definition like this, I think it needs to be able to contribute to analysis like formal verification or, despite them stating that it's not a goal, being able to create the described architecture. Or even generate something like a terraform plan. Otherwise it falls victim to the same problem as any other method of creating diagrams, that of them falling out of sync with the system.
They are a long way there already by providing a way to use a programming language backed by a large ecosystem of other tools that can be used to work with e.g. terraform, like python/go.
For understanding an existing thing, diagram from code seems great.
If I’m prototyping, I’m probably just going to draw a diagram on a whiteboard, not write code to create one. That’s bringing way too much cognitive overhead into the process that will distract from the task at hand.
Surely, my diagram shouldn't have programming crud around it
EDIT Actually, might be different...
Not doing crap like that is one of the things that I loved about Python...
no
1. https://airflow.apache.org/docs/apache-airflow/stable/tutori...
from diagrams import Diagram
from diagrams.aws.compute import EC2
with Diagram("Simple Diagram"):
EC2("web")
This has a very odd API. It's using (abusing?) context managers and contextvars to do weird spooky things that you could just as easily do with ordinary objects or functions.But wondering why it's using ">>". I'm not great with Python. How does this ">>" thing work and why does it make sense to associate elements with ">>".
In this case they’re overriding bitshifting. In terms of why, it does feel like a natural visual choice.
https://github.com/mingrammer/diagrams/blob/master/diagrams/...
Of course C++ has it, and it is one of the great footguns in its arsenal.
I think those garbage "academia" sites are constantly emailing, asking me to "claim" it.