I have paused working on my kino_wardley component for a while.
Just having a think about how to integrate diagram generation into a livebook.
I came up with this https://github.com/chriseyre2000/livebooks/blob/main/DynamicDiagrams.livemd
Here is the code
Mix.install([{:kino, "~> 0.7.0"}])
data = """
digraph architecture {
rankdir=LR;
subgraph client_side_apps {
front_end -> {auth_api, my_app_api};
extension -> {auth_api, my_app_api};
{rank=same; front_end, extension, auth_api};
}
subgraph api_gateways {
my_app_api -> {photos_ms, chats_ms, friends_ms};
}
subgraph microservices {
photos_ms -> {database};
chats_ms -> {database, cache};
friends_ms -> {database, facebook_api};
}
}
"""
{body, _} = System.shell( "echo '#{data}' | /usr/local/bin/dot -Tpng", stderr_to_stdout: true)
Kino.Image.new(body, :png)
It simply installs Kino and uses the graphviz command line tool dot to build a png which is then displayed in a Kino.Image.
This gives the basis of adding diagrams generated from dot or plantuml straight into a livebook.
These would make very useful as a LiveCell
