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.3.0.tar.gz (166.4 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.3.0-py3-none-any.whl (174.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: codebase_map-2.3.0.tar.gz
  • Upload date:
  • Size: 166.4 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.3.0.tar.gz
Algorithm Hash digest
SHA256 50c6ee475b71528fbc1c14214990d170ff2b2906594c6914f78a356d783f31fc
MD5 240818daac3a169a88b07ba0d66ff8cd
BLAKE2b-256 9cb9934e05466d5199bac77ab0d52a5050aa222bf5753dc3f4a6372523c99885

See more details on using hashes here.

File details

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

File metadata

  • Download URL: codebase_map-2.3.0-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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b51362070d2982517d56f81a571a88aed21f0ddb350b4ea0e0b2ee2d6956122e
MD5 ae81bf623373041e8bb23e3a82290bee
BLAKE2b-256 c95cbadba087085affa42a4e158f2f609013aeff0dbf14c8ebd9488794764c85

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