Documentation
¶
Overview ¶
Package flow generates architecture flow diagrams from the codeiq graph.
Mirrors src/main/java/io/github/randomcodespace/iq/flow/ — `View` is the enum of supported diagram views, `Engine` queries the graph, the builders in this file produce a `Diagram` per view, and `Renderer` emits Mermaid / JSON / DOT / YAML.
Five views match the Java side exactly:
- overview: 4 subgraphs (CI, Infrastructure, Application, Security)
- ci: CI/CD pipeline detail (workflows, jobs, triggers)
- deploy: K8s / Docker / Terraform topology
- runtime: endpoints / entities / messaging grouped by layer
- auth: guards / endpoints / protection coverage
Index ¶
- func IsKnownView(s string) bool
- func Render(d *Diagram, format string) (string, error)
- func RenderDOT(d *Diagram) string
- func RenderJSON(d *Diagram) (string, error)
- func RenderMermaid(d *Diagram) string
- func RenderYAML(d *Diagram) (string, error)
- type Diagram
- type Edge
- type Engine
- type Node
- type Snapshot
- type Store
- type Subgraph
- type View
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsKnownView ¶
IsKnownView reports whether the supplied string identifies a built-in view. Used by the `flow` CLI and the `generate_flow` MCP tool to reject typos before opening the graph.
func Render ¶
Render emits the Diagram in the requested format. Recognised formats: json (default), mermaid, dot, yaml. Returns an error for unknown formats.
func RenderDOT ¶
RenderDOT emits the diagram as a Graphviz DOT digraph string. Subgraphs are emitted as `cluster_*` for visual grouping in Graphviz output.
func RenderJSON ¶
RenderJSON emits the diagram as indented JSON. Field names match the Java FlowRenderer.renderJson output exactly so parity diffs match 1:1.
func RenderMermaid ¶
RenderMermaid emits the diagram as a Mermaid `graph` flowchart string. The output is deterministic — nodes within each subgraph and edges are sorted by ID before emission.
func RenderYAML ¶
RenderYAML emits the diagram as YAML. The mapping uses the same key names as the JSON output.
Types ¶
type Diagram ¶
type Diagram struct {
Title string `json:"title"`
View string `json:"view"`
Direction string `json:"direction"`
Subgraphs []Subgraph `json:"subgraphs"`
LooseNodes []Node `json:"loose_nodes"`
Edges []Edge `json:"edges"`
Stats map[string]any `json:"stats"`
}
Diagram is the complete flow diagram. Renderers consume this structure directly; no other shape is exposed.
func NewDiagram ¶
NewDiagram constructs an empty diagram for the supplied view with the default left-to-right ("LR") direction and pre-allocated slices/maps.
func (*Diagram) AllNodes ¶
AllNodes returns every node across both loose nodes and subgraph nodes. Order matches the Java side: loose nodes first, then each subgraph's nodes in subgraph order.
func (*Diagram) ValidEdges ¶
ValidEdges returns the edges whose source AND target IDs exist on a node in the diagram. Dangling references are silently dropped — matches the Java side's FlowDiagram.toMap behaviour.
type Edge ¶
type Edge struct {
Source string `json:"source"`
Target string `json:"target"`
Label string `json:"label,omitempty"`
Style string `json:"style"`
}
Edge is one edge in a flow diagram. Edges are filtered against the set of valid node IDs during rendering — dangling edges are dropped.
func NewLabelEdge ¶
NewLabelEdge constructs a solid edge with a label.
func NewStyledEdge ¶
NewStyledEdge constructs an edge with an explicit style (solid | dotted | thick).
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is the flow-diagram generator. Stateless apart from the bound Store; safe for concurrent calls because Generate loads a fresh Snapshot every invocation.
Mirrors src/main/java/.../flow/FlowEngine.java.
func NewEngineFromSnapshot ¶
NewEngineFromSnapshot constructs an Engine that returns the supplied snapshot from every call — useful for tests that want to avoid the Kuzu round trip.
type Node ¶
type Node struct {
ID string `json:"id"`
Label string `json:"label"`
Kind string `json:"kind"`
Style string `json:"style"`
Properties map[string]any `json:"properties"`
}
Node is one node in a flow diagram. The diagram is a collapsed / summarized view of the underlying graph, so a single flow Node frequently represents a *category* of graph nodes (e.g. "Endpoints x42").
func NewNode ¶
NewNode constructs a Node with default style ("default") and empty properties. Use NewNodeWithProps / NewNodeWithStyle for richer cases.
func NewNodeWithProps ¶
NewNodeWithProps constructs a Node with the supplied properties map.
type Snapshot ¶
type Snapshot struct {
Nodes []*model.CodeNode
Edges []*model.CodeEdge
// contains filtered or unexported fields
}
Snapshot is a materialised view of the graph used by every view builder. Loading once at the top of Generate avoids the per-view round trip the Java `FlowDataSource.findByKind` pattern caused. Snapshot is read-only and safe to share across goroutines.
Mirrors the Java side's CacheFlowDataSource — pre-loaded in memory so view builders are pure functions over (nodes, edges).
func LoadSnapshot ¶
LoadSnapshot loads every node and edge from store. On large graphs this is materially heavier than the Java CacheFlowDataSource path; the flow command surface accepts the trade because it is interactive (one human call) rather than hot-path.
func NewSnapshot ¶
NewSnapshot constructs a Snapshot over the supplied nodes and edges. Both slices are retained by reference — do not mutate after passing.
type Store ¶
type Store interface {
LoadAllNodes() ([]*model.CodeNode, error)
LoadAllEdges() ([]*model.CodeEdge, error)
}
Store is the minimum graph surface Engine needs. *graph.Store satisfies this; tests use an in-memory fake.
type Subgraph ¶
type Subgraph struct {
ID string `json:"id"`
Label string `json:"label"`
Nodes []Node `json:"nodes"`
DrillDownView string `json:"drill_down_view,omitempty"`
ParentView string `json:"parent_view,omitempty"`
}
Subgraph is a labelled group of nodes. Subgraphs may declare a drill-down view that the UI follows when the user expands the group.
func NewSubgraph ¶
NewSubgraph constructs a subgraph with no drill-down hint.
type View ¶
type View string
View is a single supported flow view. The string value is the canonical identifier used in CLI args, MCP tool params, and stored output paths.
const ( // ViewOverview is the high-level architecture overview. ViewOverview View = "overview" // ViewCI is the CI/CD pipeline detail view. ViewCI View = "ci" // ViewDeploy is the deployment topology view. ViewDeploy View = "deploy" // ViewRuntime is the runtime architecture view. ViewRuntime View = "runtime" // ViewAuth is the auth / security view. ViewAuth View = "auth" )