I finally got a chance to look at a pretty decent text-to-diagramming tool called D2, found here: https://d2lang.com/tour/intro/. I liked the idea behind doing diagramming via text, because using drawing tools for diagramming is always tedious. One of the things that I lacked in the past was a good system to accomplish just that task, to visually explain ideas. With a fresh new opportunity to consider how to improve my workflow when thinking about projects.
For what it is worth, I tried PlantUML in the past: https://plantuml.com/ I guess I was never really happy with the look of it out-of-the-box. I do know that the Emacs mode for PlantUML is quite decent though (that is, as opposed to the D2 one, which is OK, but still in beta.)
The core reason for using tools like this is that it treats diagrams like source code. I am not sure how far I would use https://en.wikipedia.org/wiki/Literate_programming programming tools, yet. (Jupyter is the most well-known modern variant of the idea.) The thing is though that explaining concepts as quick as like writing a quick program is much easier than playing drag-and-drop.
Tools are only useful though as they have applications. And, one of the first things I was thinking about was a tiny system for my blog here to go from a web page to publishing without intermediate deployment steps. Architecturally, I was thinking of adding a Kafka producer/consumer into it. It's really over-the-top for this, but it is more to use Kafka on something.
I wrote this:
direction: right
git_repo: Git Repository
create: Producer Flow {
edit_page: Edit Page
edit_page.shape: page
publish_worker: Publisher
edit_page -> publish_worker -> _.consume.topic_pubreq
}
consume: Consumer Flow {
topic_pubreq: Publish Request Topic
topic_pubreq.shape: queue
topic_pubreq -> publisher_logic
publisher_logic: Processes To Publish Or Defer {
process_worker_1: Process Worker 1
process_worker_2: Process_Worker 2
process_worker_1 --> _.topic_pubreq: If draft or delayed
process_worker_2 --> _._.git_repo: Publish to git repository
explanation: |md
These will either
* publish now
* ignore based on if it is a draft,
* or put back into queue if it needs to be delayed.
Multiple processes handle imaginary needs for scale, something
that would make Kafka shine here. :)
|
}
}
Which looks like this (it is an SVG, which could be resized automatically, but I am lazy :) ):
(Maybe in a follow-up post, I'll write about implementing this?)
I learned enough of D2 by just breezing through the manual. It's useful to understand that "shapes", which are like immutable variables also have a scope that reflects in the output graph. The above _.
syntax allows you to hop through the levels of scope. It would be nice if the compiler saw "variables" in outer scopes. The reason is that it would make snippets of code portable. However, that's a nitpick for me and would not rush to file an issue on that.
Just like in PlantUML, I don't really see a way to have diagram "functions" or "modules", which would be mind-blowing :) However, I see this is in progress: https://github.com/terrastruct/d2/issues/554. So this is something to follow up on.
In all, I think this is a project to keep following up on and to see where it goes, and of course, I will use this post to add additions to my own research.
Made with Bootstrap and my site generator script.