Knowledge Graph
Understanding CodeMap's code knowledge graph architecture
What is a Knowledge Graph?
CodeMap builds a comprehensive knowledge graph of your codebase, capturing files, symbols, dependencies, and semantic relationships. A knowledge graph is a network of interconnected entities and relationships.
CodeMap's graph includes:
- Files - Every source file in your project
- Symbols - Functions, classes, interfaces, types, variables — each enriched with call graph data
- File Dependencies - Import/export relationships between files
- Symbol Call Graph - Which functions call which, tracked across file boundaries
- Labels & Groups - Semantic organization created by you or AI agents
Graph Structure
The graph is built through AST (Abstract Syntax Tree) parsing of your code files. For each file, CodeMap extracts:
- Exported symbols and their types
- Import statements and dependencies
- Symbol call relationships (
callsandcalledByper symbol) - File metadata (size, hash, last modified)
Symbol Call Graph
Beyond file-level imports, CodeMap tracks which symbols call which across your entire codebase. Every symbol carries two fields:
- calls - Symbols this symbol invokes (e.g.,
["src/db.ts$query", "src/cache.ts$get"]) - calledBy - Symbols that invoke this one (e.g.,
["src/api/routes.ts$getUser"])
Symbol references use the format relativePath$symbolName — for example src/services/UserService.ts$deleteUser. This syntax works across all call-graph-aware tools.
Practical Uses
- Dead code detection — exported symbols with an empty
calledBymay be unused - Blast radius — use
codemap_impact_analysiswith a symbol reference to see every function that transitively calls it - Refactoring safety — before changing a function signature, check
calledByto find every call site
Multi-Language Support
CodeMap supports multiple languages with dedicated parsers:
- TypeScript/JavaScript - Full AST parsing with type information
- Vue - Single-file component parsing (script, template, style)
- PHP - Support for PHP 5.2 through 8.x
Each parser extracts language-specific constructs and relationships, building a unified graph representation regardless of the source language.
# Get graph statistics (includes symbolGraph.edgeCount)
codemap stats
# View all parsers and project overview
codemap orient# Peek at a file — always returns symbols with calls/calledBy
codemap peek src/services/UserService.ts
# Symbol-level dependency: what does deleteUser call, and who calls it?
codemap deps src/services/UserService.ts$deleteUser# Symbol-level blast radius: who transitively calls deleteUser?
codemap impact-analysis src/services/UserService.ts$deleteUser
# Find potentially dead code: symbol with no callers
codemap deps src/utils/legacy.ts$formatXmlThe knowledge graph updates automatically as you work. When you create, modify, or delete files, CodeMap tracks these changes and adjusts the graph — including symbol call edges — in real-time without requiring manual reindexing.
Any tool that supports symbol targeting accepts the format relativePath$symbolName — for example src/services/UserService.ts$deleteUser. Use this with codemap_get_dependencies, codemap_impact_analysis, codemap_read_file, codemap_delete, and more to scope operations to a single symbol.
Because CodeMap normalizes all languages into a unified graph structure, you can search and analyze your codebase using the same tools regardless of whether it's TypeScript, Vue, PHP, or a mix of all three.