backstage-plugin-techdocs-addon-mermaid icon indicating copy to clipboard operation
backstage-plugin-techdocs-addon-mermaid copied to clipboard

RFC: Automatic transforms to catalog entities in mermaid

Open jtreher opened this issue 1 year ago • 2 comments

I had an idea, but I don't know if it would actually be practical in the long term. This would make sense for diagrams where you are showing detail for how systems interact with one another. Like, I want to create very specific graphs for specific use cases of our enterprise.

I am looking for comment regarding a token you could add to your diagram nodes to indicate that they are catalog entities (ex: *** as a prefix for an entity to be followed by its entity ref (partial?))

  1. If that token is found in the diagram, before doing the render of the mermaid string, it would fetch the entity details for the indicated entities found from the catalog API.
  2. It would replace the text from the marker to the entity title and it would also make the diagram node a clickable link

For example:

graph
    ***system/my-system-->***system/another-system

would be converted to

graph
    my-system[My system]-->another-system[Another System]

    click my-system "/catalog/default/system/my-system" _blank
    click another-system "/catalog/default/system/another-system" _blank

Cons:

  1. Mermaid preview works really well in markdown preview tools with the right extensions. This would make a real preview only possible in Backstage or with the TechDocs CLI.
  2. Potential security issue unless you only allow relative links .
  3. More complexity in the plugin.

jtreher avatar Dec 06 '23 12:12 jtreher