# Code Knowledge Graph

The Code Knowledge Graph parses your repository and builds an interactive visualization of its structure -- functions, classes, modules, and how they connect through calls, imports, and inheritance.

## What It Shows

The graph maps your codebase as a network of nodes (code symbols) and edges (relationships). It supports Rust, TypeScript, JavaScript, and Python.

**Node types**: Functions, methods, classes, structs, enums, interfaces, traits, modules, and files.

**Edge types**: Calls (function invocation), imports, inheritance, interface/trait implementation, containment (module contains function), and type references.

Nodes are color-coded by community -- clusters of highly connected symbols detected automatically using community detection algorithms.

## How to Navigate

### Graph Explorer

1. Navigate to **Code Graph** in the sidebar
2. Select a repository from the list
3. If the graph has not been built yet, click **Build Graph** and wait for parsing to complete
4. The interactive canvas renders with all symbols and relationships

On the canvas:

- **Pan** by dragging the background
- **Zoom** with the scroll wheel
- **Click a node** to open the code inspector panel

### Search

Type at least 2 characters in the search box to find symbols by name. Click a result to highlight it on the canvas and open the inspector.

### Code Inspector

When you click a node, the inspector panel shows:

- **Symbol name** and kind (function, class, etc.)
- **File path** with line range
- **Source code** excerpt
- **Connected nodes** -- what this symbol calls, what calls it, what it imports, etc.

### Statistics

The statistics panel shows the total node and edge count, number of detected communities, languages found, and a file tree of the codebase.

## Use Cases

- **Onboarding** -- understand unfamiliar codebase structure at a glance
- **Architecture review** -- identify tightly coupled modules and circular dependencies
- **Security analysis** -- trace data flow from entry points to sensitive operations to understand blast radius
- **Impact analysis** -- see what depends on code you plan to change before refactoring
