September 15, 2021

How to use Diagrams to create architectural diagrams

advanced_diagram

my_diagram.jpg

In this post, we are going to see the real time implementation of Diagrams to create some of the sample architectural diagrams.

Diagram 1: Basic Diagram

As the initial step, we will start with the basic diagram, where we will generate (code) an image file with single EC2 node with the image name as simple_diagram.png (default output format is png)

The file will be located in the current working directory.

The files and artifacts are present in this Github Repo.

Step 1 : Write the code

Kindly create a file with using any of the file editor (say vi, nano gedit, etc.,) and enter the below contents and save the file with a name (In our case, its 1_basic_diagram.py)

Step 2 : Execute the file

Kindly execute the file with the below mentioned commands to generate and list the diagram.

Step 3 : View the file using an image viewer

Kindly execute the below command to view the generated image from the terminal.

simple_diagram.png
simple_diagram.png

Diagram 2 : Advanced Diagram

In this step, we will go with the advanced diagram which includes some more AWS services, where we will generate (code) an image file with the image name as my_diagram.jpg.

The file will be located in the current working directory.

the files and artifacts are stored in this GitHub Repo

Step 1 : Write the code

Kindly create a file with using any of the file editor (say vi, nano gedit, etc.,) and enter the below contents and save the file with a name (In our case, its 2_advanced_diagram.py)

Key Take-away from this code:

  • graph_attr – Used to allow custom Graphviz dot attributes options
  • show=False – Used to disable the file opening automatically
  • outformat=”jpg” – Used to mention the output format of the diagram
  • filename=”my_diagram” – Used to mention the custom file name

Step 2 : Execute the file

Kindly execute the file with the below mentioned commands to generate and list the diagram.

Step 3 : View the file using an image viewer

Kindly execute the below command to view the generated image from the terminal.

advanced_diagram
my_diagram.jpg

Diagram 3 : Custom & On-Prem diagram

In this step, we will go with the Custom and On-Prem tools, where we will generate (code) an image file with the image name as custom_diagram.jpg.

The file will be located in the current working directory.

Note: In order to use Custom resources, we need to have the respective icons in a local or remote directory. In our case, the custom resources are present in the directory called my_resources.

The files and artifacts are present in this GitHub Repo.

Step 1 : Write the code

Kindly create a file with using any of the file editor (say vi, nano gedit, etc.,) and enter the below contents and save the file with a name (In our case, its 3_custom_diagram.py)

Key Take-away from this code:

  • direction=”LR” – Used to define the direction of the diagram (in our case, it is Left to Right)
  • with Cluster – Used to create a cluster in a diagram (In our case, we have Public and Private Clusters)
  • Custom(“Android”, “./my_resources/android.png”) – Used to import custom resources in a diagram

Step 2 : Execute the file

Kindly execute the file with the below mentioned commands to generate and list the diagram.

Step 3 : View the file using an image viewer

Kindly execute the below command to view the generated image from the terminal.

custom_diagram.jpg
custom_diagram.jpg

 

1 thought on “How to use Diagrams to create architectural diagrams

  1. This is outstanding, really appreciate the thought process and admire the creativity,
    Kudos for the successfully execution, One word to explain it all is ‘awesamatic’

Leave a Reply

Your email address will not be published. Required fields are marked *