Standard RAG answers local, pinpoint questions well (e.g. "Where is the calculate_discount function defined?"). However, it struggles with holistic, architectural questions:
- "How is the billing subsystem structured?"
- "What is the blast radius if I change the PaymentGateway interface?"
- "Are there circular dependencies between the order and inventory modules?"
To answer these questions, nexcoder-code-intel implements GraphRAG: constructing a multi-relational code knowledge graph and applying hierarchical community detection.
The CodeGraph models source code as a directed multigraph where nodes represent syntactic symbols and edges represent structural relationships:
[UserService] --(calls)--> [PasswordHasher]
|
(inherits)
v
[BaseService] --(implements)--> [IService]
^
|
(binds_ui)
|
[UserForm (DFM)]
calls: Function invocation or method dispatch.inherits: Class inheritance or subclass relationship.implements: Interface fulfillment.imports: Module or package dependency.references: Field, constant, or variable access.binds_ui: Association between a visual UI component (e.g. Delphi DFM form button) and backend event handler code.
Before proposing a refactoring or modifying a public signature, agents query the code graph for transitive impact:
from nexcoder_code_intel import CodeGraph
graph = CodeGraph()
# ... symbols added ...
# Analyze impact with breadth-first traversal
report = graph.impact_analysis("PaymentGateway", max_depth=3)
print("Direct Dependents:", len(report.direct_dependents))
print("Transitive Dependents:", len(report.transitive_dependents))
print("Blast Radius Score:", report.risk_score)The report identifies:
- Direct Callers: Methods directly invoking the symbol.
- Transitive Cascades: Downstream services impacted through multiple hops.
- Risk Score: Normalized metric factoring in coupling, fan-in, and depth.
Answering high-level architectural questions requires abstracting thousands of individual functions into cohesive functional domains.
nexcoder-code-intel runs the Louvain Modularity Algorithm over the code graph:
+-------------------------------------------------------------+
| System Architecture Graph |
| |
| +---------------------------+ +-------------------------+ |
| | Community 1: Auth Module | | Community 2: Billing | |
| | - UserEntity | | - InvoiceManager | |
| | - TokenVerifier | | - GatewayAdapter | |
| | - SessionStore | | - TaxCalculator | |
| +-------------+-------------+ +------------+------------+ |
| | | |
| +------------(calls)----------+ |
+-------------------------------------------------------------+
- Node Clustering: Closely-coupled classes and functions are grouped into communities.
- Bottom-Up Synthesis: An LLM generates a dense architectural summary for each community based on its public interfaces and internal calls.
- Multi-Hop Query Resolution: High-level questions match community summaries first, immediately pruning irrelevant modules and routing queries to the exact subgraphs needed.
| Capability | Standard Vector RAG | CodeGraph + GraphRAG |
|---|---|---|
| Lookup Exact Function | Good (with lexical FTS) | Excellent |
| Understand Call Hierarchies | Poor (blind to relationships) | Native (directed graph traversal) |
| Identify Blast Radius | Cannot determine | Deterministic BFS impact report |
| Architectural Overview | Suffers from context truncation | Cohesive via Louvain community summaries |
| UI-to-Backend Binding | Poor | Explicit binds_ui relationship edges |