Skip to main content

Parse any codebase, build a knowledge graph, visualise it, and query it in natural language.

Project description

graphmy

Parse any codebase, build a knowledge graph, visualise it, and query it in natural language.

PyPI version CI License: MIT Python 3.10+

graphmy turns any source code directory into an interactive, queryable knowledge graph. Point it at a codebase and get:

  • A navigable graph — every function, class, method, and file as a node; every call, import, and inheritance as a typed edge
  • A self-contained HTML visualisation — open in any browser, share as a single file, no server required
  • Natural language queries — "what calls authenticate?", "find functions related to payment processing"
  • Multi-language — Python, JavaScript, TypeScript, Go, Rust, and Java in one tool

Install

pip install graphmy

For the --serve live UI:

pip install graphmy[serve]

For LLM-synthesized query answers (requires OpenAI key):

pip install graphmy[openai]

Quick start

# 1. Index a codebase (builds graph + vector index in .graphmy/)
graphmy index ./my-project

# 2. Query in natural language
graphmy query ./my-project "what calls authenticate?"
graphmy query ./my-project "find functions related to payments"

# 3. Generate interactive HTML visualisation (self-contained, ~2MB+)
graphmy viz ./my-project
open output.html

# 4. Or boot a live server with NL query bar
graphmy viz ./my-project --serve

# 5. Inspect codebase stats
graphmy info ./my-project

How it works

┌─────────────────────────────────────────────────────┐
│  PARSER  (tree-sitter, per-language grammars)        │
│  • functions, classes, methods, imports, inheritance │
│  • works on Python, JS/TS, Go, Rust, Java           │
├─────────────────────────────────────────────────────┤
│  GRAPH   (networkx DiGraph)                          │
│  • nodes: File, Class, Function, Method, …           │
│  • edges: CALLS, IMPORTS, DEFINES, CONTAINS,         │
│           INHERITS, IMPLEMENTS                       │
│  • persisted as JSON in .graphmy/                    │
├─────────────────────────────────────────────────────┤
│  SEARCH  (sentence-transformers + chromadb)          │
│  • embeds every symbol (name + signature + docstring)│
│  • incremental upsert — only re-embeds changed files │
│  • structural queries bypass embeddings entirely     │
├─────────────────────────────────────────────────────┤
│  VISUALISER  (cytoscape.js + dagre layout)           │
│  • self-contained HTML (no server needed)            │
│  • click any node → name, file:line, source preview, │
│    callers, callees                                  │
│  • --serve boots FastAPI + NL query bar              │
└─────────────────────────────────────────────────────┘

CLI reference

graphmy index   <path> [--exclude GLOB] [--fresh]
graphmy query   <path> <query> [--limit N] [--explain]
graphmy viz     <path> [--out FILE] [--serve] [--host H] [--port P]
                       [--max-body-lines N]
graphmy info    <path>
graphmy config  <path>
graphmy --version
graphmy --help

graphmy index

Parse the codebase and build the graph + vector index. Stores everything in .graphmy/ at the project root. Subsequent runs are incremental — only changed files are re-parsed.

graphmy index ./my-project
graphmy index ./my-project --exclude "tests/**" --exclude "**/*.min.js"
graphmy index ./my-project --fresh   # ignore cache, full re-index

graphmy query

Search the codebase in natural language.

graphmy query ./my-project "what calls validate_user?"
graphmy query ./my-project "find authentication functions" --limit 10
graphmy query ./my-project "explain the payment flow" --explain  # requires openai extra

graphmy viz

Generate an interactive visualisation.

# Self-contained HTML file (default)
graphmy viz ./my-project
graphmy viz ./my-project --out my-graph.html
graphmy viz ./my-project --max-body-lines 50   # cap inlined source for large repos

# Live server with NL query bar
graphmy viz ./my-project --serve
graphmy viz ./my-project --serve --host 0.0.0.0 --port 8080

Configuration

Create .graphmy/config.toml in your project root, or use environment variables:

# .graphmy/config.toml

# OpenAI integration (enables --explain in queries and the Explain button in --serve UI)
openai_api_key = "sk-..."
openai_model   = "gpt-4o-mini"   # default

# Paths to exclude from indexing (glob patterns, relative to project root)
exclude = ["tests/**", "docs/**", "**/*.min.js", "**/node_modules/**"]

# Maximum source lines inlined per symbol in static HTML (0 = unlimited)
max_body_lines = 0

Environment variables take precedence over config file:

export GRAPHMY_OPENAI_API_KEY="sk-..."
export GRAPHMY_OPENAI_MODEL="gpt-4o"

Python API

graphmy can also be used programmatically:

from graphmy import GraphmyIndex, GraphmyConfig

# Index a codebase
config = GraphmyConfig(exclude=["tests/**"])
index = GraphmyIndex("./my-project", config=config)
index.build()   # incremental by default

# Structural query — exact graph traversal
results = index.query_structural("authenticate")
for r in results:
    print(r.name, r.file, r.line)

# Natural language query
results = index.query_nl("what handles user authentication?")
for r in results:
    print(r.symbol.name, r.score, r.relationships)

# Export visualisation
index.export_html("graph.html")

Supported languages

Language Extensions Extracts
Python .py functions, classes, methods, imports, inheritance, decorators, async
JavaScript .js .mjs .cjs functions, classes, methods, ESM imports, require()
TypeScript .ts .tsx all JS + interfaces, type aliases, enums, implements
Go .go functions, methods on types, structs, interfaces, imports
Rust .rs functions, structs, enums, traits, impl blocks, use statements
Java .java classes, interfaces, methods, constructors, extends, implements

External symbols (calls/imports to dependencies outside the project root) appear as stub nodes — visible in the graph but not expanded. This keeps your graph focused on your code.


Index cache (.graphmy/)

<project-root>/
└── .graphmy/
    ├── config.toml          # optional user config
    ├── graph.json           # full graph (networkx node-link JSON)
    ├── file_hashes.json     # {filepath: [mtime, sha256]} for incremental re-index
    └── vectors/             # chromadb embedded vector store (SQLite + HNSW)

Add .graphmy/ to your .gitignore (graphmy does this automatically on first index).


Contributing

See CONTRIBUTING.md. Issues and PRs are welcome.


License

MIT — see 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

graphmy-0.1.1.tar.gz (313.4 kB view details)

Uploaded Source

Built Distribution

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

graphmy-0.1.1-py3-none-any.whl (77.5 kB view details)

Uploaded Python 3

File details

Details for the file graphmy-0.1.1.tar.gz.

File metadata

  • Download URL: graphmy-0.1.1.tar.gz
  • Upload date:
  • Size: 313.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for graphmy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8484a099ee19a5e4b7d49f38ffaa02cb2d7968fee51ed2c30a2d542da2a9a113
MD5 f957a019918db1a52162db2db886010c
BLAKE2b-256 c1a249d467b6190fb281e100bdbd7545f59e609d779e24dd2a49220c5cb5f735

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphmy-0.1.1.tar.gz:

Publisher: publish.yml on Kamalesh-Kavin/graphmy

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

File details

Details for the file graphmy-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: graphmy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 77.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for graphmy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 60b35d3392d33c3f7fd79e09e780a38498cd4af0bb301d838678b2f7bd77f130
MD5 374bbceb71455d9656ba9c9bb308fe54
BLAKE2b-256 1faf6651f22edf4ef95a297feef74c6c94e4320e840e1657688f6d1dfa3d3588

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphmy-0.1.1-py3-none-any.whl:

Publisher: publish.yml on Kamalesh-Kavin/graphmy

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