{"id":6283,"date":"2021-11-12T16:08:46","date_gmt":"2021-11-12T09:08:46","guid":{"rendered":"https:\/\/briswell-vn.com\/?p=6283"},"modified":"2021-11-12T16:11:07","modified_gmt":"2021-11-12T09:11:07","slug":"plantuml","status":"publish","type":"post","link":"https:\/\/www.briswell-vn.com\/en\/news\/plantuml\/","title":{"rendered":"PlantUML to write UML diagram by code"},"content":{"rendered":"<p><\/p>\n<h2>About PlantUML<\/h2>\n<p>There are many situations to explain requirements, configurations, and functions using UML diagrams in the software developments regardless of Waterfall or Agile model.<br \/>\nBut the diagram documents are not created by text editors, by drawing applications so it is difficult to understand the gap in every version.<br \/>\nPlantUML helps us to create them by coding so it is easy to understand the differences by text. That is easy to manage versions.<\/p>\n<h2>Create Local Environment<\/h2>\n<h3>Start PlantUML in local host<\/h3>\n<p>Explain the easy installation using Docker.<\/p>\n<ol>\n<li>Install Docker and start it.\uff08Check <a href=\"https:\/\/briswell-vn.com\/en\/news\/launch-with-docker\/\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a> to install Docker.\uff09<\/li>\n<li>Execute this command &#8220;docker run -d -p 8080:8080 plantuml\/plantuml-server:jetty&#8221; and start the Docker container of PlantUML.<\/li>\n<li>Access to &#8220;http:\/\/localhost:8080\/&#8221; in your browser. It success when it is shown like below&#8217;s screen.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-6291\" src=\"https:\/\/briswell-vn.com\/wp-content\/uploads\/2021\/11\/image-20211029173703751-300x123.png\" alt=\"\" width=\"300\" height=\"123\" srcset=\"https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2021\/11\/02172640\/image-20211029173703751-300x123.png 300w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2021\/11\/02172640\/image-20211029173703751-1024x418.png 1024w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2021\/11\/02172640\/image-20211029173703751-768x314.png 768w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2021\/11\/02172640\/image-20211029173703751.png 1342w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/li>\n<\/ol>\n<h3>Setting VScode<\/h3>\n<ol>\n<li>Click Extension and\u3001Install &#8220;PlantUML&#8221; plug-in.<\/li>\n<li>Open Extension setting of it and set it as below&#8217;s.\n<ul>\n<li>Plantuml: Render =&gt; PlantUMLServer<\/li>\n<li>Plantuml: Server =&gt; http:\/\/localhost:8080<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h2>How to use<\/h2>\n<h3>Show preview while editting<\/h3>\n<ol>\n<li>Create an UML file, *****.uml, and copy below&#8217;s code and paste to the file.<br \/>\n<code>@startuml<br \/>\nstart<br \/>\nrepeat<br \/>\n:Test something;<br \/>\nif (Something went wrong?) then (no)<br \/>\n#palegreen:OK;<br \/>\nbreak<br \/>\nendif<br \/>\n-&gt;NOK;<br \/>\n:Alert \"Error with long text\";<br \/>\nrepeat while (Something went wrong with long text?) is (yes) not (no)<br \/>\n-&gt;\/\/merged step\/\/;<br \/>\n:Alert \"Success\";<br \/>\nstop<br \/>\n@enduml<\/code><\/li>\n<li>Choose &#8220;PlantUML:Preview Current Diagram&#8221; on the command pannel.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-6296\" src=\"https:\/\/briswell-vn.com\/wp-content\/uploads\/2021\/11\/image-20211029165031071-300x101.png\" alt=\"\" width=\"368\" height=\"124\" srcset=\"https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2021\/11\/02174035\/image-20211029165031071-300x101.png 300w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2021\/11\/02174035\/image-20211029165031071-1024x345.png 1024w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2021\/11\/02174035\/image-20211029165031071-768x259.png 768w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2021\/11\/02174035\/image-20211029165031071-1536x518.png 1536w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2021\/11\/02174035\/image-20211029165031071.png 1668w\" sizes=\"auto, (max-width: 368px) 100vw, 368px\" \/><\/li>\n<li>Show the preview window<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-6297\" src=\"https:\/\/briswell-vn.com\/wp-content\/uploads\/2021\/11\/image-20211029171040393-300x293.png\" alt=\"\" width=\"371\" height=\"362\" srcset=\"https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2021\/11\/02174105\/image-20211029171040393-300x293.png 300w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2021\/11\/02174105\/image-20211029171040393-1024x999.png 1024w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2021\/11\/02174105\/image-20211029171040393-768x749.png 768w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2021\/11\/02174105\/image-20211029171040393-1536x1499.png 1536w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2021\/11\/02174105\/image-20211029171040393-256x250.png 256w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2021\/11\/02174105\/image-20211029171040393.png 1564w\" sizes=\"auto, (max-width: 371px) 100vw, 371px\" \/><\/li>\n<\/ol>\n<h3>Output diagram<\/h3>\n<ol>\n<li>Choose &#8220;PlantUML: Export Current File Diagrams&#8221; on the command panel.<\/li>\n<li>Choose png.<\/li>\n<li>Created &#8220;out&#8221; folder and created the image file under this folder.<\/li>\n<\/ol>\n<p>It is possible for us to create the Sequence diagram, the Use-case diagrams, the Class diagram, and etc besides the Activity diagram and the site has samples to create them so check up this site.<\/p>\n<h2>Create system configuration diagram using AWS services<\/h2>\n<p>Give us the icons of AWS for PlantUML on GitHub.<\/p>\n<p>Previously, <a href=\"https:\/\/github.com\/milo-minderbinder\/AWS-PlantUML\" target=\"_blank\" rel=\"noopener noreferrer\">AWS-PlantUML<\/a> was often used to. But recently it is not updated. For this reason I use <a href=\"https:\/\/github.com\/awslabs\/aws-icons-for-plantuml\" target=\"_blank\" rel=\"noopener noreferrer\">aws-icons-for-plantuml<\/a> as alternative.<\/p>\n<p>The diagram using it is below&#8217;s.<\/p>\n<p><code><br \/>\n@startuml aws-sample-system-diagram<\/p>\n<p>!define AWSPuml https:\/\/raw.githubusercontent.com\/awslabs\/aws-icons-for-plantuml\/v11.1\/dist<br \/>\n!includeurl AWSPuml\/AWSCommon.puml<br \/>\n!includeurl AWSPuml\/NetworkingContentDelivery\/ElasticLoadBalancingApplicationLoadBalancer.puml<br \/>\n!includeurl AWSPuml\/GroupIcons\/Region.puml<br \/>\n!includeurl AWSPuml\/NetworkingContentDelivery\/Route53.puml<br \/>\n!includeurl AWSPuml\/Compute\/all.puml<br \/>\n!includeurl AWSPuml\/Storage\/SimpleStorageService.puml<br \/>\n!includeurl AWSPuml\/Database\/AuroraMySQLInstance.puml<br \/>\n!includeurl AWSPuml\/Database\/ElastiCacheElastiCacheforRedis.puml<\/p>\n<p>left to right direction<\/p>\n<p>actor \"Person\" as personAlias<br \/>\nRegion(cloudArea, \"Tokyo\", \"AWS\", \"\"){<br \/>\nRoute53(route53, \"Sample.com\", \"Route53\", \"\")<br \/>\nElasticLoadBalancingApplicationLoadBalancer(elb, \"Production-ALB\", \"ALB\", \"\")<br \/>\nEC2Instance(desktopAlias, \"Production-ec2\", \"EC2\", \"t3.micro \\n amazon linux2\")<br \/>\nSimpleStorageService(storageAlias, \"Production-s3\", \"AmazonS3\", \"Host name \\n public\")<br \/>\nAuroraMySQLInstance(rds,\"Database\",\"RDS Mysql\",\"Host name \\n DB name\")<br \/>\nElastiCacheElastiCacheforRedis(redis,\"Redis\",\"Elastic Cache\",\"Host name\")<br \/>\n}<\/p>\n<p>personAlias --&gt; route53<br \/>\nroute53 --&gt; elb<br \/>\nelb --&gt; desktopAlias<br \/>\nelb --&gt; storageAlias<br \/>\ndesktopAlias --&gt; storageAlias<br \/>\ndesktopAlias --&gt; redis<br \/>\nrds &lt;--&gt; desktopAlias<br \/>\n@enduml<\/p>\n<p><\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-6301\" src=\"https:\/\/briswell-vn.com\/wp-content\/uploads\/2021\/11\/aws-sample-system-diagram-300x150.png\" alt=\"\" width=\"624\" height=\"312\" srcset=\"https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2021\/11\/02174825\/aws-sample-system-diagram-300x150.png 300w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2021\/11\/02174825\/aws-sample-system-diagram-1024x511.png 1024w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2021\/11\/02174825\/aws-sample-system-diagram-768x383.png 768w, https:\/\/s3-ap-southeast-1.amazonaws.com\/homepage-media\/wp-content\/uploads\/2021\/11\/02174825\/aws-sample-system-diagram.png 1155w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/p>\n<p>The icons you want to use besides are written <a href=\"https:\/\/github.com\/awslabs\/aws-icons-for-plantuml\/blob\/main\/AWSSymbols.md\">AWSSymbols.md<\/a> under the top folder.<\/p>\n<h2>Impression<\/h2>\n<p>Creating them by VScode causes no need to buy software licenses to create the diagrams and it is easy to work with others. And it is easy to manage the version also.<\/p>\n<p>We can not adjust the position of diagrams. The setting of the position is only drawn from top to down or from left to right.<br \/>\nFor that reason, it is better to avoid using it if the people who are got explanations can not be accepted.<\/p>\n<p>But for me, It is possible to focus to create the diagrams efficiently by not mind adust the position in detail and writing only important things. I think.<\/p>\n<h2>Note<\/h2>\n<p>If you don&#8217;t want to create the local environment, try to use <a href=\"http:\/\/www.plantuml.com\/plantuml\/uml\/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000\" target=\"_blank\" rel=\"noopener noreferrer\">demo<\/a> of PlantUML site.<\/p>\n<p>And then you can use Preview of VScode without Docker when you set the URL of PlantUML to &#8220;Plantuml: Render&#8221;. But It is better to use it considering the documents that you create are confidential or not.<\/p>\n<h2>Refer to<\/h2>\n<p><a href=\"https:\/\/plantuml.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">PlantUML<\/a><br \/>\n<a href=\"https:\/\/note.com\/keyskey1021\/n\/n12cb62301f68\" target=\"_blank\" rel=\"noopener noreferrer\">Visual Studio Code\u3067\u30d7\u30ec\u30d3\u30e5\u30fc\u3092\u898b\u306a\u304c\u3089PlantUML\u3092\u66f8\u3051\u308b\u74b0\u5883\u3092Docker\u3067\u4f5c\u308b<\/a><br \/>\n<a href=\"https:\/\/github.com\/awslabs\/aws-icons-for-plantuml\" target=\"_blank\" rel=\"noopener noreferrer\">aws-icons-for-plantuml<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>About PlantUML There are many situations to explain requirements, configurations, and functions using UML diagrams in the software developments regardless of Waterfall or Agile model. But the diagram documents are not created by text editors, by drawing applications so it is difficult to understand the gap in every version. PlantUML helps us to create them by coding so it is easy to understand the differences [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":6316,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[4,9,71],"tags":[],"class_list":["post-6283","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news","category-general","category-it-tec"],"_links":{"self":[{"href":"https:\/\/www.briswell-vn.com\/en\/wp-json\/wp\/v2\/posts\/6283","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.briswell-vn.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.briswell-vn.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.briswell-vn.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.briswell-vn.com\/en\/wp-json\/wp\/v2\/comments?post=6283"}],"version-history":[{"count":0,"href":"https:\/\/www.briswell-vn.com\/en\/wp-json\/wp\/v2\/posts\/6283\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.briswell-vn.com\/en\/wp-json\/wp\/v2\/media\/6316"}],"wp:attachment":[{"href":"https:\/\/www.briswell-vn.com\/en\/wp-json\/wp\/v2\/media?parent=6283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.briswell-vn.com\/en\/wp-json\/wp\/v2\/categories?post=6283"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.briswell-vn.com\/en\/wp-json\/wp\/v2\/tags?post=6283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}