We learned PlantUML at beginning of the semester and even did an entire homework creating UML diagrams of a project. But the reason I am writing about UML diagrams right now is because as I was going through previous activities I realized, not only can UML diagrams be used for code built on OOP but also to create a simple and easy to read diagram of an microservices architecture.

As we all know we are going to be using microservices architecture to build Libre Food Pantry so I decided to look for a resource that can make using PlantUML simpler and easier to use and understand. I found a great blog by solutions architect Alex Sarafian. Below are the few features that I found very useful:
- We can color code arrows for multiple flows flow of the diagram and add legend to specify what color represents which flow.
Format example: A -> B #Blue : text
legend
| Color | Flow |
|<#Red>| Flow 1 |
|<#Blue>| Flow 2 |
endlegend

We can color code arrows inside PlaceOrderService and ApproveOrderService for easier understanding of the services.
- Autonumber feature will automatically add a number alongside the text of every event. Autonumber gives a linear sequence of events that are going to take place. For example, 1st UI placing the order to API, then 2nd from API to Database and so on.
Format example 1: numbers in front of event text
autonumber
Bob -> Alice : Authentication Request
Bob <- Alice : Authentication Response

Format example 2: Numbers are 2-digit padded and highlighted
autonumber “<B>[00]”
Bob -> Alice : Authentication Request
Bob <- Alice : Authentication Response

- PlantUML limits the image width and height to 4096. Therefore, when image file is created over the limit of 4096, diagrams are cutoff completely taking away the advantage of efficient flow UML diagram. To fix this we can use command line parameters to increase the width and height limit of image. Another way is to use ‘skinparam dpi X’ parameter. However, the downside to using skinparam is that we must find the value for ‘X’ by experimenting to see when UML diagram fits the best.
- We can display text relevant to an event below the arrow for a cleaner UML diagram. We a skin parameter to achieve this. For example:
skinparam responseMessageBelowArrow true
autonumber “<B>[00]”
Bob -> Alice : Authentication Request
Bob <- Alice : Authentication Response

- PlantUML supports a lot of different colors. A neat trick is to use the ‘colors’ command to render a picture with all colors.
Sources: https://www.codit.eu/blog/plantuml-tips-and-tricks/?country_sel=be
From the blog CS@worcester – Towards Tech by murtazan and used with permission of the author. All other rights reserved by the author.