Skip to content

lazzerex/codebase-knowledge-map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ—บ๏ธ Codebase Knowledge Map

Node.js JavaScript TypeScript D3.js Express Babel HTML5 CSS3 License MIT

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.

image image

โœจ Features

  • ๐Ÿ“Š 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

๐Ÿš€ Quick Start

Prerequisites

  • Node.js (v14 or higher)
  • npm or yarn

Installation

  1. Clone the repository

    git clone https://github.com/lazzerex/codebase-knowledge-map.git
    cd codebase-knowledge-map
  2. Install dependencies

    npm install
  3. Start the server

    npm start
  4. Open your browser

    http://localhost:3000
    
  5. Click "Load Data" to see the sample visualization!

๐ŸŽฎ Controls

๐Ÿ–ฑ๏ธ Mouse Controls

  • Drag nodes to reposition them
  • Scroll to zoom in/out
  • Click nodes to highlight connections
  • Hover for function details

โŒจ๏ธ Keyboard Shortcuts

  • Ctrl/Cmd + F - Toggle fullscreen
  • Ctrl/Cmd + 0 - Reset zoom
  • Ctrl/Cmd + 1 - Fit view to screen
  • T - Toggle sidebar
  • ESC - Exit fullscreen

๐ŸŽ›๏ธ UI Controls

  • ๐Ÿ” Fullscreen - Immersive full-screen mode
  • ๐Ÿ“ Fit View - Auto-zoom to fit all nodes
  • ๐Ÿ“‹ Toggle Sidebar - Show/hide function list
  • โ“ Help - Display help dialog

๐ŸŽจ Visual Guide

Node Colors

  • ๐ŸŸข Green - Low complexity (1-2)
  • ๐ŸŸ  Orange - Medium complexity (3-4)
  • ๐Ÿ”ด Red - High complexity (5+)

Node Sizes

  • Larger nodes = Higher complexity functions
  • Smaller nodes = Simpler functions

Connections

  • Arrows show function call dependencies
  • Hover to highlight connection paths

๐Ÿ“ Project Structure

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

๐Ÿ› ๏ธ Development

Adding Your Own Code

  1. Add files to test-code/ directory

    cp your-file.js test-code/
  2. Restart the server

    npm start
  3. Click "Load Data" to analyze your code

Running Tests

# Test the parser directly
npm run test

# Or use the CLI tool
node test-parser.js

Development Mode

# Auto-restart on changes
npm run dev

๐Ÿ”ง Configuration

Supported File Types

  • .js - JavaScript
  • .jsx - React JSX
  • .ts - TypeScript
  • .tsx - TypeScript JSX

Parser Features

  • โœ… Function declarations
  • โœ… Arrow functions
  • โœ… Class methods
  • โœ… Function calls (dependencies)
  • โœ… Cyclomatic complexity calculation
  • โœ… ES6+ syntax support

๐Ÿ“Š Technical Details

Built With

  • Frontend: HTML5, CSS3, D3.js v7
  • Backend: Node.js, Express
  • Parser: Babel AST parser
  • Visualization: Force-directed graph simulation

Key Dependencies

{
  "@babel/parser": "^7.23.0",
  "@babel/traverse": "^7.23.0", 
  "express": "^4.18.2",
  "d3": "^7.8.5"
}

๐ŸŽฏ Use Cases

  • ๐Ÿง‘โ€๐Ÿ’ป 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

๐Ÿšง Roadmap

v2.0 Planned Features

  • 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

๐Ÿค Contributing

We welcome contributions! Here's how to get started:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow existing code style
  • Add tests for new features
  • Update documentation
  • Test across different browsers

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • 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

๐Ÿ“ž Support


โญ If you find this project useful, please consider giving it a star on GitHub!

About

A visualization tool for JavaScript/TypeScript codebases.

Topics

Resources

License

Stars

Watchers

Forks