main() — graph2md Function Reference
Architecture documentation for the main() function in main.go from the graph2md codebase.
Entity Profile
Dependency Diagram
graph TD 5ab9a7d2_746e_d880_5dc3_4ed8134ed871["main()"] 80fa005d_7e3e_f056_f8f8_f520be5cd3e1["main.go"] 5ab9a7d2_746e_d880_5dc3_4ed8134ed871 -->|defined in| 80fa005d_7e3e_f056_f8f8_f520be5cd3e1 a9dbae93_6283_7fbc_c0f0_8ea1ae06de62["loadGraph()"] 5ab9a7d2_746e_d880_5dc3_4ed8134ed871 -->|calls| a9dbae93_6283_7fbc_c0f0_8ea1ae06de62 4ac5d4d0_ee5a_6e77_e319_2b4ae2365a67["getStr()"] 5ab9a7d2_746e_d880_5dc3_4ed8134ed871 -->|calls| 4ac5d4d0_ee5a_6e77_e319_2b4ae2365a67 ca0c6a02_8026_15c3_7b03_14d806cba321["hasLabel()"] 5ab9a7d2_746e_d880_5dc3_4ed8134ed871 -->|calls| ca0c6a02_8026_15c3_7b03_14d806cba321 234fe91b_fb9f_ff66_8620_ad8caf50d9b1["generateSlug()"] 5ab9a7d2_746e_d880_5dc3_4ed8134ed871 -->|calls| 234fe91b_fb9f_ff66_8620_ad8caf50d9b1 style 5ab9a7d2_746e_d880_5dc3_4ed8134ed871 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
main.go lines 92–442
func main() {
inputFiles := flag.String("input", "", "Comma-separated paths to graph JSON file(s)")
outputDir := flag.String("output", "data", "Output directory for markdown files")
repoName := flag.String("repo", "supermodel-public-api", "Repository name")
repoURL := flag.String("repo-url", "https://github.com/supermodeltools/supermodel-public-api", "Repository URL")
flag.Parse()
if *inputFiles == "" {
log.Fatal("--input is required (comma-separated paths to graph JSON files)")
}
if err := os.MkdirAll(*outputDir, 0755); err != nil {
log.Fatalf("creating output dir: %v", err)
}
// Load and merge all graphs
var allNodes []Node
var allRels []Relationship
nodeMap := make(map[string]bool)
for _, path := range strings.Split(*inputFiles, ",") {
path = strings.TrimSpace(path)
if path == "" {
continue
}
log.Printf("Loading graph from %s...", path)
nodes, rels, err := loadGraph(path)
if err != nil {
log.Printf("Warning: failed to load %s: %v", path, err)
continue
}
for _, n := range nodes {
if !nodeMap[n.ID] {
nodeMap[n.ID] = true
allNodes = append(allNodes, n)
}
}
allRels = append(allRels, rels...)
log.Printf(" Loaded %d nodes, %d relationships", len(nodes), len(rels))
}
log.Printf("Total: %d unique nodes, %d relationships", len(allNodes), len(allRels))
// Build node lookup: id -> node
nodeLookup := make(map[string]*Node)
for i := range allNodes {
nodeLookup[allNodes[i].ID] = &allNodes[i]
}
// Build relationship indices
imports := make(map[string][]string)
importedBy := make(map[string][]string)
callsRel := make(map[string][]string)
calledByRel := make(map[string][]string)
containsFile := make(map[string][]string) // directory -> files
definesFunc := make(map[string][]string) // file -> functions
declaresClass := make(map[string][]string) // file -> classes
definesType := make(map[string][]string) // file -> types
childDir := make(map[string][]string) // directory -> subdirectories
belongsToDomain := make(map[string]string) // node -> domain name
belongsToSubdomain := make(map[string]string) // node -> subdomain name
partOfDomain := make(map[string]string) // subdomain node ID -> domain name
extendsRel := make(map[string][]string) // class -> parent classes
// Reverse lookups for "Defined In"
fileOfFunc := make(map[string]string) // function nodeID -> file nodeID
fileOfClass := make(map[string]string) // class nodeID -> file nodeID
fileOfType := make(map[string]string) // type nodeID -> file nodeID
// Domain/subdomain node lookups by name
domainNodeByName := make(map[string]string) // domain name -> domain node ID
subdomainNodeByName := make(map[string]string) // subdomain name -> subdomain node ID
// Domain -> subdomain mappings
domainSubdomains := make(map[string][]string) // domain name -> subdomain node IDs
// Subdomain -> functions/classes
subdomainFuncs := make(map[string][]string) // subdomain name -> function node IDs
subdomainClasses := make(map[string][]string) // subdomain name -> class node IDs
for _, rel := range allRels {
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does main() do?
main() is a function in the graph2md codebase, defined in main.go.
Where is main() defined?
main() is defined in main.go at line 92.
What does main() call?
main() calls 4 function(s): generateSlug, getStr, hasLabel, loadGraph.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free