Local Python code analysis tool - understand architecture, dependencies, and call graphs
Project description
CodeMap
CodeMap is a pure local developer tool that analyzes Python codebases and provides:
- ๐ Architecture Analysis - Understand code structure, dependencies, and call graphs
- ๐ฆบ Call Graph Extraction - Trace function/method calls across your codebase
- โ ๏ธ Risk Analysis - Identify complex code patterns and potential issues
- ๐ Symbol Indexing - Search and explore functions, classes, and methods
- ๐ Local Web Dashboard - Visual code analysis interface
- ๐ Privacy First - All analysis runs locally, no data leaves your machine
Requirements
- Python 3.10+
- pip (Python package manager)
- ~5 minutes to get started
Quick Start (3 Steps)
Step 1๏ธโฃ: Install CodeMap
# Install from PyPI (easiest)
pip install codemap-python
Verify installation:
codemap --help
You should see:
usage: codemap [-h] {analyze,dashboard,open,cache} ...
For developers: To modify source code or contribute, clone the repository:
git clone https://github.com/ADITYA-kus/codemap_ai.git cd codemap_ai pip install -e .
Step 2๏ธโฃ: Analyze Your First Repository
IMPORTANT: The analyze command REQUIRES the --path argument pointing to a directory!
# Analyze the demo repo (takes 5-10 seconds)
codemap analyze --path demo_repo
Output: JSON analysis data
{
"ok": true,
"cache_dir": ".codemap_cache/...",
"analysis_version": "2.2",
"repo_dir": "demo_repo"
}
Analyze your own Python project:
codemap analyze --path /path/to/your/python/project
Analyze a GitHub repository:
codemap analyze --github https://github.com/owner/repo
Step 3๏ธโฃ: View in Web Dashboard
# Start the web dashboard
codemap dashboard --port 8000
Open in browser:
http://127.0.0.1:8000
You'll see:
- List of analyzed repositories
- Call graphs
- Architecture metrics
- Risk analysis
- Symbol search
Common Commands
Analyze Commands
# โ ๏ธ REQUIRED: Analyze needs --path argument!
# Analyze a local repository
codemap analyze --path <repo_directory>
# Analyze a GitHub repository (public)
codemap analyze --github https://github.com/owner/repo
# Analyze private GitHub repo (requires token)
codemap analyze --github https://github.com/owner/private-repo --token YOUR_GITHUB_TOKEN
# Force rebuild analysis (ignore cache)
codemap analyze --path <repo_directory> --rebuild
# Use API for detailed JSON output
codemap api analyze --path <repo_directory>
Dashboard Commands
# Start web dashboard (default: localhost:8000)
codemap dashboard --port 8000
# Start dashboard with auto-reload (development)
codemap dashboard --port 8000 --reload
# Open dashboard in browser
codemap open --port 8000
Cache Management
# ๐ List all analyzed repositories and their cache info
codemap cache list
# ๐ Show detailed cache information for a specific repository
codemap cache info --path <repo_directory>
# โฑ๏ธ Set cache retention policy (automatically clean old caches)
codemap cache retention --path <repo_directory> --days 30 --yes
# ๐งน Preview what would be cleaned (safe, no deletion)
codemap cache sweep --dry-run
# ๐งน Actually clean up expired caches (requires --yes confirmation)
codemap cache sweep --yes
# ๐๏ธ Clear cache for a specific repository (preview first)
codemap cache clear --path <repo_directory> --dry-run
# ๐๏ธ Actually delete a repository's cache (requires --yes confirmation)
codemap cache clear --path <repo_directory> --yes
Cache Management Tips:
- โ
Always use
--dry-runfirst to preview changes - โ
Add
--yesflag to skip confirmation (useful in scripts) - โ
Default retention is 14 days; adjust with
--days <number> - โ
Cache is stored in:
~/.codemap_cache/(varies by OS) - โ
Use
cache listto see all cached repositories and their sizes
Get GitHub Token (for private repos):
- Go to https://github.com/settings/tokens
- Click "Generate new token" โ "Generate new token (classic)"
- Give it a name (e.g., "CodeMap")
- Select
reposcope (full control of private repos) - Copy the token and save it somewhere safe
- Use in commands:
--token ghp_xxxxx
Or pass token via stdin (more secure):
echo "YOUR_TOKEN" | codemap analyze --github https://github.com/owner/repo --token-stdin
Directory Structure
This is the source code structure for developers. If you installed via pip, these files are automatically installed in your Python environment.
codemap_ai/ (source code)
โโโ README.md # This file
โโโ cli.py # Command-line interface
โโโ security_utils.py # Security & secret redaction
โโโ pyproject.toml # Package configuration
โโโ analysis/ # Code analysis engine
โ โโโ core/ # AST parsing, imports
โ โโโ call_graph/ # Call graph building
โ โโโ explain/ # Symbol metadata
โ โโโ architecture/ # Dependency analysis
โ โโโ graph/ # Graph indexing
โโโ ui/ # Web dashboard
โ โโโ app.py # FastAPI server
โ โโโ templates/ # HTML templates
โ โโโ static/ # CSS, JavaScript
โโโ tests/ # Test suite
โโโ demo_repo/ # Example repository
Features Explained
๐ Symbol Search
Find all functions, classes, and methods in your codebase:
codemap api search --path <repo_path> --query "MyClass"
codemap api search --path <repo_path> --query "function_name"
๐ Call Graph
Understand how functions call each other:
codemap api explain --path <repo_path> --symbol "module.ClassName.method"
โ ๏ธ Risk Radar
Detect complex code patterns and potential issues:
codemap api risk_radar --path <repo_path>
๐ Impact Analysis
See which files/functions are affected by changes:
codemap api impact --path <repo_path> --target "module.function"
Privacy & Security
โ 100% Local
- All analysis happens on your machine
- No data sent to external servers
- .env files and secrets are never exposed
โ Secure Cache
- Analysis results cached locally
- Cache auto-cleared after 14 days (configurable)
- No credentials stored
โ Secret Redaction
- API keys automatically masked in output
- GitHub tokens never logged
- Safe error messages
Example Workflow
Local Project Analysis
# 1. Navigate to your Python project
cd C:\Users\YourName\my_python_project
# 2. Analyze it with CodeMap
codemap analyze --path .
# โ
Analysis complete! Results cached locally
# 3. Start the web dashboard
codemap dashboard --port 8000
# โ
Dashboard running at http://127.0.0.1:8000
# 4. Open in browser
codemap open --port 8000
# 5. Explore in browser:
# - View all repositories
# - See call graphs
# - Check architecture metrics
# - View risk analysis
# 6. Search for a specific class
codemap api search --path . --query "MyClass"
# 7. Check call graph for a function
codemap api explain --path . --symbol "mymodule.MyClass.method"
GitHub Repository Analysis
# 1. Analyze a public GitHub repo
codemap analyze --github https://github.com/owner/awesome-project
# โ
Downloaded and analyzed
# 2. View in dashboard
codemap dashboard --port 8000
codemap open --port 8000
# 3. Clean up old repos
codemap cache list # See all cached repos
codemap cache sweep # Auto-cleanup old ones
Next Steps
-
๐ฏ First analysis - Try the demo:
codemap analyze --path demo_repo
-
๐ View results - Open the dashboard:
codemap dashboard --port 8000
-
๐ Analyze your code - Point to your project:
codemap analyze --path ~/my-project
-
๐ Try GitHub - Analyze public repos:
codemap analyze --github https://github.com/owner/repo
-
๐ Advanced features - Explore search, impact, risk analysis:
codemap api search --path . --query "YourClass"
Quick Reference
# Installation
pip install -e .
# Most common commands
codemap analyze --path <directory> # Analyze local repo
codemap analyze --github <url> # Analyze GitHub repo
codemap dashboard --port 8000 # Start dashboard
codemap open --port 8000 # Open in browser
codemap cache list # List all analyses
codemap cache clear <hash> # Delete one analysis
Support & Help
โ Run without arguments to see all available commands:
codemap --help
codemap analyze --help
codemap dashboard --help
codemap api --help
โ Check requirements:
python --version # Should be 3.10+
pip --version # Should be installed
git --version # For GitHub repos
โ Verify repo path:
# Make sure your repo has Python files
dir <your_repo> # Windows
ls <your_repo> # Linux/Mac
find <your_repo> -name "*.py" # Find Python files
Happy coding! ๐
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codemap_python-0.1.5.tar.gz.
File metadata
- Download URL: codemap_python-0.1.5.tar.gz
- Upload date:
- Size: 113.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a99e9117360a7124b8ff3f24478a71ac8f2ac6b49b33d52eab246fedc8ec47db
|
|
| MD5 |
4bfcf641cf817ac1b208bbe3611af553
|
|
| BLAKE2b-256 |
aabf20252332f744d57f4c1bdd2f29bdf23702720b9f2e6651973c2243b5b89f
|
File details
Details for the file codemap_python-0.1.5-py3-none-any.whl.
File metadata
- Download URL: codemap_python-0.1.5-py3-none-any.whl
- Upload date:
- Size: 116.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d34801e53e58b0ac93d3cbd3af1e23c2ce336eab7cacf87c73d59c475cb4676
|
|
| MD5 |
29ecba961f8a36ac3c15fd2ad7ff4361
|
|
| BLAKE2b-256 |
15334d467e668fbd268c64b0e65e3b4ccefe4e104d4e30f9ab31cefedc1b460a
|