MCPcopy
hub / github.com/blushft/go-diagrams

github.com/blushft/go-diagrams @main sqlite

repository ↗ · DeepWiki ↗
2,569 symbols 8,898 edges 1,315 files 5 documented · 0%
README

Go-Diagrams

Fast and easy application diagrams

Go-Diagrams is a loose port of diagrams.

Contents

Features

Turn this:

d, err := diagram.New(diagram.Filename("app"), diagram.Label("App"), diagram.Direction("LR"))
if err != nil {
    log.Fatal(err)
}

dns := gcp.Network.Dns(diagram.NodeLabel("DNS"))
lb := gcp.Network.LoadBalancing(diagram.NodeLabel("NLB"))
cache := gcp.Database.Memorystore(diagram.NodeLabel("Cache"))
db := gcp.Database.Sql(diagram.NodeLabel("Database"))

dc := diagram.NewGroup("GCP")
dc.NewGroup("services").
    Label("Service Layer").
    Add(
        gcp.Compute.ComputeEngine(diagram.NodeLabel("Server 1")),
        gcp.Compute.ComputeEngine(diagram.NodeLabel("Server 2")),
        gcp.Compute.ComputeEngine(diagram.NodeLabel("Server 3")),
    ).
    ConnectAllFrom(lb.ID(), diagram.Forward()).
    ConnectAllTo(cache.ID(), diagram.Forward())

dc.NewGroup("data").Label("Data Layer").Add(cache, db).Connect(cache, db)

d.Connect(dns, lb, diagram.Forward()).Group(dc)

if err := d.Render(); err != nil {
    log.Fatal(err)
}

Into this:

app-diagram

Usage

go get github.com/blushft/go-diagrams

Create a diagram:

d, err := diagram.New(diagram.Label("my-diagram"), diagram.Filename("diagram"))
if err != nil {
    log.Fatal(err)
}

fw := generic.Network.Firewall().Label("fw")
sw := generic.Network.Switch().Label("sw")

d.Connect(fw, sw)

Render the output:

if err := d.Render(); err != nil {
    log.Fatal(err)
}

Go-Diagrams will create a folder in the current working directory with the graphviz DOT file and any image assets.

Create an ouput image with any graphviz compatible renderer:

dot -Tpng diagram.dot > diagram.png

Extension points exported contracts — how you extend this code

Connector (Interface)
(no doc) [2 implementers]
diagram/diagram.go
NodeOption (FuncType)
(no doc)
diagram/node.go
Option (FuncType)
(no doc)
diagram/options.go
GroupOption (FuncType)
(no doc)
diagram/group.go
EdgeOption (FuncType)
(no doc)
diagram/edge.go
Attribute (FuncType)
(no doc)
attr/attr.go

Core symbols most depended-on inside this repo

Close
called by 2278
diagram/diagram.go
NewNode
called by 1138
diagram/node.go
MergeOptionSets
called by 1138
diagram/node.go
Icon
called by 1138
diagram/node.go
Provider
called by 159
diagram/node.go
NodeShape
called by 159
diagram/node.go
Label
called by 15
diagram/node.go
NodeLabel
called by 13
diagram/node.go

Shape

Function 1,207
Method 1,182
Struct 171
FuncType 5
TypeAlias 3
Interface 1

Languages

Go100%

Modules by API surface

nodes/aws/compute.go43 symbols
nodes/aws/iot.go30 symbols
nodes/azure/network.go27 symbols
nodes/azure/general.go27 symbols
nodes/aws/security.go25 symbols
diagram/node.go25 symbols
diagram/group.go25 symbols
nodes/aws/network.go24 symbols
nodes/aws/analytics.go24 symbols
nodes/aws/ml.go23 symbols
nodes/gcp/ml.go22 symbols
nodes/azure/compute.go21 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

github.com/UnnoTed/fileb0xv1.1.4 · 1×
github.com/awalterschulze/gographvizv0.0.0-2020090112412 · 1×
github.com/dave/jenniferv1.4.1 · 1×
github.com/davecgh/go-spewv1.1.1 · 1×
github.com/iancoleman/strcasev0.1.1 · 1×
golang.org/x/expv0.0.0-2020090818373 · 1×
golang.org/x/netv0.0.0-2019062020020 · 1×

For agents

$ claude mcp add go-diagrams \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact