MCPcopy Index your code
hub / github.com/TtTRz/graphify-rs

github.com/TtTRz/graphify-rs @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
977 symbols 2,987 edges 81 files 215 documented · 22%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

graphify-rs

AI-powered knowledge graph builder

Transform code, docs, papers, and images into queryable, interactive knowledge graphs.

CI Crates.io Downloads docs.rs License: MIT Rust

中文文档 | CLI Reference | Architecture | Changelog


Why graphify-rs?

Built around Andrej Karpathy's /raw folder workflow: drop anything into a folder — papers, tweets, screenshots, code, notes — and get a structured knowledge graph that shows you what you didn't know was connected.

Three things it does that an LLM alone cannot:

Feature Why it matters
1 Persistent graph Relationships survive across sessions. Query weeks later without re-reading.
2 Honest audit trail Every edge tagged EXTRACTED, INFERRED, or AMBIGUOUS. Facts vs. guesses, always clear.
3 Cross-document surprise Community detection finds connections you'd never think to ask about.

Quick Start

# Install
cargo install graphify-rs

# Build a knowledge graph (free, fast, no API key needed)
graphify-rs build --no-llm

# Explore interactively (output is at ~/.graphify-rs/<project>-<hash>/)
open "$(ls -d ~/.graphify-rs/*graphify* | head -1)/graph.html"

# Query the graph
graphify-rs query "how does auth work?"

# (Optional) Add semantic extraction via LLM
export ANTHROPIC_API_KEY=sk-...   # or configure [llm] in graphify-rs.toml
graphify-rs build

Performance

Rust rewrite of graphify (Python) — fully compatible graph.json output.

Python Rust
Speed ~204ms ~24ms (8.5x faster)
Memory ~48MB ~1MB (48x less)
AST parsing Regex only 11 native tree-sitter + regex fallback
Community detection Louvain Leiden (with refinement)
MCP server - 16 tools over JSON-RPC 2.0
Export formats 7 9 (+ Obsidian, split HTML)
Extraction Sequential Parallel (rayon, configurable -j)

How It Works

 Source Files              graphify-rs build
 ┌──────────┐    ┌──────────────────────────────────────────────────────┐
 │ .py .rs  │    │                                                      │
 │ .go .ts  │───>│  detect -> extract -> build -> cluster -> analyze -> export
 │ .md .pdf │    │                                                      │
 └──────────┘    └──────────┬───────────────────────────────────────────┘
                            v
                  ~/.graphify-rs/<name>-<hash>/
                  ├── graph.json          queryable graph data
                  ├── graph.html          interactive visualization
                  ├── GRAPH_REPORT.md     analysis report
                  ├── wiki/               per-community wiki pages
                  └── obsidian/           Obsidian vault

Pass 1 — AST extraction (free, always runs): tree-sitter parses 21 languages into functions, classes, imports, calls. All edges tagged EXTRACTED (confidence 1.0).

Pass 2 — Semantic extraction (optional, --no-llm to skip): LLM API (Anthropic, OpenAI, Ollama, or OpenAI-compatible) discovers conceptual links, shared assumptions, design rationale. Edges tagged INFERRED (confidence 0.4–0.9). Configure via [llm] in graphify-rs.toml.

Graph Algorithms

7 advanced algorithms beyond basic traversal:

Algorithm What it does
Leiden clustering Community detection with internal connectivity guarantee
PageRank Structural importance (not just degree) — finds true architectural pillars
Tarjan's SCC Dependency cycle detection — surfaces circular imports
Dijkstra weighted path Shortest path weighted by edge confidence
Node2Vec embedding Graph similarity search — finds redundant/refactorable code
Incremental clustering Re-clusters only changed communities on rebuild
Smart summarization Three-level abstraction (detailed → community → architecture) for LLM token budgets

See docs/ARCHITECTURE.md for complexity analysis.

Supported Languages (21)

