Skip to main content

A command-line tool for exploring and visualizing large Python codebases

Project description

idgi

A command-line tool for exploring and visualizing large Python codebases.

License Python

Installation

Install with uv

uv add idgi

Install with pip

pip install idgi

Prerequisites

  • Python 3.9 or higher

Optional: Graphviz for Visual Exports

For SVG/PNG export functionality, install Graphviz:

# macOS
brew install graphviz

# Ubuntu/Debian
sudo apt-get install graphviz

Install from Source (Development)

git clone https://github.com/your-username/idgi.git
cd idgi
uv sync

Getting Started

Once installed, you can start exploring any Python codebase:

# Analyze your project
idgi scan ./your_project

# Visualize dependencies
idgi graph --type imports ./your_project

# Search for specific code elements
idgi search "MyClass" ./your_project

Quick Start

1. Scan a Project

# Basic scan
idgi scan ./my_project

# Scan with exclusions
idgi scan ./my_project --exclude venv --exclude tests --exclude "*.pyc"

# Show detailed package breakdown
idgi scan ./my_project --show-packages --show-errors

2. Visualize Dependencies

# Show import dependencies as ASCII tree
idgi graph --type imports ./my_project

# Interactive exploration mode
idgi graph --type imports --interactive ./my_project

# Export to SVG
idgi graph --type imports --output dependencies.svg ./my_project

# Show class inheritance hierarchy
idgi graph --type inheritance --format hierarchy ./my_project

3. Search Code Elements

# Search for classes, functions, or modules
idgi search "DataLoader" ./my_project

# Limit results
idgi search "test" ./my_project --limit 20

4. Export Multiple Formats

# Export all graph types to multiple formats
idgi export ./my_project --output ./graphs --format svg --format json

# Export specific graph types
idgi export ./my_project --output ./graphs --types imports --types inheritance

Usage Guide

Commands

scan - Analyze Codebase Structure

Recursively scans a directory to analyze Python files and packages.

idgi scan [OPTIONS] DIRECTORY

Options:
  --exclude PATTERN          Exclude files/directories matching pattern
  --no-recursive             Don't scan recursively
  --show-packages            Show package breakdown
  --show-errors              Show parsing errors

Example Output:

┌─────────────────┬─────────┐
│ Metric          │ Count   │
├─────────────────┼─────────┤
│ Python files    │ 1,247   │
│ Total lines     │ 45,123  │
│ Packages        │ 23      │
│ Classes         │ 156     │
│ Functions       │ 489     │
│ Import statements│ 234    │
└─────────────────┴─────────┘

graph - Generate and Display Graphs

Creates various types of dependency and relationship graphs.

idgi graph [OPTIONS] DIRECTORY

Options:
  --type {imports,inheritance,calls,modules,classes,functions}
                             Type of graph to generate (default: imports)
  --format {tree,network,hierarchy}
                             Display format (default: network)
  --interactive, -i          Interactive exploration mode
  --output FILE              Export to file instead of displaying
  --max-nodes N              Maximum nodes to display
  --depth N                  Tree depth for tree format (default: 3)
  --stats                    Show graph statistics

Graph Types:

  • imports: Module dependency graph showing import relationships
  • inheritance: Class inheritance hierarchy
  • calls: Function call relationships
  • modules: High-level module overview
  • classes: Class-focused relationship graph
  • functions: Function and method relationships

search - Find Code Elements

Search for specific classes, functions, or modules by name.

idgi search [OPTIONS] TERM DIRECTORY

Options:
  --limit N                  Maximum results to show (default: 50)

export - Export Graphs to Files

Export multiple graph types to various file formats.

idgi export [OPTIONS] DIRECTORY

Options:
  --output DIR               Output directory (required)
  --format {svg,png,pdf,json,dot,gml,graphml}
                             Export formats (can be specified multiple times)
  --types {imports,inheritance,calls,modules,classes,functions}
                             Graph types to export

Supported Export Formats:

Format Description Use Case
SVG Scalable Vector Graphics Web display, documentation
PNG Portable Network Graphics Reports, presentations
PDF Portable Document Format Printing, formal documents
JSON Structured data Further analysis, web apps
DOT Graphviz source Custom styling, editing
GML Graph Modeling Language Academic research
GraphML XML-based graph format Tool interoperability

