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.2.0.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.2.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: codegraph_cli_ai-0.2.0.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.2.0.tar.gz
Algorithm Hash digest
SHA256 db2a38b08bfdd3b2066e9dac4efefa4208c774b22213210cefac4afd29d02ab8
MD5 b86b76d0aa6dec946e0fe2b7b6bd3ace
BLAKE2b-256 542a971aea1eb2b04e40a47fa51a418fbfae3f679e27acda04b08df4a34e1bf3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for codegraph_cli_ai-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f810e71ec28ddffa4f39cd3361406cb27df60f350b4accd14e7f0cc4e55249dd
MD5 78877380c71b9c3e63d97a7980eb030d
BLAKE2b-256 463bbfe0bb65ca4ef9fc325fbc0e3f533502cfe082aff026f414338194750fb1

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