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

Uploaded Python 3

File details

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

File metadata

  • Download URL: codegraph_cli_ai-0.1.9.tar.gz
  • Upload date:
  • Size: 12.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.9.tar.gz
Algorithm Hash digest
SHA256 815eb2eba496c8a05bed00163b8d82e80c8c4080440a51338e14b0c306d8fe28
MD5 62057497ada6f7f0785dd01acfc68774
BLAKE2b-256 5453b12d78bda36dd6dd30926e7d98fef43faa9499df41548fceabf05fab30d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for codegraph_cli_ai-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 fa37d135fda174bda4f07e51ff1dca2b2da67886ebc3eef45d14e669eb7d7b34
MD5 66cb599ec559ec3704a8dee678cff9d7
BLAKE2b-256 26c15e4cdcba04ea652690cc48ceae036fa2cc03678a2fdacfd18c4b56213f60

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