Skip to content

yassinekrika/cli-node-graph

Repository files navigation

cli-node-graph

TypeScript codebase knowledge graph analyzer — an Nx-style dependency graph tool with deep symbol-level analysis.

npm version License: MIT

Features

  • 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.

Installation

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-graph

Or run it directly using npx:

npx cli-node-graph <command> [options]

Usage

Analyzing a Project

Analyze a TypeScript codebase to build the knowledge graph:

cli-node-graph analyze ./path/to/project

Exporting the Graph

Export the knowledge graph to various formats (e.g., reactflow, json, dot, mermaid):

cli-node-graph export ./path/to/project --format reactflow -o graph.json

Finding Cycles

Detect circular dependencies in your project:

cli-node-graph cycles ./path/to/project

Impact Analysis

Determine what files or symbols are affected if you change a specific symbol:

cli-node-graph impact UserService ./path/to/project

Project Statistics

View overall statistics of your codebase:

cli-node-graph stats ./path/to/project

API Usage

You can also use cli-node-graph programmatically in your Node.js scripts:

npm install cli-node-graph
import { 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);

Contributing

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.

License

MIT

About

TypeScript codebase knowledge graph analyzer — an Nx-style dependency graph tool with deep symbol-level analysis.

Resources

Contributing

Stars

4 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors