Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyPI version Python versions License: MIT COSMIC Ecosystem

graphify

Codebase knowledge graph tool. Graphify turns any folder of code into a queryable knowledge graph using tree-sitter AST extraction, Leiden community detection, and graph querying.

graphify .

Output:

graphify-out/
├── graph.html         interactive graph in your browser
├── GRAPH_REPORT.md    key concepts, connections, suggested questions
├── graph.json         full graph — query without re-reading files
└── .graphify_labels.json  community names

Features

  • 36+ language grammars via tree-sitter — Python, TypeScript, Rust, Go, Java, C++, Kotlin, Scala, Ruby, Swift, PHP, Lua, Zig, and more
  • Leiden community detection — discover module groupings and cross-module dependencies
  • 9+ LLM backends — Claude, Gemini, Kimi, OpenAI, Ollama (local), DeepSeek, Azure, Bedrock, Claude-CLI
  • Query the graphgraphify query "how does auth work?", graphify path "Parser" "AST", graphify explain "DatabasePool"
  • Multiple export formats — HTML, SVG, JSON, GraphML, Obsidian vault, Markdown wiki, Neo4j Cypher
  • MCP server — expose the graph as tool-callable MCP server with 10 query tools and 6 resources
  • 20+ AI assistant integrations — Claude Code, Gemini CLI, Codex, Cursor, Copilot, Aider, Devin, Kiro, and more
  • Headless extractiongraphify extract ./src for CI pipelines (no IDE needed)
  • Incremental updatesgraphify update ./src re-extracts only changed files
  • PR impact analysis — see which communities a PR touches and its blast radius
  • Git hooks — graph auto-rebuilds on commit
  • Entity deduplication — MinHash/LSH blocking + Jaro-Winkler fuzzy matching + union-find merge
  • Privacy — AST extraction is fully local, no telemetry

Install

# Recommended
uv tool install graphifyy

# Alternatives
pipx install graphifyy
pip install graphifyy

Optional extras

pip install "graphifyy[pdf]"           # PDF support
pip install "graphifyy[office]"        # Word/Excel support
pip install "graphifyy[video]"         # Video transcription
pip install "graphifyy[mcp]"           # MCP server (stdio + HTTP)
pip install "graphifyy[neo4j]"         # Neo4j export
pip install "graphifyy[svg]"           # SVG export
pip install "graphifyy[leiden]"        # Leiden community detection
pip install "graphifyy[ollama]"        # Ollama local LLM
pip install "graphifyy[all]"           # everything

Quick start

# 1. Install
uv tool install graphifyy

# 2. Set up your AI assistant
graphify install

# 3. Build the knowledge graph
graphify .

# 4. Query it
graphify query "how does the authentication system work?"
graphify path "UserService" "DatabasePool"
graphify explain "RequestHandler"

Commands

Command Description
graphify . Build graph for current folder (AST + LLM extraction)
graphify extract <path> Full extraction pipeline
graphify extract <path> --backend gemini Use specific LLM backend
graphify update <path> Incremental re-extraction (AST only, no API cost)
graphify cluster-only <path> Rerun clustering and generate report
graphify query "<question>" Search the graph (BFS/DFS)
graphify path "<A>" "<B>" Shortest path between two concepts
graphify explain "<concept>" Explain a node and its neighbors
graphify affected "<node>" Impact analysis for a node
graphify serve [graph.json] Start MCP server (stdio or HTTP)
graphify prs PR dashboard with graph impact analysis
graphify hook install Auto-rebuild graph on git commit
graphify install Install skill for your AI coding assistant
graphify provider add Add a custom LLM provider

LLM backends

Backend Env var Default model Notes
Claude ANTHROPIC_API_KEY claude-sonnet-4-6
Gemini GEMINI_API_KEY / GOOGLE_API_KEY gemini-3-flash-preview
Kimi MOONSHOT_API_KEY kimi-k2.6
OpenAI OPENAI_API_KEY gpt-4.1-mini
Ollama OLLAMA_BASE_URL qwen2.5-coder:7b Local, free
DeepSeek DEEPSEEK_API_KEY deepseek-v4-flash
Azure AZURE_OPENAI_API_KEY gpt-4o
Bedrock AWS_PROFILE / AWS_REGION claude-3-5-sonnet
Claude CLI (uses claude on PATH) claude-code-plan Uses your Pro/Max sub

MCP server

Graphify serves as an MCP server with these tools:

  • query_graph — Search with BFS or DFS, configurable depth and token budget
  • get_node — Full details for a specific node
  • get_community — All nodes in a community
  • god_nodes — Most connected nodes in the graph
  • graph_stats — Node/edge/community counts
  • shortest_path — Path between two concepts
  • list_prs — Open PRs with CI status and graph impact
  • get_pr_impact — Detailed graph impact for a specific PR
  • triage_prs — Actionable PRs ranked by merge risk

HTTP transport (shared server)

graphify-mcp serve graph.json --transport http --port 8080 --api-key MY_SECRET

AI assistant integrations

# Claude Code
graphify install --platform claude

# Gemini CLI
graphify install --platform gemini

# Cursor
graphify install --platform cursor

# VS Code Copilot Chat
graphify install --platform vscode

# See all supported platforms
graphify install --help

Architecture

Source Files
    │
    ▼
[extract.py]       File discovery, chunking, dispatch
    │
    ├── [extractors/]    tree-sitter AST parsing (36+ languages)
    │
    └── [llm.py]         LLM semantic extraction (9+ backends)
    │
    ▼
[build.py]         NetworkX graph construction + deduplication
    │
    ▼
[cluster.py]       Leiden community detection (graspologic)
    │
    ▼
[analyze.py]       God nodes, surprising connections, question suggestions
    │
    ▼
[export.py]        graph.json, HTML, SVG, GraphML, Obsidian, Neo4j
[wiki.py]          Wikipedia-style markdown articles
[serve.py]         MCP server (stdio + HTTP)
[prs.py]           PR impact analysis

How extraction works

  1. File discovery — Recursively finds code, documents, images, videos, and PDFs; respects .gitignore
  2. AST extraction — tree-sitter parses each file and extracts function/class definitions, imports, and call sites into nodes and edges with EXTRACTED confidence
  3. Semantic extraction — files are packed into chunks fitting an LLM's context window and sent for architectural knowledge extraction, producing EXTRACTED, INFERRED, and AMBIGUOUS edges
  4. Graph building — AST + semantic results are merged into a single NetworkX graph with entity deduplication (MinHash/LSH + Jaro-Winkler)
  5. Community detection — Leiden algorithm discovers natural module groupings; oversized communities are split
  6. Analysis — God nodes (most connected), surprising cross-community connections, and suggested questions
  7. Export — Multiple output formats including interactive HTML, queryable JSON, and Obsidian vault

Development

git clone https://github.com/Sachitt-AV-08/graphify.git
cd graphify
uv sync
pytest

License

MIT

About

Codebase knowledge graph tool — 36+ languages, 9+ LLM backends, MCP server, 20+ AI assistant integrations

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages