{"id":79,"date":"2024-09-15T14:16:52","date_gmt":"2024-09-15T14:16:52","guid":{"rendered":"https:\/\/plantuml.cn\/index.php\/2024\/09\/15\/the-ultimate-plantuml-cheat-sheet-a-comprehensive-guide\/"},"modified":"2024-09-15T14:16:52","modified_gmt":"2024-09-15T14:16:52","slug":"the-ultimate-plantuml-cheat-sheet-a-comprehensive-guide","status":"publish","type":"post","link":"https:\/\/plantuml.cn\/index.php\/2024\/09\/15\/the-ultimate-plantuml-cheat-sheet-a-comprehensive-guide\/","title":{"rendered":"The Ultimate PlantUML Cheat Sheet: A Comprehensive Guide"},"content":{"rendered":"<h1>The Ultimate PlantUML Cheat Sheet: A Comprehensive Guide<\/h1>\n<p><strong>SEO Meta Description:<\/strong> Master the art of PlantUML with our comprehensive cheat sheet. Learn how to create stunning diagrams, use libraries, and more. Boost your productivity today!<\/p>\n<h2>Introduction<\/h2>\n<p>PlantUML is a powerful tool that allows you to create diagrams quickly using a simple textual description. Whether you&rsquo;re a developer, architect, or just someone who loves visualizing ideas, PlantUML can be a game-changer. This cheat sheet will guide you through the essentials, from basic syntax to advanced libraries, ensuring you can create professional-grade diagrams with ease.<\/p>\n<h2>What is PlantUML?<\/h2>\n<p>PlantUML is an open-source tool that uses a simple language to generate UML diagrams. It supports a wide range of diagram types, including sequence, class, activity, and more. The beauty of PlantUML lies in its simplicity; you don&rsquo;t need to be a graphic designer to create complex diagrams.<\/p>\n<h3>Basic Syntax<\/h3>\n<p>The basic syntax of PlantUML is straightforward. Here\u2019s a quick example of a sequence diagram:<\/p>\n<pre><code class=\"language-plantuml\">@startuml\nAlice -&gt; Bob: Authentication Request\nBob --&gt; Alice: Authentication Response\n\nAlice -&gt; Bob: Another authentication request\nAlice &lt;-- Bob: Another authentication response\n@enduml\n<\/code><\/pre>\n<p>This code will generate a sequence diagram showing the interaction between Alice and Bob. The <code>@startuml<\/code> and <code>@enduml<\/code> tags indicate the beginning and end of the diagram, respectively.<\/p>\n<h3>Common Elements<\/h3>\n<p>PlantUML supports various elements that you can use to build your diagrams. Here are some common ones:<\/p>\n<ul>\n<li><strong>Actors<\/strong>: Represented by <code>actor<\/code> keyword.<\/li>\n<li><strong>Participants<\/strong>: Represented by <code>participant<\/code> keyword.<\/li>\n<li><strong>Messages<\/strong>: Represented by arrows (<code>-&gt;<\/code>, <code>--&gt;<\/code>, <code>&lt;--<\/code>, etc.).<\/li>\n<\/ul>\n<h3>Advanced Features<\/h3>\n<p>PlantUML also offers advanced features like skin parameters, notes, and more. For instance, you can add notes to your diagrams to provide additional context:<\/p>\n<pre><code class=\"language-plantuml\">@startuml\nactor User\nUser -&gt; Application: Request Data\nnote right: User initiates a request\nApplication --&gt; User: Data Response\n@enduml\n<\/code><\/pre>\n<h2>PlantUML Cheat Sheet<\/h2>\n<h3>Libraries and Standard Includes<\/h3>\n<p>PlantUML supports a variety of libraries that can be included in your diagrams. These libraries provide pre-defined sprites and macros, making it easier to create complex diagrams.<\/p>\n<h4>C4 Library<\/h4>\n<p>The C4 library is a popular choice for creating architecture diagrams. It follows the C4 model, which organizes the architecture into Context, Containers, Components, and Code.<\/p>\n<pre><code class=\"language-plantuml\">@startuml\n!include &lt;C4\/C4_Container&gt;\nPerson(personAlias, &quot;Label&quot;, &quot;Optional Description&quot;)\nContainer(containerAlias, &quot;Label&quot;, &quot;Technology&quot;, &quot;Optional Description&quot;)\nSystem(systemAlias, &quot;Label&quot;, &quot;Optional Description&quot;)\nSystem_Ext(extSystemAlias, &quot;Label&quot;, &quot;Optional Description&quot;)\nRel(personAlias, containerAlias, &quot;Label&quot;, &quot;Optional Technology&quot;)\nRel_U(systemAlias, extSystemAlias, &quot;Label&quot;, &quot;Optional Technology&quot;)\n@enduml\n<\/code><\/pre>\n<h4>Cloud Insight Library<\/h4>\n<p>The Cloud Insight library provides sprites for various technologies, making it easy to represent them in your diagrams.<\/p>\n<pre><code class=\"language-plantuml\">@startuml\n!include &lt;cloudinsight\/tomcat&gt;\n!include &lt;cloudinsight\/kafka&gt;\n!include &lt;cloudinsight\/java&gt;\n!include &lt;cloudinsight\/cassandra&gt;\ntitle Cloudinsight sprites example\nskinparam monochrome true\nrectangle &quot;&lt;$tomcat&gt;\\nwebapp&quot; as webapp\n@enduml\n<\/code><\/pre>\n<h3>Links and URLs<\/h3>\n<p>You can include links in your PlantUML diagrams using square brackets. This is useful for referencing external resources or documentation.<\/p>\n<pre><code class=\"language-plantuml\">@startuml\n[http:\/\/plantuml.com]\n[http:\/\/plantuml.com This label is printed]\n[http:\/\/plantuml.com{Optional tooltip} This label is printed]\n@enduml\n<\/code><\/pre>\n<h3>Code Blocks<\/h3>\n<p>PlantUML allows you to include code blocks within your diagrams. This is particularly useful for illustrating algorithms or snippets of code.<\/p>\n<pre><code class=\"language-plantuml\">@startuml\nAlice -&gt; Bob : hello\nnote right\n&lt;code&gt;\nmain() {\nprintf(&quot;Hello world&quot;);\n}\n&lt;\/code&gt;\nend note\n@enduml\n<\/code><\/pre>\n<h3>Elastic Library<\/h3>\n<p>The Elastic library provides icons for Elasticsearch, Logstash, and Kibana. It\u2019s similar to the AWS and Azure libraries and uses the same tool to create them.<\/p>\n<pre><code class=\"language-plantuml\">@startuml\n!include &lt;elastic\/common&gt;\n!include &lt;elastic\/elasticsearch\/elasticsearch&gt;\n!include &lt;elastic\/logstash\/logstash&gt;\n!include &lt;elastic\/kibana\/kibana&gt;\nELASTICSEARCH(ElasticSearch, &quot;Search and Analyze&quot;,database)\nLOGSTASH(Logstash, &quot;Parse and Transform&quot;,node)\nKIBANA(Kibana, &quot;Visualize&quot;,agent)\nLogstash -right-&gt; ElasticSearch: Transformed Data\n@enduml\n<\/code><\/pre>\n<h3>Amazon Labs AWS Library<\/h3>\n<p>The Amazon Labs AWS library provides PlantUML sprites and macros for AWS services. It\u2019s a great way to visualize your AWS architecture.<\/p>\n<pre><code class=\"language-plantuml\">@startuml\n!include &lt;awslib\/AWSCommon&gt;\n!include &lt;awslib\/InternetOfThings\/IoTRule&gt;\n!include &lt;awslib\/Analytics\/KinesisDataStreams&gt;\n!include &lt;awslib\/ApplicationIntegration\/SimpleQueueService&gt;\nleft to right direction\nagent &quot;Published Event&quot; as event #fff\nIoTRule(iotRule, &quot;Action Error Rule&quot;, &quot;error if Kinesis fails&quot;)\nKinesisDataStreams(eventStream, &quot;IoT Events&quot;, &quot;2 shards&quot;)\nSimpleQueueService(errorQueue, &quot;Rule Error Queue&quot;, &quot;failed Rule actions&quot;)\nevent --&gt; iotRule : JSON message\niotRule --&gt; eventStream : messages\niotRule --&gt; errorQueue : Failed action message\n@enduml\n<\/code><\/pre>\n<h2>Frequently Asked Questions<\/h2>\n<h3>What is PlantUML used for?<\/h3>\n<p>PlantUML is used for creating various types of UML diagrams, including sequence, class, activity, and more. It\u2019s particularly useful for developers and architects who need to visualize complex systems.<\/p>\n<h3>How do I include libraries in my PlantUML diagrams?<\/h3>\n<p>You can include libraries using the <code>!include<\/code> directive. For example, to include the C4 library, you would use <code>!include &lt;C4\/C4_Container&gt;<\/code>.<\/p>\n<h3>Can I add links to my PlantUML diagrams?<\/h3>\n<p>Yes, you can add links using square brackets. For example, <code>[http:\/\/plantuml.com]<\/code>.<\/p>\n<h3>How do I add code blocks to my diagrams?<\/h3>\n<p>You can add code blocks using the <code>&lt;code&gt;<\/code> tag. For example:<\/p>\n<pre><code class=\"language-plantuml\">note right\n&lt;code&gt;\nmain() {\nprintf(&quot;Hello world&quot;);\n}\n&lt;\/code&gt;\nend note\n<\/code><\/pre>\n<h3>What is the Elastic library in PlantUML?<\/h3>\n<p>The Elastic library provides icons for Elasticsearch, Logstash, and Kibana. It\u2019s similar to the AWS and Azure libraries and uses the same tool to create them.<\/p>\n<h2>Conclusion<\/h2>\n<p>PlantUML is a versatile and powerful tool that can significantly enhance your ability to visualize and communicate complex systems. With this cheat sheet, you now have a comprehensive guide to creating stunning diagrams, using libraries, and more. Whether you&rsquo;re a seasoned developer or just starting out, PlantUML can help you bring your ideas to life. Happy diagramming!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Ultimate PlantUML Cheat Sheet: A Comprehensive Guid &hellip; <a href=\"https:\/\/plantuml.cn\/index.php\/2024\/09\/15\/the-ultimate-plantuml-cheat-sheet-a-comprehensive-guide\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cThe Ultimate PlantUML Cheat Sheet: A Comprehensive Guide\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-79","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/plantuml.cn\/index.php\/wp-json\/wp\/v2\/posts\/79"}],"collection":[{"href":"https:\/\/plantuml.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/plantuml.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/plantuml.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/plantuml.cn\/index.php\/wp-json\/wp\/v2\/comments?post=79"}],"version-history":[{"count":0,"href":"https:\/\/plantuml.cn\/index.php\/wp-json\/wp\/v2\/posts\/79\/revisions"}],"wp:attachment":[{"href":"https:\/\/plantuml.cn\/index.php\/wp-json\/wp\/v2\/media?parent=79"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/plantuml.cn\/index.php\/wp-json\/wp\/v2\/categories?post=79"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/plantuml.cn\/index.php\/wp-json\/wp\/v2\/tags?post=79"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}