{"id":3162,"date":"2019-03-22T18:07:23","date_gmt":"2019-03-22T18:07:23","guid":{"rendered":"https:\/\/blog.paranoidprofessor.com\/?p=3162"},"modified":"2019-03-22T18:07:23","modified_gmt":"2019-03-22T18:07:23","slug":"dipping-your-toes-into-the-ocean-with-mermaid","status":"publish","type":"post","link":"https:\/\/blog.paranoidprofessor.com\/index.php\/2019\/03\/22\/dipping-your-toes-into-the-ocean-with-mermaid\/","title":{"rendered":"dipping your toes into the ocean with Mermaid"},"content":{"rendered":"<p>It began with a great idea.<\/p>\n<blockquote><p>&#8220;lets do our systems graphs in such a way we can version them in GIT&#8221;<\/p><\/blockquote>\n<p>Anyway, I believe that is how it started.\u00a0 I was then told that perhaps the open source tool Mermaid would be the solution to that grand idea.<\/p>\n<p>It did look pretty good.\u00a0 I tried using this for some trivial graphs and I was amazed at how well it worked.\u00a0 You could create a small flow chart within a few minutes.\u00a0 Not only that but the graphs that where created were SVG, that wasn&#8217;t really on my radar but it would have been useful a few projects back.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-3163 aligncenter\" src=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/03\/mermaid-v1.png\" alt=\"\" width=\"262\" height=\"266\" \/><\/p>\n<p>&nbsp;<\/p>\n<table class=\"w3-table-all\">\n<tbody>\n<tr>\n<th>Version 1<\/th>\n<\/tr>\n<tr>\n<td>graph TB<br \/>\nAuthServer(&#8220;Oath v2.0)&#8221;)<br \/>\nUserDB\u00a0AuthServer&#8211;&gt;UserDB<br \/>\nUserDB &#8211;&gt;AuthServer<br \/>\nclient(user\/browser)&#8211;https &#8211;&gt;AuthServer<br \/>\nextpgm(ext system) &#8212; https &#8211;&gt;AuthServer<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>I did like this but to be honest it didn&#8217;t really keep the systems properly grouped together.\u00a0 That was also quickly correct by grouping the systems as a sub graph.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-3164\" src=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/03\/mermaid-v2.png\" alt=\"\" width=\"519\" height=\"232\" srcset=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/03\/mermaid-v2.png 519w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/03\/mermaid-v2-300x134.png 300w\" sizes=\"(max-width: 519px) 100vw, 519px\" \/><\/p>\n<table class=\"w3-table-all\">\n<tbody>\n<tr>\n<th>Version 2<\/th>\n<\/tr>\n<tr>\n<td>graph LR<br \/>\nsubgraph Internal Systems<br \/>\nAuthServer(&#8220;Oath v2.0)&#8221;)<br \/>\nUserDB\u00a0AuthServer&#8211;&gt;UserDBUserDB &#8211;&gt;AuthServer<br \/>\nendsubgraph Client Services<br \/>\nLogin\u00a0 \u00a0 \u00a0 \u00a0\u00a0client(user\/browser)&#8211;https &#8211;&gt;AuthServer<br \/>\nextpgm(ext system) &#8212; https &#8211;&gt;AuthServer<br \/>\nend<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Mermaid seemed to handle these flows just fine.\u00a0 Not being content with this I tested the sequence diagrams.\u00a0 They actually seemed to work even easier.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-3168 aligncenter\" src=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/03\/mermaid-sequence-300x239.png\" alt=\"\" width=\"394\" height=\"314\" srcset=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/03\/mermaid-sequence-300x239.png 300w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/03\/mermaid-sequence.png 569w\" sizes=\"(max-width: 394px) 100vw, 394px\" \/><\/p>\n<p>&nbsp;<\/p>\n<table class=\"w3-table-all\">\n<tbody>\n<tr>\n<th>Sequence Diagram<\/th>\n<\/tr>\n<tr>\n<td>sequenceDiagram<br \/>\nuser-&gt;&gt;+AuthServer: User credentials<br \/>\nAuthServer -&gt;&gt;+ user: token<br \/>\nNote right of AuthServer: Token valid 6 hours<br \/>\nuser-&gt;&gt;+MediaServer: requests movie + token<br \/>\nalt token valid<br \/>\nMediaServer -&gt;&gt;+ user: streams content<br \/>\nelse token valid<br \/>\nMediaServer &#8211;&gt;&gt;- user: request refused<br \/>\nend<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>I was about to bring all of this to my team leaders attention when I received some feedback from one my teammates. He was correct, color makes things not only less boring but can also visually help with grouping like items together.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-3165\" src=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/03\/mermaid-v3.png\" alt=\"\" width=\"646\" height=\"277\" srcset=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/03\/mermaid-v3.png 646w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/03\/mermaid-v3-300x129.png 300w\" sizes=\"(max-width: 646px) 100vw, 646px\" \/><\/p>\n<table class=\"w3-table-all\">\n<tbody>\n<tr>\n<th>Version 3<\/th>\n<\/tr>\n<tr>\n<td>graph LR<br \/>\nclassDef cyan fill:cyan<br \/>\nclassDef yellow fill:yellowsubgraph Internal Systems<br \/>\nAuthServer[&#8220;Oath v2.0)&#8221;]<br \/>\nUserDB(Login data)<br \/>\nDetailsDB(Customer Details)<br \/>\nAuthServer&#8211;&gt;|JDBC|UserDB<br \/>\nUserDB &#8211;&gt;|WebSphere|AuthServerclass AuthServer yellow<br \/>\nclass UserDB cyan<br \/>\nclass DetailsDB cyan<br \/>\nend<br \/>\nsubgraph Client Services<br \/>\nLogin\u00a0 \u00a0 \u00a0 \u00a0\u00a0client(user\/browser)&#8211;https &#8211;&gt;AuthServer<br \/>\nextpgm(ext system) &#8212; https &#8211;&gt;AuthServerend<br \/>\nlinkStyle 2 stroke-width:2px,fill:none,stroke:green;<br \/>\nlinkStyle 3 stroke-width:2px,fill:none,stroke:green;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>It was at this point that I realized that these connections between elements was only one way.\u00a0 Unfortunately you cannot simply have a line with arrows at each end. I didn&#8217;t think that adding a few back arrows would make that big of a change to the diagrams but unfortunately they did.\u00a0 Not only that as you start to add a lot of different elements, each with bi-directional communication, the nicely ordered elements start to change places.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-3166\" src=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/03\/mermaid-v4-300x252.png\" alt=\"\" width=\"300\" height=\"252\" srcset=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/03\/mermaid-v4-300x252.png 300w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/03\/mermaid-v4.png 617w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-3167\" src=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/03\/mermaid-v5-300x236.png\" alt=\"\" width=\"300\" height=\"236\" srcset=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/03\/mermaid-v5-300x236.png 300w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/03\/mermaid-v5.png 613w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>&nbsp;<\/p>\n<table class=\"w3-table-all\">\n<tbody>\n<tr>\n<th>Version 4<\/th>\n<\/tr>\n<tr>\n<td>graph LR<br \/>\nclassDef cyan fill:cyanclassDef yellow fill:yellow<br \/>\nsubgraph Internal Systems<br \/>\nAuthServer[&#8220;Oath v2.0)&#8221;]<br \/>\nUserDB(Login data)<br \/>\nDetailsDB(Customer Details)<br \/>\nPresenter[catalog system]<br \/>\nAuthServer&#8211;&gt;|JDBC|UserDB<br \/>\nUserDB &#8211;&gt;|WebSphere|AuthServer<br \/>\nclass AuthServer yellow<br \/>\nclass UserDB cyan<br \/>\nclass DetailsDB cyan<br \/>\nend<br \/>\nsubgraph Client Services\u00a0Login<br \/>\nclient(user\/browser)&#8211;https &#8211;&gt;AuthServer<br \/>\nAuthServer &#8211;&gt;clientAuthServer &#8211;&gt;extpgm<br \/>\nextpgm(ext system) &#8212; https &#8211;&gt;AuthServerend<\/td>\n<\/tr>\n<tr>\n<td>version 5<\/td>\n<\/tr>\n<tr>\n<td>graph LR<br \/>\nclassDef cyan fill:cyan<br \/>\nclassDef yellow fill:yellow<br \/>\nsubgraph Internal Systems<br \/>\nAuthServer[&#8220;Oath v2.0)&#8221;]<br \/>\nUserDB(Login data)<br \/>\nDetailsDB(Customer Details)<br \/>\nPresenter[catalog system]<br \/>\nAuthServer&#8211;&gt;|JDBC|UserDB<br \/>\nUserDB &#8211;&gt;|WebSphere|AuthServer<br \/>\nclass AuthServer yellow<br \/>\nclass UserDB cyan<br \/>\nclass DetailsDB cyan<br \/>\nend<br \/>\nsubgraph Client Services Login<br \/>\nclient(user\/browser)&#8211;https &#8211;&gt;AuthServer<br \/>\nAuthServer &#8211;&gt;client<br \/>\nAuthServer &#8211;&gt;extpgm<br \/>\nextpgm(ext system) &#8212; https &#8211;&gt;AuthServer<br \/>\nend<br \/>\nclient &#8211;&gt;Details<br \/>\nDBclient &#8211;&gt;Presenter<br \/>\nlinkStyle 2 stroke-width:2px,fill:none,stroke:green;<br \/>\nlinkStyle 3 stroke-width:2px,fill:none,stroke:green;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The colors of the elements remains easy enough, but as the number of elements increases finding and changing the colors of the lines becomes more and more like software development.\u00a0 The hacking kind, not the software engineering kind.<\/p>\n<p>The task that I was given had enough elements on it to take up half of a keyboard but this type of graph doesn&#8217;t automatically look very good.\u00a0 It is simply too much.<\/p>\n<p>I did like the few hours that I spent fooling around with Mermaid.\u00a0 I can see how this might be nice if you have some simple elements that should be graphed.<\/p>\n<div id=\"attachment_3169\" style=\"width: 465px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-3169\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-3169\" src=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/03\/mermaid-gantt-300x165.png\" alt=\"\" width=\"455\" height=\"252\" srcset=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/03\/mermaid-gantt-300x165.png 300w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/03\/mermaid-gantt-768x423.png 768w\" sizes=\"(max-width: 455px) 100vw, 455px\" \/><p id=\"caption-attachment-3169\" class=\"wp-caption-text\">This example exist on Mermaid page<\/p><\/div>\n<p>Perhaps Mermaid is an exceptional tool for either sequence diagrams or gantt charts but I don&#8217;t really need that at the moment.<\/p>\n<p>If you really want, you can even add Mermaid to your web pages.\u00a0 As for me, I am not certain that I would want the diagrams to be outside of my direct control and at the moment human beings are able to make more of the simplifying decisions for item placement.<\/p>\n<p>&nbsp;<\/p>\n<p>I really with I could give this project two thumbs up but I did encounter a few things that would prevent me, certainly in larger sittings, from using this.<\/p>\n<ol>\n<li>It is not possible to have lines with arrows on each side<\/li>\n<li>It is not possible to simply add notes or legends to flow charts<\/li>\n<li>It is snot possible to have a line from one entire subgraph to another item or subgraph<\/li>\n<li>No influence on the element placement<\/li>\n<li>SVG output from the tool isn&#8217;t well supported by Microsoft products, or else there is a problem with the SVG image.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>It began with a great idea. &#8220;lets do our systems graphs in such a way we can version them in GIT&#8221; Anyway, I believe that is how it started.\u00a0 I was then told that perhaps the open source tool Mermaid &hellip; <a href=\"https:\/\/blog.paranoidprofessor.com\/index.php\/2019\/03\/22\/dipping-your-toes-into-the-ocean-with-mermaid\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/3162"}],"collection":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/comments?post=3162"}],"version-history":[{"count":5,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/3162\/revisions"}],"predecessor-version":[{"id":3175,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/3162\/revisions\/3175"}],"wp:attachment":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/media?parent=3162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/categories?post=3162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/tags?post=3162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}