Beyond Vector Search: Building a Graph-Native Codebase Intelligence Agent with FalkorDB
Why vector embeddings fail at understanding software architecture, and how we built an explainable ReAct agent that navigates code as a living graph.
1. Introduction
Every software engineer knows the sinking feeling of opening a new, massive repository for the first time.
You look at dozens of directories, hundreds of source files, implicit architectural layers, and complex dependency webs. You open your favorite AI coding assistant and ask:
"If I refactor our authentication service, what downstream agent nodes and API routes will break?"
The assistant pauses, scans your repository with vector similarity search, and responds with a confident, beautifully formatted hallucination. It lists files that don't depend on your service, misses the actual orchestrator three directories over, and leaves you to dig through the call stack manually.
During the FalkorDB Graph Hacks 2026, we set out to fix this fundamental breakdown. We built CodeWeaver — a graph-powered codebase intelligence agent that treats code not as disconnected text chunks, but as what it actually is: a directed, typed, multi-dimensional graph.
Here is the story of why we abandoned vanilla vector RAG for codebase intelligence, how we modeled a real-world enterprise codebase in FalkorDB, and what we learned building an autonomous agent with a 100% explainable reasoning path.
Demo
Check out the project demo:
2. The Real Problem: Why Vector Search Fails at Code
The modern AI stack is obsessed with semantic embeddings. For general knowledge retrieval, vector search works wonders. But software code is not natural language prose — code is strict, deterministic topology.
When you chunk a codebase into 500-token text slices and embed them into a vector space, you destroy the exact information that makes software function:
-
Topological Blindness: Embedding vectors capture semantic similarity, not causal connectivity. A function named
handleAuthErrormight be semantically identical tologAuthFailure, but if only one of them is invoked by the mission-critical state machine, vector search treats them as interchangeable. - The Multi-Hop Horizon: Real codebase questions are multi-hop by definition: $$\text{Repository} \longrightarrow \text{Domain Service} \longrightarrow \text{State Machine Node} \longrightarrow \text{API Route}$$ Vector retrieval cannot jump across four deterministic references. It retrieves chunks that "sound" like the query, completely missing the transitive chain.
- Zero Verifiability: When a traditional LLM answers an architectural question, you have no way to verify how it reached its conclusion. You are left trusting a black box with your production deployment.
3. The Insight: Code is a Graph, Not a Bag of Tokens
Compilers have understood this for half a century: code represents an Abstract Syntax Tree (AST), a call graph, and an import dependency graph.
When an experienced engineer investigates a codebase, they don't do vector similarity in their heads. They trace references:
- "Who calls this function?"
- "Which architectural layer does this file belong to?"
- "What high-level business feature does this module implement?"
- "Who owns this domain?"
These questions are textbook graph traversals. By representing the codebase as a native property graph, we can leverage Cypher queries to answer structural, multi-hop questions with mathematical certainty. The LLM shouldn't guess connections; it should navigate verified graph relations.
4. What We Built: CodeWeaver
CodeWeaver is an autonomous codebase intelligence platform built on top of FalkorDB, Next.js 16, LangChain, and PostgreSQL.
Instead of guessing from isolated snippets, CodeWeaver equips an autonomous ReAct agent with specialized tools that execute Cypher queries against FalkorDB in real time.
Core Capabilities:
- Architectural Discovery: Understands clean architecture layers, modules, and file distributions.
- Blast Radius & Impact Analysis: Calculates multi-hop downstream dependencies when files or functions change.
- Feature-to-Code Mapping: Bridges the gap between high-level business features (e.g., ReAct Agent Loop, Human-in-the-Loop Validation, Policy RAG) and the exact classes and files that implement them.
- Explainable Reasoning Paths: Every answer returned by the agent includes the exact internal FalkorDB node IDs traversed. Users can click a single button to inspect the visual subgraph that grounded the response.
-
Interactive Knowledge Graph Canvas: A dedicated, interactive force-directed graph page (
/graph) with category filtering, node inspection, and real-time search.
5. How We Modeled the Codebase as a Graph
To test CodeWeaver against a realistic, non-trivial system, we ingested the complete repository of an Autonomous Healthcare Prior Authorization Agent — a system featuring Next.js 16, LangGraph state machines, domain services, and Prisma persistence.
We designed a property graph schema that captures both low-level code syntax and high-level architectural intent:
(Person)-[:OWNED_BY]-(File|Module)
(File)-[:BELONGS_TO]->(Module)
(File)-[:IMPLEMENTS]->(Feature)
(Function|Class)-[:BELONGS_TO]->(File)
(Function)-[:CALLS]->(Function)
(Class|File)-[:USES]->(Class|File)
The Node Types:
-
Module: Architectural layers (Agent Core,Agent Tools,Services,Repository,UI Components). -
Feature: Functional product capabilities (ReAct Loop,Prior Authorization Flow,Clinical Guideline RAG). -
File: Source files across the repository. -
Function&Class: Discrete AST-extracted symbols, methods, and declarations. -
Person: Domain owners and maintainers responsible for specific modules.
The Relationship Topology:
-
BELONGS_TO: Structural encapsulation (functions in files; files in modules). -
IMPLEMENTS: Semantic grounding linking low-level code directly to high-level product features. -
CALLS&USES: AST invocation chains and import dependencies. -
OWNED_BY: Accountability and team ownership mapping.
Our ingestion engine parsed the codebase into 228 nodes and 306 relationships, creating a complete structural digital twin inside FalkorDB.
6. How the Agent Reasons: Cypher-Powered Tools & Explainability
We built CodeWeaver using LangChain and LangGraph to implement a structured ReAct (Reason-Act-Reflect) loop.
Rather than giving the LLM raw Cypher execution privileges (which often produces invalid syntax and security risks), we provided the agent with four deterministic graph tools:
-
getArchitectureOverview: Traverses high-levelModulenodes and their file counts. -
getFeatureImplementation: Finds all files and classes linked to a feature viaIMPLEMENTS. -
analyzeDependencies: Executes 1-to-3 hop traversals (<-[:CALLS|USES*1..3]-) to compute the blast radius of a component. -
getOwnershipInfo: Resolves code ownership throughOWNED_BYrelationships.
User Prompt
│
▼
LangChain ReAct Agent (Azure OpenAI GPT-4o)
│
├─► Step 1: Select Graph Tool (e.g., analyzeDependencies)
│
├─► Step 2: Query FalkorDB via Redis Protocol
│ MATCH (n)<-[:CALLS|USES*1..2]-(dep)
│ RETURN ID(n), ID(dep), n.name, dep.name
│
├─► Step 3: FalkorDB responds in 1.4ms
│
▼
Synthesize Answer + Collect Reasoning Node IDs: [42, 88, 104, 115]
│
▼
Client: Render Answer + Interactive Reasoning Path Subgraph
The Power of the Reasoning Path
Whenever the agent queries FalkorDB, our Cypher queries explicitly project the internal graph node IDs: RETURN ID(n) AS nodeId.
The agent collects these IDs throughout its reasoning trajectory and returns them alongside the markdown answer. In the UI, the user sees an interactive Reasoning Path badge. Clicking it opens a focused modal containing only the nodes and relationships the agent touched.
There is zero black-box mystery: developers can verify every claim against the actual graph topology.
7. Architecture Decisions
1. In-Memory Graph Processing with FalkorDB
Agentic workflows require multiple tool calls per turn. If graph queries take 500ms, an agent that needs 3 hops feels sluggish and unresponsive. FalkorDB runs in-memory with C-level graph algorithms over Redis protocol, consistently returning multi-hop queries in under 2 milliseconds. This sub-millisecond latency makes iterative graph reasoning feel instantaneous.
2. Separation of Playground (/chat) and Explorer (/graph)
A common mistake in AI developer tools is cramming an enormous canvas into the chat interface. We maintained a strict separation:
- The Playground focuses on focused conversational Q&A with lightweight, contextual subgraph previews.
- The Knowledge Graph Page provides an expansive, full-viewport canvas with category filtering, real-time node search, and full property inspection.
3. Persistent Grok-Style Chat Sessions
Codebase investigations are iterative. We paired PostgreSQL and Prisma with our FalkorDB backend to persist chat sessions, conversation histories, and associated reasoning node IDs across browser sessions.
8. Challenges We Faced & How We Solved Them
Challenge 1: The "Visual Hairball" Effect
Our first attempt at visualizing 200+ nodes and 300+ relationships on an HTML canvas resulted in an unreadable green blob. Text labels overlapped, and users couldn't isolate relevant components.
Solution: We introduced adaptive scale-based label rendering and category filtering. In GraphViewer.tsx, high-level entities (Module, Feature) display bold labels at all zoom levels, while granular labels (Function, Class) only render when the user zooms in past 1.05x scale. We also added canvas outline stroke rendering (ctx.strokeText) to ensure contrast across both light and dark themes.
Challenge 2: Hallucination-Free Reasoning Nodes
Initially, we experimented with asking the LLM to output which nodes it referenced. The result? The LLM occasionally invented node IDs that didn't exist in FalkorDB.
Solution: We eliminated LLM discretion entirely. The graph tools themselves extract and accumulate the exact FalkorDB ID(node) integers directly from the Cypher query result records. The frontend receives mathematically grounded node IDs straight from the database engine.
9. What We Learned
- Graph databases turn RAG from probabilistic guessing into deterministic retrieval. When an LLM cites a structural path derived from a graph database, its hallucinations on architectural boundaries drop to near zero.
- Explainability is the missing pillar in developer tooling. Developers don't distrust AI because it's imperfect; they distrust AI because it doesn't show its work. Providing an interactive subgraph showing the exact nodes used in reasoning builds immediate trust.
-
Graph schema design requires intentional abstraction. Including every single variable or line of code creates unusable noise. Focusing on high-impact abstractions (
Module,Feature,File,Function,Class) provides the sweet spot for agentic reasoning.
10. Why FalkorDB Was Critical
CodeWeaver simply could not exist without a purpose-built graph database:
-
Expressive OpenCypher: Modeling queries like
MATCH (f:File)-[:IMPLEMENTS]->(feat:Feature {name: "ReAct Agent Loop"})requires clean, standardized graph query language semantics. - Unbeatable Speed: FalkorDB’s in-memory execution meant our agent’s multi-step ReAct loop ran without latency penalties.
-
Effortless Docker Deployment: Deploying FalkorDB alongside Postgres in a single
docker compose up -dmade local setup seamless.
FalkorDB isn't a secondary cache in CodeWeaver — it is the intelligence engine that powers every single answer our agent produces.
11. Conclusion
Software systems will only grow larger, more complex, and more distributed. As AI agents take on larger roles in software engineering, feeding them flattened text chunks through vector search is a dead end.
By anchoring AI reasoning in a native graph database like FalkorDB, we can build agents that truly understand software architecture — agents that trace dependencies across multiple hops, respect module boundaries, and show their work with complete transparency.
CodeWeaver proves that when code is modeled as connected knowledge, AI stops guessing and starts understanding.
Check out the CodeWeaver GitHub Repository to explore the code, run the ingestion pipeline, and try the graph-powered agent yourself.

Top comments (0)