- MindByte Weekly Pulse: Weekly IT Insights: Quick GitHub, Azure, & .NET Updates
- Posts
- Building Async and Cloud Native organizations - Issue #22
Building Async and Cloud Native organizations - Issue #22
Unlock the Power of Diagrams: Revolutionize Your Documentation with MermaidJS!
Welcome to my weekly newsletter! Every week, I bring you the latest news, updates, and resources from the world of coding and architecture. I'm so glad you've decided to join me, and I can't wait to share my insights and expertise with you.
I hope you'll find this newsletter to be a valuable resource, and I welcome your feedback and suggestions. If there's something you'd like to see more of, or if you have any questions or comments, please don't hesitate to contact me.
Thank you for joining me, and happy reading!
MermaidJS: Diagramming, Charting, and Visualizing Data Made Easy
Documentation is an essential part of software development. However, creating documentation is often time-consuming and becomes outdated quickly. Diagramming and documentation costs precious developer time and gets outdated quickly. But not having diagrams or documentation ruins productivity and hurts organizational learning. This is where Mermaid comes in.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/4d5487e0-a1cc-488d-bf0c-4de3b146002f/nsey-benajah-WaWV3DVqTA0-unsplash.jpg)
Photo by Nsey Benajah on Unsplash
Mermaid is a JavaScript-based diagramming and charting tool that takes Markdown-inspired text definitions and creates diagrams dynamically in the browser. The main purpose of Mermaid is to help documentation catch up with development.
To keep documentation up-to-date, it is important to store diagrams alongside the code. This way, they are easily modifiable, and the diagrams remain in sync with the code. GitHub natively renders Mermaid diagrams, so no plugins or converters are needed, making it a seamless process.
Mermaid supports various types of diagrams, including flowcharts, sequence diagrams, class, state, and entity relationship diagrams, user journeys, Gantt charts, pie charts, requirement and C4C diagrams, timelines, mindmaps, and GitGraphs.
Flowchart
A flowchart is a pretty basic example of the power of Mermaid. Here's a simple example of a flowchart in Mermaid syntax:
```mermaid
graph LR
A[SystemA] -->|Raw transaction| B(SystemB)
C[SystemC] -->|Relations| B
B -->|Transaction| D(SystemD)
D -->|Status change| B
```
Which will get converted into the below image. When you want GitHub to render this, make sure to include the code block (starting and ending with three `) and indicate it is a mermaid type.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/f120b680-b44b-4a76-a99a-8a78c5f81aa9/image.png)
Timeline
Mermaid also provides visualizations for timelines. A timeline is a type of diagram used to illustrate a chronology of events, dates, or periods of time. It is usually presented graphically to indicate the passing of time, and it is usually organized chronologically. Here is an example of a timeline in Mermaid syntax:
```mermaid
timeline
title History of Social Media Platform
2002 : LinkedIn
2004 : Facebook : Google
2005 : Youtube
2006 : Twitter
```
Generating this timeline from those six lines of code in Mermaid.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/66d7fa78-bd0b-434e-a4af-db39391f4e05/image.png)
Mindmaps
MermaidJS also supports mind maps, a diagram used to visually organize information into a hierarchy, showing relationships among pieces of the whole. Major ideas are connected directly to the central concept, and other ideas branch out from those major ideas. This is particularly useful for brainstorming, organizing thoughts, and presenting ideas in a clear and concise manner.
Here is an example of a mind map in Mermaid syntax:
```mermaid
mindmap
Root
Activities
Sport
Running
Swimming
Culture
Music
Theater
Transportations
Car
Plane
```
When we let GitHub render this, we get the following:
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/717eacc2-8ac8-45a9-9247-5edda6b09fd3/image.png)
This syntax will create a mindmap with two sub-nodes, each has a sub node as well. As with all Mermaid diagrams, the syntax is easy to read and write, and the diagram is easy to modify as needed.
GitGraph
GitGraph is another visualization provided by Mermaid. It is a pictorial representation of Git commits and Git actions on various branches, which is particularly helpful for developers and DevOps teams to share their Git branching strategies. For example, it makes it easier to visualize how Git flow works. Here is an example of GitGraph in Mermaid syntax:
```mermaid
gitGraph
commit
commit id: "Wrong commit"
branch develop
checkout develop
commit
commit
checkout main
merge develop
commit
commit
```
Rendering a nice git graph. As this is just text converted into a graphic, you can use scripting to output the text. A simple bash or powershell script can be used to preprocess the data so that you have a nice-looking visualization. Allowing you to extract the needed data from a source system.
![](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/4c212388-64de-4aa5-bcb8-02d8333650e3/image.png)
Conclusion
In conclusion, documenting diagrams and visualizations is crucial for software development projects. Storing them alongside the code is an efficient way to ensure that the documentation stays up-to-date and is easily accessible to all team members.
MermaidJS is an excellent solution that allows users to create easily modifiable diagrams in a variety of formats, from flowcharts to timelines and mind maps. And with GitHub's native support for MermaidJS, rendering diagrams directly in issues, readme files, comments, and pull requests has never been easier.
I hope you've enjoyed this week's issue of my newsletter. If you found it useful, I invite you to share it with your friends and colleagues. And if you're not already a subscriber, be sure to sign up to receive future issues.
Next week, I'll be back with more articles, tutorials, and resources to help you stay up-to-date on the latest developments in coding and architecture. In the meantime, keep learning and growing, and happy coding!
Best regards, Michiel
Reply