Native tree-sitter Regex fallback
Python, JavaScript, TypeScript, Rust, Go, Java, C, C++, Ruby, C#, Dart Kotlin, Scala, PHP, Swift, Lua, Zig, PowerShell, Elixir, Obj-C, Julia

Agent Integration

graphify-rs install              # install skill for AI coding agents
graphify-rs serve                # start MCP server (16 tools)

Agents auto-check the graph before architecture questions and rebuild after code changes. Works with Claude Code, CodeBuddy, Codex, OpenCode, and more.

16 MCP tools: query_graph, explore, pagerank, detect_cycles, smart_summary, find_similar, shortest_path, and 9 more.

Architecture

14-crate Cargo workspace — see docs/ARCHITECTURE.md for the full design.

Crate Role
graphify-core Data models, graph structure, confidence system
graphify-extract AST extraction (21 languages), multi-provider LLM semantic extraction
graphify-cluster Leiden community detection, incremental re-clustering
graphify-analyze PageRank, cycles, embeddings, god nodes, temporal risk
graphify-serve MCP server (16 tools), smart summarization, full-text search index
graphify-export 9 formats: JSON, HTML, SVG, GraphML, Cypher, Wiki, Obsidian, Report
+ 8 more Cache, security, ingestion, watch, hooks, benchmark, detect, build

Output Formats

File Description
graph.json NetworkX-compatible node_link_data JSON
graph.html Interactive vis.js visualization (dark theme, auto-pruning)
html/ Per-community HTML pages with navigation
GRAPH_REPORT.md God nodes, surprising connections, suggested questions
graph.svg / graph.graphml Static visualization / graph editor import
cypher.txt Neo4j import script
wiki/ / obsidian/ Wiki pages / Obsidian vault with wikilinks

CLI at a Glance

graphify-rs build [--path .] [--no-llm] [--format json,html]   # build graph
graphify-rs query "question" [--dfs] [--budget 2000]            # query
graphify-rs watch --path .                                       # auto-rebuild
graphify-rs serve                                                 # MCP server
graphify-rs diff old.json new.json                               # compare
graphify-rs stats graph.json                                     # statistics

Full reference: docs/CLI.md (22 subcommands)

Contributing

See CONTRIBUTING.md for setup, code style, testing, and PR guidelines.

License

MIT — see LICENSE.

Rust rewrite of graphify by safishamsi.

Extension points exported contracts — how you extend this code

Parser (Interface)
A source-file parser that produces graph nodes and edges. Implementations must be `Send + Sync` so they can be shared a [1 …
crates/graphify-extract/src/parser.rs

Core symbols most depended-on inside this repo

hs
called by 95
crates/graphify-extract/src/lang_config.rs
add_node
called by 81
crates/graphify-core/src/graph.rs
get_node
called by 58
crates/graphify-core/src/graph.rs
try_extract
called by 42
crates/graphify-extract/src/treesitter/mod.rs
add_edge
called by 41
crates/graphify-core/src/graph.rs
make_edge
called by 38
crates/graphify-extract/src/ast_extract/mod.rs
line_of
called by 36
crates/graphify-extract/src/ast_extract/mod.rs
extract_file
called by 35
crates/graphify-extract/src/ast_extract/mod.rs

Shape

Function 874
Class 47
Method 35
Enum 20
Interface 1

Languages

Rust100%

Modules by API surface

crates/graphify-serve/src/lib.rs42 symbols
crates/graphify-extract/tests/treesitter.rs41 symbols
crates/graphify-serve/src/search.rs34 symbols
crates/graphify-core/src/graph.rs34 symbols
crates/graphify-serve/src/mcp/mod.rs33 symbols
crates/graphify-cluster/src/lib.rs33 symbols
crates/graphify-analyze/src/tests.rs33 symbols
crates/graphify-extract/src/tests.rs32 symbols
crates/graphify-extract/tests/ast_extract.rs30 symbols
crates/graphify-extract/src/lang_config.rs28 symbols
crates/graphify-core/src/model.rs28 symbols
src/install.rs26 symbols

For agents

$ claude mcp add graphify-rs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact