yuzutech / kroki

Creates diagrams from textual descriptions!

Home Page:https://kroki.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for structurizr workspace.json for layout information

tlanfer opened this issue · comments

We keep our architecture charts as a separate workspace.dsl file in a repository which we render via the mkdocs-kroki-plugin and then just reference it in different locations in our documentation as:

#  ContentRepositoryApp

```kroki-structurizr view-key=someSpecificView
@from_file:workspace.dsl
```

The automatic layouting is sometimes not ideal. Its easy enough to manually arange things to look good. Unfortunately it looks like there is no way to also provide the workspace.json file, which stores information on manually arranged view.

I considered if this a mkdocs-kroki-plugin limitation, but looking at the kroki docs it doesnt look like there is a way to provide more than one file to the render endpoints.

It would be great if it was possible.

Looking into alternative approaches to render these charts, i learned that none of the available structurizr exporters even support exporting manual layouting, which i guess makes this issue a bit wishfull thinking.

export-diagrams.js from https://github.com/structurizr/puppeteer
allows you to render diagrams with custom layout.

I currently have a script that starts docker.io/structurizr/lite, then runs export-diagrams.js against that.
Works great.

Would off course be nicer if it would be integrated with kroki.

I see that kroki already uses puppeteer for other use cases, so I guess technically this would be possible.
But I don't know about the internals of kroki and how it interfaces with structurizr, so can not say how much work this would be to add or change.

I see that kroki already uses puppeteer for other use cases, so I guess technically this would be possible. But I don't know about the internals of kroki and how it interfaces with structurizr, so can not say how much work this would be to add or change.

Hey, i followed this issue... This was last year one thing i thought, when i came to wardleymapping and kroki... So i began to dig a little bit. It is not very difficult. I am using puppeteer as well as the diagrams.io implemenetation. So, feel free to copy and adjust it to your needs. :) https://github.com/yuzutech/kroki/blob/d97533eec6309c5a393dc4ce00cf2fc542cbcce3/onlinewardleymaps/src/index.js

In my case, i removed some stuff in the website of onlinewardleymaps.com to polish the output. So maybe something you need to do aswell.

I don't have time to code this right now, but something like this might work (dumping here for future self or someone else):

  • run the docker.io/structurizr/onpremises as a container
  • for each request
  • when sending post requests to kroki, send the workspace.json file as "diagram_options"
  • possibly, when sending get requests encode both the workspace.dsl and the workspace.json file as one payload (url length may become a problem) and split them server side.

edit: actually, workspace.json contains workspace.dsl, and is what the api expects to get anyway.