Skip to main content

Function dependency graph generator for Python and TypeScript — works great with Claude Code.

Project description

Codebase Map

Standalone function dependency graph generator for Python (and TypeScript) projects. Output: interactive HTML + JSON. 100% offline · zero CDN. License: MIT · Version: 2.2.0

Parse your codebase into a function dependency graph (nodes = functions/classes, edges = call relationships). Foundation for understanding large codebases, PR impact analysis, and dual-snapshot diff.


Install

From PyPI (recommended for v2.2.1+):

pipx install codebase-map     # Isolated install (recommended)
# or
pip install codebase-map

From source (latest main):

pipx install "git+https://github.com/hypercommerce-vn/codebase-map.git"

For development:

git clone git@github.com:hypercommerce-vn/codebase-map.git
cd codebase-map
pip install -e ".[dev]"

Verify:

codebase-map --version

Quick Start

1. Create config at project root

# codebase-map.yaml
project: "my-app"
sources:
  - path: "app"
    language: python
    base_module: "app"
    exclude: ["__pycache__", "migrations"]
output:
  dir: "docs/function-map"
  formats: [json, html]
graph:
  depth: 3
  group_by: module

2. Generate graph

codebase-map generate -c codebase-map.yaml

Output: docs/function-map/graph.json + interactive index.html.

3. Query the graph

codebase-map summary -f docs/function-map/graph.json
codebase-map query "CustomerService" -f docs/function-map/graph.json
codebase-map impact "AuthService" -f docs/function-map/graph.json
codebase-map search "create" -f docs/function-map/graph.json

4. Dual-snapshot diff (v2.2)

# Create baseline
codebase-map generate --label "baseline"

# ... make changes ...

codebase-map generate --label "post-dev"
codebase-map snapshot-diff --baseline baseline --current post-dev --format markdown

Commands

Command Purpose
generate Generate function dependency graph
query Look up function/class details
impact Show impact zone for a node
search Search nodes by keyword
summary Graph statistics
diff Git diff impact analysis
snapshot-diff Dual-snapshot structural diff (v2.2)
snapshots Manage snapshots (list/clean)
api-catalog List API routes
coverage Overlay test coverage
check-staleness Check graph freshness

All commands support --help for detailed options.


Features

🔍 Graph Generation

  • Python AST parser (classes, functions, methods, decorators)
  • Layer classification (route / service / model / util / schema / test)
  • Domain clustering (by module path)
  • Call graph edges + import edges
  • JSON + interactive HTML output

📊 Dual-Snapshot Diff (v2.2)

  • Compare two graph snapshots (before/after)
  • Added / removed / modified / renamed functions
  • Affected callers (transitive, 1-3 levels)
  • Rename detection via signature matching
  • Output formats: markdown (PR body), JSON (CI), text (terminal)

🎨 Interactive HTML

  • D3.js force-directed graph (bundled, offline)
  • Sidebar tree, minimap, toolbar
  • Executive view, PR Diff view, API Catalog
  • Multi-view tabs, breadcrumb navigation
  • Business Flow mapping

⚙️ CI Integration

  • cbm-baseline.yml — auto-baseline on merge to main
  • cbm-post-merge.yml — rotate baseline after PR merge
  • cbm-pr-impact.yml — post PR Impact comment (dual-snapshot)

Architecture

Source Code (Python/TS)
    ↓
  [AST Parser]
    ↓
  [Graph Builder]  → Nodes + Edges + Metadata
    ↓
  [Exporters]      → JSON + HTML (D3.js)
    ↓
  [Query Engine]   → summary, impact, search, query
    ↓
  [Snapshot Diff]  → add/remove/modify/rename + affected callers

CBM is stateless: every command takes graph.json as input. No database, no state.


Use Cases

Before modifying a function

codebase-map impact "CustomerService.create" -f graph.json
# Shows all callers — know blast radius before refactoring

In PR description

codebase-map snapshot-diff --baseline main --current feature-branch --format markdown
# Copy-paste into PR body — reviewers see structural impact

CI auto-comment

Installed workflows post impact analysis on every PR automatically.

Understand a new codebase

codebase-map summary -f graph.json       # How big is it?
codebase-map api-catalog -f graph.json    # What APIs exist?
codebase-map query "main" -f graph.json   # Where's the entry point?

Sister Project: Knowledge AI Platform

Want AI-powered Q&A on your codebase? Check out Knowledge AI Platform — adds multi-LLM RAG, MCP server, and onboarding report generator on top of CBM data.


Development

# Install
pip install -e ".[dev]"

# Test
pytest tests/ -q

# Lint
black --check codebase_map/ tests/
isort --check codebase_map/ tests/
flake8 codebase_map/ tests/

# Generate on self
codebase-map generate -c codebase-map-self.yaml

License

MIT — see LICENSE file.


Credits

Built by Hyper Commerce for internal use, open-sourced for the community.


Version 2.2.0 · Published 2026-04-16

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

codebase_map-2.2.1.tar.gz (166.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codebase_map-2.2.1-py3-none-any.whl (174.1 kB view details)

Uploaded Python 3

File details

Details for the file codebase_map-2.2.1.tar.gz.

File metadata

  • Download URL: codebase_map-2.2.1.tar.gz
  • Upload date:
  • Size: 166.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for codebase_map-2.2.1.tar.gz
Algorithm Hash digest
SHA256 463d15c7ae672641676ca386702a76c8d94d8f0527048ff3f779be64d0a5d33f
MD5 ba533fefbb01a8f8ecd3534626a0cf6a
BLAKE2b-256 7d5aad98368c30ef4721fb7f255ba43653a26e69a07ab3b95d36f386bcbef327

See more details on using hashes here.

File details

Details for the file codebase_map-2.2.1-py3-none-any.whl.

File metadata

  • Download URL: codebase_map-2.2.1-py3-none-any.whl
  • Upload date:
  • Size: 174.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for codebase_map-2.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 26b3e1321b4d0d1c0d2c8c2e4725ed6a54de6f596293fa64d9d3fdf643b0320b
MD5 a271e1cae53065c4d0d928dbe7ae5720
BLAKE2b-256 3054641ee6175f4d6ea5a93cfe6c2472fb26e2d2e853783d2e30c6899ed02d84

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page