Example 2
This time we will connect the nodes to show relationships.
The diagram below visualizes a 3-tier web application architecture. Each tier—Web, Application, and Database—is represented by a distinct color-coded rectangle for clarity. Connections between the tiers are labeled to indicate the communication protocols: the Web server communicates with the Application server via gRPC, and the Application server interacts with the Database server using SQL.
The Edge statements create connections between the nodes, illustrating the flow of data and interactions within the architecture.
[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.
Since the diagram output is a file, specify the output folder path using $OutputFolderPath.
The $MainGraphLabel variable sets the main title of the diagram.
This section creates connections between the nodes in a herarchical layout. The Edge statements create connections between the nodes.
Edge is a reserved word in PSGraph module:
https://psgraph.readthedocs.io/en/latest/Command-Edge/
New-Diagrammer -InputObject $example2 -OutputFolderPath $OutputFolderPath -Format $Format -MainDiagramLabel $MainGraphLabel -Filename Example2 -LogoName "Main_Logo" -DraftMode:$DraftMode
When you run the script, it generates a PNG file named Example2.png in the specified output folder.
Resulting diagram: