A powerful CLI tool with an interactive web interface to analyze React component trees, relationships, and architecture patterns. Store multiple analysis runs in SQLite and visualize your React application structure with beautiful interactive graphs.
- ๐ณ Component Tree Visualization - See your component hierarchy at a glance
- ๐ Relationship Analysis - Track how components interact with each other
- ๐ช Hooks Detection - Analyze React hooks usage patterns
- ๐ Props Analysis - Understand component interfaces and prop flow
- โก Fast AST Parsing - Powered by Babel for accurate code analysis
- ๐พ SQLite Database - Persistent storage for multiple analysis runs
- ๐ Historical Tracking - Compare analyses over time
- ๐ Run Management - View and switch between different analysis runs
- ๐ Web-Based Dashboard - Beautiful, responsive interface
- ๐ฑ Three View Modes:
- List View - Paginated component table with search
- Hierarchy View - Collapsible component tree with usage counts
- Graph View - Interactive D3.js force-directed network visualization
- ๐จ Interactive Features:
- Zoom controls (+, -, reset)
- Fullscreen mode
- Drag-and-drop nodes
- Hover tooltips
- Click for component details
- URL-based state management
# Clone the repository
git clone https://github.com/mohmed98/react-analyzer.git
cd react-analyzer
# Install dependencies
npm install# 1. Analyze your React project
node bin/cli.js analyze -d /path/to/your/react/project --include-props --include-hooks
# 2. Start the web viewer
node bin/cli.js serve
# 3. Open your browser
# Visit http://localhost:3000Scan your React codebase and store analysis results in the database.
node bin/cli.js analyze [options]Options:
-d, --dir <directory>- Directory to analyze (default: ./src)--include-props- Include detailed prop analysis--include-hooks- Include React hooks analysis
Examples:
# Analyze current project
node bin/cli.js analyze --include-props --include-hooks
# Analyze specific directory
node bin/cli.js analyze -d /path/to/react/app/src --include-props --include-hooks
# Quick analysis without extras
node bin/cli.js analyze -d ./componentsLaunch the interactive web interface to explore analysis results.
node bin/cli.js serve [options]Options:
-p, --port <port>- Port to run the server on (default: 3000)
Examples:
# Default port (3000)
node bin/cli.js serve
# Custom port
node bin/cli.js serve -p 8080- Paginated Table - Browse components 50 at a time
- Component Details - Click any component to see full details
- File Paths - Hidden by default, shown in modal
- Props & Hooks - View all props and hooks used
- Tree Structure - Visual parent-child relationships
- Collapsible Nodes - Expand/collapse component trees
- Usage Counts - See how many times components are used (e.g., "Button (ร5)")
- Smart Limits - Show 50, 100, 200, 500, or all components
- Auto-Collapse - Large datasets start collapsed for performance
The most powerful view for understanding architecture!
Features:
- Force-Directed Layout - Components automatically arrange based on relationships
- Interactive Nodes:
- ๐ฃ Purple nodes - Root components (not used by others)
- ๐ข Green nodes - Used components
- Size - Bigger nodes = more usage
- Controls:
- + / - - Zoom in/out buttons
- โ - Reset zoom to center
- โถ - Fullscreen mode (true fullscreen!)
- Mouse wheel - Smooth zoom
- Drag - Rearrange nodes
- Pan - Click empty space and drag
- Interactions:
- Hover - Show component name and usage count
- Click node - Open detailed component modal
- Live animation - Watch the graph settle into optimal layout
Perfect for:
- ๐ Finding central/hub components
- ๐๏ธ Understanding architecture patterns
- ๐ Visualizing complex relationships
- ๐ Presenting to teams
Analysis data is stored in react-analysis.db with three tables:
- Multiple analysis runs with timestamps
- Summary statistics
- Project metadata
- Component details (name, file path)
- Props and hooks (JSON)
- Linked to analysis run
- Component usage relationships
- Parent-child connections
- Enables hierarchy and graph views
# Morning: Analyze current state
node bin/cli.js analyze -d ./src --include-props --include-hooks
# Throughout day: View in browser
node bin/cli.js serve
# Browse to http://localhost:3000
# - Check hierarchy view for new components
# - Use graph view to understand impacts
# - Compare with previous runs# Before review: Analyze feature branch
node bin/cli.js analyze -d ./src --include-props --include-hooks
# During review: Use web viewer
node bin/cli.js serve
# - List view: Find specific components
# - Hierarchy view: See new component relationships
# - Graph view: Visualize architecture changes# Initial analysis
node bin/cli.js analyze -d /path/to/large/app --include-props --include-hooks
# Start viewer
node bin/cli.js serve
# In Graph View:
# 1. Start with 50 components to see core structure
# 2. Identify central hubs (big green nodes)
# 3. Gradually increase to 100, 200 for full picture
# 4. Use fullscreen mode for better visibility
# 5. Click nodes to understand component detailsPerfect for presentations and architecture discussions:
- See entire component network
- Identify tightly coupled areas
- Find reusable components (big green nodes)
- Spot orphaned components (purple nodes)
- Collapsible tree structure
- Usage counts show component reusability
- Great for understanding parent-child flows
- Traditional table format
- Quick searching and filtering
- Pagination for large apps
- Identify central hub components
- Find tightly coupled areas
- Spot architectural anti-patterns
- Plan refactoring strategies
- Share analysis runs via database
- Present architecture in fullscreen graph mode
- Onboard new developers visually
- Document component relationships
- Generate visual component maps
- Track architecture evolution over time
- Compare different analysis runs
- Export findings for documentation
- Identify most-used components for optimization
- Understand impact before making changes
- Track relationship changes over time
- Plan component extraction safely
Add to your package.json:
{
"scripts": {
"analyze": "node ./react-analyzer/bin/cli.js analyze --include-props --include-hooks",
"analyze:dir": "node ./react-analyzer/bin/cli.js analyze -d",
"viewer": "node ./react-analyzer/bin/cli.js serve",
"viewer:custom": "node ./react-analyzer/bin/cli.js serve -p 8080"
}
}#!/bin/bash
# .git/hooks/pre-commit
echo "Analyzing React components..."
node ./react-analyzer/bin/cli.js analyze --include-props --include-hooks# .github/workflows/analyze.yml
name: React Architecture Analysis
on: [push, pull_request]
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install React Analyzer
run: |
git clone https://github.com/mohmed98/react-analyzer.git
cd react-analyzer && npm install
- name: Run Analysis
run: |
node react-analyzer/bin/cli.js analyze -d ./src --include-props --include-hooks
- name: Upload Database
uses: actions/upload-artifact@v4
with:
name: analysis-results
path: react-analysis.db# Analyze different projects
node bin/cli.js analyze -d ~/projects/project-a/src --include-props --include-hooks
node bin/cli.js analyze -d ~/projects/project-b/src --include-props --include-hooks
# All runs stored in same database
node bin/cli.js serve
# Switch between runs in the web interface# Run on different port to avoid conflicts
node bin/cli.js serve -p 4000
# Multiple instances for different projects
node bin/cli.js serve -p 3000 # Project A
node bin/cli.js serve -p 3001 # Project B- Node.js - Runtime environment
- Express.js - Web server framework
- better-sqlite3 - Fast SQLite database driver
- Babel - JavaScript AST parsing
- Commander.js - CLI interface
- Vanilla JavaScript - No framework overhead
- D3.js - Force-directed graph visualization
- Modern CSS - Flexbox, Grid, responsive design
- HTML5 - Semantic markup
# Error: Port 3000 is already in use
# Solution: Use a different port
node bin/cli.js serve -p 8080# Error: Database is locked
# Solution: Stop any running server instances
# Check: ps aux | grep "node bin/cli.js serve"
# Kill: kill -9 <process_id>- Ensure directory has React files (.jsx, .tsx, .js)
- Check component naming (must be PascalCase)
- Verify JSX syntax is valid
- Try analyzing parent directory
- Start with 50 components for large apps
- Use fullscreen mode for better performance
- Collapse unused branches in hierarchy view
- Consider analyzing subdirectories separately
Contributions are welcome! Areas for improvement:
- Search/filter components in web viewer
- Export analysis as JSON/CSV
- Compare different analysis runs visually
- Dark mode toggle
- Component complexity metrics
- Performance profiling integration
- TypeScript type analysis
- Custom styling for graph nodes
- Share analysis runs via URL
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'feat: Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Babel for AST parsing
- Visualizations powered by D3.js
- CLI interface built with Commander.js
- Database powered by better-sqlite3
- Server built with Express.js
-
Interactive web dashboardโ Complete! -
SQLite persistent storageโ Complete! -
Multiple view modesโ Complete! -
D3.js graph visualizationโ Complete! - Search and filter components
- Export to various formats
- Compare analysis runs
- Performance metrics
- Dark mode
- VS Code extension
- Team collaboration features
- Real-time analysis mode
Made with โค๏ธ for the React community
If this tool helps you understand your React applications better, please give it a โญ!
# Try it with your project in 3 commands:
git clone https://github.com/mohmed98/react-analyzer.git
cd react-analyzer && npm install
node bin/cli.js analyze -d /path/to/your/react/app --include-props --include-hooks && node bin/cli.js serveThen open http://localhost:3000 and switch to Graph View with Fullscreen mode for the best experience! ๐