# Connections — Dependency Graph

> Visualize how your code elements connect to each other

Interactive dependency graph powered by Neo4j with Cytoscape.js visualization. Model your code structure: files, classes, methods, functions, and their relationships. AI agent imports the graph automatically.

## Features

- **6 node types**: File, Class, Method, Function, Const, Module. Each with its own color on the graph.
- **6 edge types**: CONTAINS, CALLS, IMPORTS, INHERITS, USES, IMPLEMENTS. Full code dependency modeling.
- **Cytoscape.js visualization**: Interactive graph with force-directed layout (cose). Zoom, pan, click nodes, filter by type.
- **Bulk import**: Import hundreds of nodes and edges in one request. Perfect for automatic code sync.
- **Path finding**: Find shortest path between two elements. Cypher query in Neo4j.
- **Graceful degradation**: Neo4j unavailable? Dashboard works — shows unavailability message.

## How it works

1. **Create nodes**: Add code elements: files, classes, methods. Optionally specify file path and line number.
2. **Connect with edges**: Define relationships: class CONTAINS method, method CALLS another method, file IMPORTS module.
3. **Explore the graph visually**: Open graph view. Click nodes to see details and connections in the side panel.
4. **Automate with AI**: AI agent can import your code's dependency graph — bulk create nodes and edges via MCP.

## AI and MCP

Your AI agent can build your code's dependency graph automatically and query it — 9 MCP tools + bulk operations.

- `create_graph_node`: Create node with type, name, and optional metadata
- `bulk_create_graph_nodes`: Import multiple nodes in one request
- `create_graph_edge`: Connect two nodes with an edge of given type
- `bulk_create_graph_edges`: Import multiple edges in one request
- `query_graph`: Get full graph or type-filtered subgraph
- `find_graph_path`: Shortest path between two nodes
- `get_graph_stats`: Stats: node and edge counts per type
- `delete_graph_node`: Delete node and cascade its edges
- `delete_graph_edge`: Delete edge between nodes

## Technical details

- **Graph database**: Neo4j 5 Community. Async driver with per-project data isolation (project_id property on nodes).
- **Visualization**: Cytoscape.js v3.30.4 (CDN). Force-directed layout (cose). Custom coloring by type.
- **Data isolation**: Every node and edge tagged with project_id. Uniqueness constraint per type. HNSW index on project_id.
- **Graceful degradation**: ENABLE_GRAPH_DB=false disables the module. is_enabled() + try/except returns empty graph.
