TypeScript codebase knowledge graph analyzer — an Nx-style dependency graph tool with deep symbol-level analysis.
- Deep AST Analysis: Parses TypeScript files to extract classes, interfaces, functions, methods, and decorators.
- Rich Relationships: Tracks imports, function calls, class inheritance, and structural dependencies.
- Advanced Graph Algorithms: Includes cycle detection, shortest path, impact analysis, and topological sorting.
- Multiple Export Formats: Export to JSON, DOT (Graphviz), GraphML, Mermaid, Cytoscape, React Flow, and Neo4j CSV.
- Visualization Tools: Use the built-in React Flow visualizer for interactive graph exploration.
Install globally to use the CLI from anywhere:
npm install -g cli-node-graph
# or
pnpm add -g cli-node-graph
# or
yarn global add cli-node-graphOr run it directly using npx:
npx cli-node-graph <command> [options]Analyze a TypeScript codebase to build the knowledge graph:
cli-node-graph analyze ./path/to/projectExport the knowledge graph to various formats (e.g., reactflow, json, dot, mermaid):
cli-node-graph export ./path/to/project --format reactflow -o graph.jsonDetect circular dependencies in your project:
cli-node-graph cycles ./path/to/projectDetermine what files or symbols are affected if you change a specific symbol:
cli-node-graph impact UserService ./path/to/projectView overall statistics of your codebase:
cli-node-graph stats ./path/to/projectYou can also use cli-node-graph programmatically in your Node.js scripts:
npm install cli-node-graphimport { GraphBuilder, GraphAlgorithms, JsonExporter } from 'cli-node-graph';
// Build the graph
const graph = new GraphBuilder().build({ projectRoot: './my-project' });
// Analyze the graph
const cycles = new GraphAlgorithms(graph).detectCycles();
console.log('Cycles found:', cycles);
// Export the graph
const json = new JsonExporter().export(graph);If you're interested in contributing to the project, please see our Contributing Guide for details on setting up the development environment, architecture, and running tests.