-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Diagram: Architecture #5452
New Diagram: Architecture #5452
Conversation
…s/mermaid into 5367/architecture-diagram
❌ Deploy Preview for mermaid-js failed.
|
@sidharthv96 Continuing our conversation from the issue, I commented on SVG loading and my thought process behind how the layout is handled. Let me know what your thoughts are. Additionally, an example of what forked edges would look like once implemented: Regarding multiple edges going into one side of a service, it's possible but I'll need to spend some time figuring out the cleanest way to implement that functionality. Ultimately I was planning on using forked edges to handle that scenario but after looking at your example the arrows can't be as neatly represented the same way through forked edges. |
How did you test the diagram to get that result? I can't seem to reproduce it. |
Not being a mermaid or architecture native, consistency would be a plus for me. Worth noting that the |
Hi @NicolasNewman! This looks really promising! There are some ongoing projects that might be good for you to be aware of, as they touch on what you are doing here: The first one is: Refactoring Rendering in Mermaid (#5237): The initial PR will convert flowcharts and state diagrams, with plans to extend this to all graph-based diagrams. Note: This shouldn’t block your initial PR, but it would be great to collaborate on converting to the new structure eventually, allowing for multiple layout options. The second activity is that we are adding a new Syntax for Flowchart attributes (Another PR): Looking forward to the architecture diagrams as well as the icons. |
Another note on the syntax:
In the defence of consistency. What if the port could be attached to the node for instance with a colon then you could use regular mermaid arrow syntax to simplify for users. Then this:
would turn into:
or even like this depending on the grammar
(I suspect the grammar with the port at the end is easier to handle) |
I'm not particularly attached to the current syntax. I actually like the colon version more in the 2nd example you gave. I'll take a look at the first PR you linked, it sounds like an exciting change! I'd be happy to collaborate on that in the future. With regards to icons, I added a page to the documentation in this PR regarding how to use icons and create external icon packs. Let me know your thoughts once you get the chance to look at it. It's designed to where it should easily be easy to integrate with other diagrams but there may be some factors I haven't considered. |
Just out of curiosity...how close is this feature to becoming reality? |
We are getting close to getting this in. Rough guess 1-2 weeks. |
@NicolasNewman Awesome work. @knsv and I went through the demos and thought this diagram type be a great addition. We think that using the Icon packs that are lazily loaded makes sense for the Icon registering and loading, but the ZenUML approach to creating the Icon pack will be easier to maintain. The We should make several Icon packs like AWS, Google, mermaid, etc, in the repo, and lazy load them in Mermaid initialize. |
Once the conflicts are resolved, we will merge this PR. |
…5367/architecture-diagram
Conflicts are now resolved. @ashishjain0512 Do you want me to convert the other icon packs currently in this PR to be lazy loaded as well? Currently only aws:full is. I'm assuming the structural changes will be made afterwards? One improvement to the documentation of this feature I haven't touched on yet was adding the names and a preview of the icons available. I'm not as familiar with the auto-generation portion of the documentation but I'd think another benefit of using the ZenUML approach is the icons being in an SVG file will be easier to add to the docs then if they were in a TS file. |
@NicolasNewman For the packs: Yes, please do! We also appreciate the work you have been doing on the project. As such, we would be happy for you to join the core team! If you are interested, ping me directly in Discord. |
🦋 Changeset detectedLatest commit: 80c4b24 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📑 Summary
Architecture diagrams allows users to show relations between services
Resolves #5367
📏 Design Decisions
Parser
Terminology
Syntax
Currently, the syntax is defined as:
service {id}({icon})[{title}] (in {group_name})?
group {id}[{title}] (in {group_id})?
{id_1} ( ( )?(L|R|T|B)--(L|R|T|B)( ) )? {id_2}
Once I transition from jison to Langium, I plan to add the following extensions:
group {id}({icon})[{title}] (in {group_id})?
{id_1} ( ( )?(L|R|T|B)-([{label}])-(L|R|T|B)( ) )? {id_2}
service {id}( ({icon}) | ("{text}") )[{title}] (in {group_name})?
Additionally, the syntax for groups (and potentially forked edges?) will be modified to better follow a declare then organize approach
Layout
Comments
As mentioned in the issue, the LRTB syntax goes against the ethos of Mermaid. Additionally, while the spatial map creates very neatly organized layouts, it prevents users from having multiple edges going out of one side. Part of the reason I began designing it this way was to avoid this diagram type from essentially being a flowchart with icons.
Going forward, there's a few options that can fix this problem:
fcose
and let it figure things out on its own.No matter which option we choose, the LRTB syntax should be extended to:
SVG Icons
SVG icons are currently created and accessed through helper functions inside of rendering-util/svgRegister.ts. A global object stores the mapping of icon names to
IconResolvers
defined asIconResolvers can easily be created through the helper function
createIcon
. This function takes the SVG code as a string along with the original resolution. It returns a CB function taking the element to inject the SVG into and optionally a different size to scale it by.A few generic icons I've created are located in rendering-utils/svg/. Additional icons can be added through the new
iconLibraries
config option. The types insvgRegister.ts
are now exported frommermaid.ts
, allowing developers to create their own icon library packages.Alternatives
From conversations in the linked issue, ZenUML already handles SVG icons on their end. Upon furthur inspection, they rely on declaring an svg module which essentially resolves the imported SVG as a string. Since the end result of both of these approaches are the same (having the SVG code as a string), personally I think it's debatable if we want to go through with this extra step. The main con I foresee is that it'll add more work for people who want to make their own icon library package as they will need to setup the declarations themselves.
On a side note, it looks like ZenUML directly added the official AWS icons to their repo here. IANAL but the terms Amazon states are:
This may mean we can make official icon packs in seperate packages, or have them be lazy loaded as needed. Ultimately I'll leave that decision up to you as that isn't my area of specialties.
Todo
📋 Tasks
Make sure you
MERMAID_RELEASE_VERSION
is used for all new features.develop
branch