Skip to main content

CLI tool to analyze codebases and visualize knowledge graphs using AST

Project description

CodeGraph AI

CodeGraph AI is a CLI tool that analyzes your Python codebase and visualizes it as an interactive knowledge graph.

It helps developers understand:

  • Code structure
  • Function call relationships
  • File dependencies
  • Overall architecture

Features

  • AST-based parsing of Python code
  • Function call graph generation
  • Dependency graph (imports)
  • Interactive visualization in browser
  • Focus on specific files
  • Hide external libraries (stdlib & third-party)
  • Fast CLI-based workflow

Installation

pip install codegraph-ai

Quick Start

codegraph index
codegraph plot

Commands

1. Index your codebase

Scan and build the graph:

codegraph index

Index a specific folder:

codegraph index path/to/your/project

2. Visualize the graph

codegraph plot

This opens an interactive graph in your browser.


Advanced Usage

Hide external libraries

Removes standard library and third-party dependencies from the graph:

codegraph plot --hide-external

Focus on a specific file

Shows only a file and its direct relationships:

codegraph plot --focus cli.py

Filter by node type

Show only certain types of nodes:

codegraph plot --level file
codegraph plot --level function
codegraph plot --level class

Filter by edge type

Show only specific relationships:

codegraph plot --edge-type calls
codegraph plot --edge-type imports
codegraph plot --edge-type contains
codegraph plot --edge-type all

Combine filters

codegraph plot --focus cli.py --hide-external --edge-type calls

How It Works

  1. Parses Python files using AST

  2. Extracts:

    • Functions
    • Classes
    • Imports
    • Function calls
  3. Builds a directed knowledge graph

  4. Renders it as an interactive visualization


Graph Semantics

Node Types

Type Description
File Python file
Function Function or method
Class Class definition
Module External dependency

Edge Types

Relation Meaning
contains File/Class contains function
calls Function calls another function
imports File imports module
defined_in Function belongs to file

Output Files

After indexing:

.codegraph/graph.json

After visualization:

graph.html

Example Workflow

codegraph index
codegraph plot --hide-external

Use Cases

  • Understand large codebases quickly
  • Visualize architecture
  • Debug dependencies
  • Explore function interactions
  • Prepare for refactoring

Author

Aditya Jogdand


License

MIT License

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

codegraph_cli_ai-0.1.8.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

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

codegraph_cli_ai-0.1.8-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file codegraph_cli_ai-0.1.8.tar.gz.

File metadata

  • Download URL: codegraph_cli_ai-0.1.8.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for codegraph_cli_ai-0.1.8.tar.gz
Algorithm Hash digest
SHA256 b1690f1808d512273f9a88262c49447763d2c07dd65b6d9da4fef87226ec7340
MD5 925434590061cbc6d0647832c74756d4
BLAKE2b-256 141df66e71297c4c8a721b5c1019335fbeaf9af975a9a78a6beff2f3fe1df535

See more details on using hashes here.

File details

Details for the file codegraph_cli_ai-0.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for codegraph_cli_ai-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 aced6c40fc85a32b5d32b944650da38c45c46dc0e4e95b51a978b3807362208d
MD5 25079657d67ef50bcefbbbed75438472
BLAKE2b-256 4b41f067987b38e94e8e9d40357df0523854f87c600ebf75087c03215df4b856

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