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

Uploaded Python 3

File details

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

File metadata

  • Download URL: codegraph_cli_ai-0.1.7.tar.gz
  • Upload date:
  • Size: 11.4 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.7.tar.gz
Algorithm Hash digest
SHA256 84c91d0351f0817f32f71f70afe4847474f58ce97228b89ae7ace08d5007b21e
MD5 a65b3f5ddf6753581d848c9876b2f252
BLAKE2b-256 8eed1b972deaf7d0bc8448da7d2f70b5bb335c178d653329baac808c7f360eb1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for codegraph_cli_ai-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 8bf0105f8071b6ed3250c5771bad23ef6e263a08e71ac67bf424de8ec8057aa2
MD5 abc6da9cebc2bfccfb2e9abf8bb21f37
BLAKE2b-256 8585e813e5177bc74ae48b16757c43aeb8c341662e421eed3503cc59fb493b4c

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