Example 3

This time we will extend the edges size using the Graphviz minlen attribute.

The diagram below illustrates a 3-tier web application architecture. Each tier—Web, Application, and Database—is depicted as a color-coded rectangle for easy identification. Labeled connections show the communication protocols: the Web server connects to the Application server using gRPC, while the Application server communicates with the Database server via SQL.

The minlen attribute has been applied to the edges to enhance the spacing between the nodes, resulting in a clearer and more organized layout.

PowerShell: param block
[CmdletBinding()]
param (
    [System.IO.FileInfo] $Path = '~\Desktop\',
    [array] $Format = @('png'),
    [bool] $DraftMode = $false
)

Starting with PowerShell v3, modules are auto-imported when needed. Importing the module here ensures clarity and avoids ambiguity.

PowerShell
Import-Module Diagrammer.Core -Force -Verbose:$false

Since the diagram output is a file, specify the output folder path using $OutputFolderPath.

PowerShell
$OutputFolderPath = Resolve-Path $Path

The $MainGraphLabel variable sets the main title of the diagram.

PowerShell
$MainGraphLabel = '3tier Web Application Diagram'

This section creates connections between the nodes in a herarchical layout. The Edge statements create connections between the nodes.

The minlen attribute is used to increase the minimum length of the edge lines.

https://graphviz.org/docs/attrs/minlen/

Example3.ps1 - Edge minlen attribute
$example3 = & {
    Node -Name Web01 -Attributes @{Label = 'Web01'; shape = 'rectangle'; fillColor = 'Green'; fontsize = 14 }
    Node -Name App01 -Attributes @{Label = 'App01'; shape = 'rectangle'; fillColor = 'Blue'; fontsize = 14 }
    Node -Name DB01 -Attributes @{Label = 'DB01'; shape = 'rectangle'; fillColor = 'Red'; fontsize = 14 }

    # This section creates connections between the nodes in a hierarchical layout.

    Edge -From Web01 -To App01 @{label = 'gRPC'; color = 'black'; fontsize = 12; fontcolor = 'black'; minlen = 3 }
    Edge -From App01 -To DB01 @{label = 'SQL'; color = 'black'; fontsize = 12; fontcolor = 'black'; minlen = 3 }
}
Finally, call the New-Diagrammer cmdlet with the specified parameters.

PowerShell
New-Diagrammer -InputObject $example3 -OutputFolderPath $OutputFolderPath -Format $Format -MainDiagramLabel $MainGraphLabel -Filename Example3 -LogoName "Main_Logo"  -DraftMode:$DraftMode

When you run the script, it generates a PNG file named Example3.png in the specified output folder.

Resulting diagram:

Example

Comments