Interactive Mode

The interactive mode provides a terminal-based interface for exploring graphs:

idgi graph --type imports --interactive ./my_project

Interactive Commands:

Command Alias Description
show s Display current node details
neighbors n Show connected nodes
goto <node> g Navigate to specific node
back b Go back to previous node
search <term> f Search for nodes containing term
tree [depth] t Show tree view
path <target> p Find shortest path to target
bookmark <name> bm Manage bookmarks
stats Display graph statistics
help h Show all commands

Filtering and Exclusions

idgi automatically excludes common directories and files that are typically not relevant for code analysis:

Default Exclusions:

  • Python cache: __pycache__, *.pyc, *.pyo, *.pyd
  • Virtual environments: venv, env, .venv, virtualenv
  • Version control: .git, .svn, .hg
  • IDE files: .vscode, .idea, *.swp
  • Build artifacts: build, dist, *.egg-info

Custom Exclusions:

# Exclude additional patterns
idgi scan ./project --exclude tests --exclude "temp_*" --exclude docs

# Use regex patterns (wrap in forward slashes)
idgi scan ./project --exclude "/test.*\.py/"

Architecture Overview

idgi follows a modular architecture with clear separation of concerns:

idgi/
├── core/           # Core analysis functionality
│   ├── scanner.py  # Directory scanning and file discovery
│   ├── parser.py   # Python AST parsing
│   └── analyzer.py # High-level codebase analysis
├── graph/          # Graph generation and visualization
│   ├── builder.py  # NetworkX graph construction
│   ├── visualizer.py # ASCII and Graphviz rendering
│   └── interactive.py # Terminal-based exploration
├── export/         # Export functionality
│   └── formats.py  # Multi-format export support
├── utils/          # Utility modules
│   ├── filters.py  # Path filtering and exclusions
│   └── cache.py    # Performance caching
└── cli.py          # Command-line interface

Performance Tips:

# Increase worker processes for large projects
idgi scan ./huge_project --workers 8

# Limit graph size for better performance
idgi graph --type imports --max-nodes 100 ./project

# Cache results by avoiding frequent exclusion changes
idgi scan ./project  # Results cached for next run

Examples

Analyzing a Django Project

# Scan Django project excluding common non-code directories
idgi scan ./myproject --exclude venv --exclude static --exclude media

# Show model inheritance hierarchy
idgi graph --type inheritance ./myproject --format hierarchy

# Find all views
idgi search "View" ./myproject --limit 30

# Export comprehensive analysis
idgi export ./myproject --output ./analysis \
  --format svg --format json --types imports --types inheritance --types calls

Large Codebase Analysis

# Scan with performance optimizations
idgi scan ./large_project --workers 8 --exclude "test_*"

# Interactive exploration starting with imports
idgi graph --type imports --interactive ./large_project --max-nodes 200

# Export key relationships only
idgi export ./large_project --output ./docs \
  --types imports --types modules --format svg

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

idgi-0.1.0.tar.gz (92.6 kB view details)

Uploaded Source

Built Distribution

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

idgi-0.1.0-py3-none-any.whl (42.2 kB view details)

Uploaded Python 3

File details

Details for the file idgi-0.1.0.tar.gz.

File metadata

  • Download URL: idgi-0.1.0.tar.gz
  • Upload date:
  • Size: 92.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for idgi-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5e728a9547d274e4d727ca985ec20c431107e30856427c25be2cf3794fcb8e74
MD5 0569d1ed6be15e33da2d69095e4aacbf
BLAKE2b-256 357da1344458c71b2a115e56b96f46e6cf799232734804feb3ff7402793a31af

See more details on using hashes here.

Provenance

The following attestation bundles were made for idgi-0.1.0.tar.gz:

Publisher: publish.yml on kokkodev/idgi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file idgi-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: idgi-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 42.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for idgi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1fff929f4349931bb10cbedd8d392354f37c9d3b7c40f8492febab4179848560
MD5 8964ceb86180a3cb2daef2853bf84d15
BLAKE2b-256 a981f5e443cf6fa6559e37327f6d1b1d3c20504d1bfc36d7747caa5beb81a755

See more details on using hashes here.

Provenance

The following attestation bundles were made for idgi-0.1.0-py3-none-any.whl:

Publisher: publish.yml on kokkodev/idgi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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