A simple Python script that scans a codebase directory and generates an interactive graph visualization showing file dependencies and architecture.
- Scans Python, JavaScript, and TypeScript files
- Parses import/dependency relationships
- Interactive graph visualization with React Flow
- Automatic browser opening
- CLI interface for specifying directory paths
- Python 3.7+
- Node.js (for building the frontend)
- pnpm (recommended) or npm
- Clone or download this repository
- Install Python dependencies:
pip install -r requirements.txt
- Install Node.js dependencies and build the frontend:
cd frontend pnpm install pnpm build cd ..
python visualizer.pypython visualizer.py /path/to/your/codebaseThe script will:
- Scan the specified directory for supported files
- Analyze dependencies and build a graph
- Start a web server on http://localhost:5000
- Automatically open your browser to view the visualization
- Python (.py): Parses
importandfrom ... importstatements - JavaScript/TypeScript (.js, .ts, .jsx, .tsx): Parses ES6 imports and CommonJS require statements
- File Scanning: Recursively scans the directory, excluding common ignore patterns (.git, node_modules, etc.)
- Dependency Analysis: Uses AST parsing for Python and regex for JavaScript to extract import relationships
- Graph Construction: Creates nodes for files and edges for dependencies
- Visualization: Serves an interactive React Flow graph showing the codebase architecture
Python Script (Flask)
├── File Scanner → Dependency Parser → Graph Builder
└── Web Server (serves React frontend)
React Frontend (React Flow)
├── Fetches graph data from /api/graph
├── Renders interactive node-based graph
└── Provides zoom, pan, and selection controls
To modify the frontend:
cd frontend
pnpm dev # Start development serverTo rebuild after changes:
cd frontend
pnpm build- Currently supports Python and JavaScript/TypeScript files
- Dependency resolution is basic and may not handle all import patterns
- Large codebases may require performance optimizations
- Graph layout is simple grid-based (can be improved with layout algorithms)
Feel free to add support for more languages, improve dependency parsing, or enhance the visualization features!