A beautiful, interactive visualization tool that analyzes JavaScript/TypeScript codebases and generates visual dependency graphs. Perfect for understanding code structure, identifying complexity hotspots, and onboarding new developers.


- ๐ Interactive Graph Visualization - D3.js-powered force-directed graph showing function relationships
- ๐ Function Analysis - Extracts functions, methods, classes, and their dependencies
- ๐ฏ Complexity Analysis - Calculates cyclomatic complexity and highlights "hotspots"
- ๐จ Beautiful UI - Modern dark theme with intuitive controls
- โก Real-time Interactions - Hover, click, and drag nodes for exploration
- ๐ฑ๏ธ Advanced Controls - Zoom, pan, fullscreen, and keyboard shortcuts
- ๐ฑ Responsive Design - Works on desktop and mobile devices
- Node.js (v14 or higher)
- npm or yarn
-
Clone the repository
git clone https://github.com/lazzerex/codebase-knowledge-map.git cd codebase-knowledge-map
-
Install dependencies
npm install
-
Start the server
npm start
-
Open your browser
http://localhost:3000
-
Click "Load Data" to see the sample visualization!
- Drag nodes to reposition them
- Scroll to zoom in/out
- Click nodes to highlight connections
- Hover for function details
Ctrl/Cmd + F
- Toggle fullscreenCtrl/Cmd + 0
- Reset zoomCtrl/Cmd + 1
- Fit view to screenT
- Toggle sidebarESC
- Exit fullscreen
- ๐ Fullscreen - Immersive full-screen mode
- ๐ Fit View - Auto-zoom to fit all nodes
- ๐ Toggle Sidebar - Show/hide function list
- โ Help - Display help dialog
- ๐ข Green - Low complexity (1-2)
- ๐ Orange - Medium complexity (3-4)
- ๐ด Red - High complexity (5+)
- Larger nodes = Higher complexity functions
- Smaller nodes = Simpler functions
- Arrows show function call dependencies
- Hover to highlight connection paths
codebase-knowledge-map/
โโโ public/ # Frontend files
โ โโโ index.html # Main HTML structure
โ โโโ style.css # Styling and themes
โ โโโ script.js # D3.js visualization logic
โโโ src/
โ โโโ parser/ # Code analysis engine
โ โโโ javascript-parser.js
โโโ test-code/ # Sample code for analysis
โ โโโ sample.js
โ โโโ shopping-cart.js
โโโ server.js # Express server
โโโ test-parser.js # CLI testing tool
โโโ package.json
-
Add files to
test-code/
directorycp your-file.js test-code/
-
Restart the server
npm start
-
Click "Load Data" to analyze your code
# Test the parser directly
npm run test
# Or use the CLI tool
node test-parser.js
# Auto-restart on changes
npm run dev
.js
- JavaScript.jsx
- React JSX.ts
- TypeScript.tsx
- TypeScript JSX
- โ Function declarations
- โ Arrow functions
- โ Class methods
- โ Function calls (dependencies)
- โ Cyclomatic complexity calculation
- โ ES6+ syntax support
- Frontend: HTML5, CSS3, D3.js v7
- Backend: Node.js, Express
- Parser: Babel AST parser
- Visualization: Force-directed graph simulation
{
"@babel/parser": "^7.23.0",
"@babel/traverse": "^7.23.0",
"express": "^4.18.2",
"d3": "^7.8.5"
}
- ๐งโ๐ป Code Reviews - Visualize function relationships and complexity
- ๐ Documentation - Generate visual architecture diagrams
- ๐ Onboarding - Help new developers understand codebases
- ๐ Refactoring - Identify complex functions that need attention
- ๐ Technical Debt - Track complexity growth over time
- File upload interface
- Git integration for commit history
- Export to PNG/SVG
- Search and filter functions
- Multiple programming language support
- Performance metrics overlay
- VS Code extension
We welcome contributions! Here's how to get started:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- Follow existing code style
- Add tests for new features
- Update documentation
- Test across different browsers
This project is licensed under the MIT License - see the LICENSE file for details.
- D3.js - For the incredible visualization framework
- Babel - For the powerful AST parsing capabilities
- Express - For the lightweight server framework
- Community - For feedback and contributions
- ๐ Issues: GitHub Issues
- ๐ฌ Discussions: GitHub Discussions
- ๐ง Email: nambinh236@gmail.com
โญ If you find this project useful, please consider giving it a star on GitHub!