{"id":12354,"date":"2022-08-08T10:00:00","date_gmt":"2022-08-08T01:00:00","guid":{"rendered":"https:\/\/www.gigas-jp.com\/appnews\/?p=12354"},"modified":"2022-08-05T17:07:57","modified_gmt":"2022-08-05T08:07:57","slug":"diagram-as-code","status":"publish","type":"post","link":"https:\/\/www.gigas-jp.com\/appnews\/archives\/12354","title":{"rendered":"Diagram as Code"},"content":{"rendered":"\n<p>Diagrams allow you to draw cloud system architectures in Python code. It was created to prototype a new system architecture design without the use of design tools. You can also describe or visualize your existing system architecture.<\/p>\n\n\n\n<p>I once talked about Mermaid which is a JavaScript-based graphing and charting tool that takes Markdown-inspired text definitions and dynamically creates charts in your browser. You can read more below.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-\u30a2\u30d7\u30ea\u95a2\u9023\u30cb\u30e5\u30fc\u30b9 wp-block-embed-\u30a2\u30d7\u30ea\u95a2\u9023\u30cb\u30e5\u30fc\u30b9\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"ahEu2e2KZg\"><a href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11717\">Mermaid diagrams in Github markdown<\/a><\/blockquote><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Mermaid diagrams in Github markdown&#8221; &#8212; \u30a2\u30d7\u30ea\u95a2\u9023\u30cb\u30e5\u30fc\u30b9\" src=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11717\/embed#?secret=3QYMiE9NsT#?secret=ahEu2e2KZg\" data-secret=\"ahEu2e2KZg\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>Similarly, Diagram allows us to draw system architect design using just code. Diagram currently supports all major providers including AWS, Azure, GCP, Kubernetes, Alibaba Cloud, Oracle Cloud and more.<\/p>\n\n\n\n<p>Let&#8217;s take a quick example how this works.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from diagrams import Diagram\nfrom diagrams.aws.compute import EC2\nfrom diagrams.aws.database import RDS\nfrom diagrams.aws.network import ELB\n\nwith Diagram(\"Grouped Workers\", show=False, direction=\"TB\"):\n    ELB(\"lb\") &gt;&gt; &#091;EC2(\"worker1\"),\n                  EC2(\"worker2\"),\n                  EC2(\"worker3\"),\n                  EC2(\"worker4\"),\n                  EC2(\"worker5\")] &gt;&gt; RDS(\"events\")<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>This will result as below.<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" src=\"https:\/\/diagrams.mingrammer.com\/img\/grouped_workers_diagram.png\" alt=\"grouped workers diagram\" width=\"840\" height=\"483\" \/><figcaption>Credit : diagrams.mingrammer.com<\/figcaption><\/figure>\n\n\n\n<p>You can see we can build amazing architecture design just by using some python code. Please check more detail at their <a href=\"https:\/\/github.com\/mingrammer\/diagrams\" data-type=\"URL\" data-id=\"https:\/\/github.com\/mingrammer\/diagrams\">Github<\/a> and quick examples <a href=\"https:\/\/diagrams.mingrammer.com\/docs\/getting-started\/examples\" data-type=\"URL\" data-id=\"https:\/\/diagrams.mingrammer.com\/docs\/getting-started\/examples\">here<\/a>.<\/p>\n\n\n\n<p>Yuuma<\/p>\n<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"none\" href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/12354\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/https:\/\/www.gigas-jp.com\/appnews\/archives\/12354\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"Diagram as Code\" data-hatena-bookmark-layout=\"standard\" title=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\"> <img src=\"\/\/b.hatena.ne.jp\/images\/entry-button\/button-only@2x.png\" alt=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\" width=\"20\" height=\"20\" style=\"border: none;\" \/><\/a><script type=\"text\/javascript\" src=\"\/\/b.hatena.ne.jp\/js\/bookmark_button.js\" charset=\"utf-8\" async=\"async\"><\/script><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/12354\" data-text=\"Diagram as Code\" data-via=\"GIGASJAPAN_APPS\" data-lang=\"ja\">Tweet<\/a><\/div>\n            <div class=\"wsbl_facebook_like\"><div id=\"fb-root\"><\/div><fb:like href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/12354\" layout=\"button_count\" action=\"like\" width=\"100\" share=\"false\" show_faces=\"false\" ><\/fb:like><\/div>\n            <div class=\"wsbl_facebook_send\"><div id=\"fb-root\"><\/div><fb:send href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/12354\" colorscheme=\"light\" ><\/fb:send><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>Diagrams allow you to draw cloud system architectures in Python code. It was created to prototype a new system [&hellip;]<\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[100],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/12354"}],"collection":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/comments?post=12354"}],"version-history":[{"count":2,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/12354\/revisions"}],"predecessor-version":[{"id":12357,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/12354\/revisions\/12357"}],"wp:attachment":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/media?parent=12354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/categories?post=12354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/tags?post=12354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}