graph

package
v0.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package graph defines the data model for an archview architecture graph: nodes (endpoints and functions, tagged with their layer/module) and edges (route bindings and call relationships) plus JSON (de)serialization.

Index

Constants

View Source
const (
	KindEndpoint = "endpoint" // an HTTP route entry point
	KindFunc     = "func"     // a Go function/method in a classified layer
	KindPort     = "port"     // an interface that sits as a seam between layers
)

Node kinds.

View Source
const (
	EdgeRoute      = "route"      // endpoint -> handler function
	EdgeCall       = "call"       // function -> function (caller -> callee)
	EdgeImplements = "implements" // concrete method -> port interface (adapter implements port)
	EdgeDispatch   = "dispatch"   // caller -> handler routed through a command/event bus
	EdgeRPC        = "rpc"        // cross-service call over the wire (SystemView stitching)
)

Edge kinds.

View Source
const (
	LayerEndpoint   = "endpoint"
	LayerController = "controller"
	LayerService    = "service"
	LayerPort       = "port"
	LayerRepository = "repository"
	LayerOther      = "other"
)

Layers. "other" is the fallback for funcs that don't match a known layer.

View Source
const (
	ViolationReverse = "reverse"      // calls backward toward the entry (e.g. repository -> service)
	ViolationSkip    = "skip"         // controller -> repository, bypassing the service layer
	ViolationCross   = "cross-module" // calls another module's internals
)

Edge violation kinds (set by the layer linter).

Variables

LayerOrder is the left-to-right pipeline order used by the renderer. Ports sit between service and repository: a service uses a port, an adapter (repository) implements it — both arrows converge on the port.

Functions

func EditorURL

func EditorURL(scheme, absFile string, line, col int) string

EditorURL builds a deep link that opens file:line:col in the given editor. Supported schemes: "vscode", "cursor". Unknown scheme returns "".

Types

type Edge

type Edge struct {
	From string `json:"from"`
	To   string `json:"to"`
	Kind string `json:"kind"`
	// Violation, when non-empty, marks an architecture smell on a call edge.
	Violation string `json:"violation,omitempty"`
}

Edge is a directed arrow between two nodes.

type Graph

type Graph struct {
	Module string `json:"module"`
	Nodes  []Node `json:"nodes"`
	Edges  []Edge `json:"edges"`
}

Graph is the whole picture.

type Node

type Node struct {
	ID        string `json:"id"`
	Kind      string `json:"kind"`
	Label     string `json:"label"`
	Layer     string `json:"layer"`
	Module    string `json:"module"`
	Service   string `json:"service,omitempty"` // owning microservice (SystemView)
	Pkg       string `json:"pkg,omitempty"`
	Func      string `json:"func,omitempty"`
	File      string `json:"file,omitempty"`
	Line      int    `json:"line,omitempty"`
	EditorURL string `json:"editorURL,omitempty"`

	// Hash is a location-independent digest of the function's normalized body,
	// populated only in Raw mode. It lets external consumers (arch-diff) detect
	// a changed body without false positives from moved or reformatted code.
	Hash string `json:"hash,omitempty"`

	// Endpoint-only fields.
	Method string `json:"method,omitempty"`
	Path   string `json:"path,omitempty"`
}

Node is a single box in the graph.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL