Structural Backbone
Code Graph
Vector search is great for fuzzy questions; it's terrible at precision. SourcePrep maintains a parallel structural graph of your codebase — a directed graph of imports, definitions, and references — so your AI can answer "where is the User struct defined and what calls it?" with zero hallucinations.
Why a Graph
Vector embeddings are excellent at semantic similarity but blind to structure. Asking "where is X defined and what calls it?" through a vector store gets you files that talk about X — not files that contain X. The Code Graph is the precision layer: parser-derived ground truth, no LLM in the loop, no hallucinations.
Rust Engine
The Code Graph is built by a high-performance Rust engine (prep-engine) that runs alongside the Python daemon. Tree-sitter generates concrete syntax trees for accurate symbol extraction.
Speed: parses ~50k files in seconds.
Accuracy: Tree-sitter CSTs, not regex.
Multi-language: Python, TypeScript, JavaScript, Go, Rust, Java, C, C++ — and growing.
What It Maps
Three relationship types form the graph's edges:
Where is a symbol declared? Files, classes, functions, types.
Where is the symbol used? Every call site, every import.
What does file A depend on? Module-level dependency edges.
Visualizing the Graph
The Code Graph panel in the dashboard provides an interactive way to explore relationships. Click any file to see its immediate dependencies (upstream) and consumers (downstream); toggle to a list view for exact import counts and symbol references.
How Agents Use It
You don't query the graph directly. Instead, your agent enables trace expansion in its context request (or uses the "Trace" keywords in the MCP editor). When enabled, SourcePrep:
- Finds the primary chunks via vector search.
- Identifies key symbols in those chunks.
- Queries the Code Graph for their definition sites and usages.
- Expands the context to include those related files, even if they didn't match the search keywords.
Example
You ask "how is billing calculated?" Vector search finds billing.py. The Code Graph notices billing.py imports tax_rates.py — so SourcePrep includes tax_rates.py in the context automatically, preventing the AI from hallucinating tax logic.
What blast-radius expansion looks like when an agent calls prep_impact before a refactor.
Beyond the Graph
The Code Graph is not a static artifact. It's the structural foundation for a 15-stage Graph Enrichment pipeline that layers in meaning, module relationships, and architectural summaries — turning raw structure into navigable knowledge your AI can actually reason over.
Read the Graph Enrichment guide