Ballerina digram is generated from the ballerina AST of the relevent program. To extract the necessary information it uses several AST Visitors.
AST is a tree like representation of the program. See following example.
Program:
import ballerina/io;