I get the want to define architectural relationships as a node & edge structure rather than just purely diagrams, which is an argument for D2 over Mermaid
but why not just use https://github.com/jsongraph?