# Visualize the dependency graph with `kix graph`

Use `kix graph` to inspect dependencies in the rendered cluster. The graph
includes references carried by resource manifests and explicit `requires` or
`extraDeps` edges. It does not need access to Kubernetes.

## Print the tree

Tree output is the quickest way to inspect ordering in a terminal:

<Command expandable {...graphTree} />

The tree starts with resources that have no dependencies. Each indented entry
depends on the resource above it. In this example, the gateway ConfigMap
appears beneath `Service/backend@platform`, showing the edge across the
namespace boundary.

If an expected edge is missing, check that the consumer reads a value from the
dependency, such as `backend.out.url { }` or `backend.out.name`. That reference
creates the edge. If there is no value to read, add the dependency to
`requires` or `extraDeps`.

`deps` alone does not create an edge. It binds a package build argument to a
provider. An edge appears only when the rendered resource uses a value from
that provider.

## Write a DOT graph

Use DOT output for Graphviz or another graph viewer:

<Command expandable {...graphDot} />

Redirect it into a file and render it with Graphviz:

<Command
  commands={[
    "kix graph 08-namespace-deps --format dot > kix-graph.dot",
    "dot -Tsvg kix-graph.dot > kix-graph.svg",
  ]}
  cwd="kix-examples/"
/>

The second command requires Graphviz. The generated SVG is useful when a tree
is too deep to scan comfortably.

## Write graph data as JSON

Use JSON when another tool will inspect the nodes and edges:

<Command {...graphJson} />

The excerpt above counts the nodes and edges and shows one node. Every node
carries its kind, name, namespace, and identity hash, so another tool can
join the graph to the rendered manifests.

Choose JSON for automation, not as the default way to read the graph by hand.

:::note[Explanation]
See [The dependency graph as the model](/docs/explanation/the-dependency-graph-as-the-model/)
for how the same graph controls deployment order and readiness waits.
:::

:::note[Reference]
See [`kix graph`](/docs/reference/cli/graph/) for output formats and command
options.
:::