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.

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.

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.

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:

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.

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

or to participate.