Skip to main content

GraphRAG knowledge base for codebases

Project description

nelgraph 🚀

An autonomous, zero-configuration Knowledge Graph builder and semantic search engine optimized for local codebases and AI testing agents. It ingests source code, AST Call Graphs, Class Inheritance structures, and Git history into a hybrid Graph-Vector database (Neo4j + ChromaDB) using DeepSeek V4-Flash.

🛠️ Installation

pip install nelgraph

🚀 CLI Usage

1. Initialize GraphRAG for your project

Navigate to your project directory and run:

nelgraph init

During initialization, it will:

  • Prompt you for your OpenRouter API key.
  • Configure the local .env and .graphrag_data/ directory.
  • Start Neo4j inside a local Docker container.
  • Build structural nodes, relations, and indexes.
  • Install a git post-commit hook so the graph auto-syncs.
  • Automatically generate the AI Agent Skill definition file at .agents/nelgraph/SKILL.md.

2. Manual Synchronization

If you want to manually trigger incremental synchronization (e.g. after changes):

nelgraph sync

3. Check Status

View current database metrics, indexed function counts, and AI enrichment coverage:

nelgraph status

4. Install Git Hook

Manually install the Git post-commit / pre-push hook for auto-syncing the graph:

nelgraph install-hook

🔌 Programmatic Python API

You can import nelgraph directly into your scripts or AI testing agents:

import nelgraph

# Configure (if .env is not present or needs custom config)
nelgraph.configure(
    codebase_path="/absolute/path/to/project",
    openrouter_api_key="your-openrouter-key"
)

# 1. Get snapshot of prioritized functions
# Returns functions grouped by community, sorted by priority score
snapshot = nelgraph.get_snapshot()
print(f"Total functions: {snapshot['total']}")

# 2. Retrieve detailed context for a function
# Disambiguate functions with same name using optional class_name or file filters
ctx = nelgraph.get_function_context("execute", class_name="CalculationContext")
print(ctx.get("function", {}).get("how_it_works"))

# 3. Retrieve detailed context for a class
# Returns class details, parent classes, child classes, methods, docstring, and source code
class_ctx = nelgraph.get_class_context("ExpressionParser")
print(class_ctx.get("parent_classes"))

# 4. Export context to a file (Markdown or JSON)
# Resolves class before function; saves to path
success = nelgraph.dump_context_to_file("ExpressionParser", "./scratch/class_context.md", format="markdown")

# 5. Semantic Search
# Uses vector similarity search to find functions/concepts related to a query
results = nelgraph.search("user authentication flow")
for r in results:
    print(r["name"], r["score"])

# 6. Mark function as tested/verified
# Persists testing status directly to the graph
nelgraph.mark_tested("process_order")

🤖 AI Agent Skill Interface

When nelgraph init runs, it generates .agents/nelgraph/SKILL.md. This file contains standard Model Context Protocol (MCP) skill signatures and operational rules for downstream LLM agents. Agents can read this file at the start of a session to understand how to query code context, track progress, and run synchronization.

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

nelgraph-1.0.9.tar.gz (352.5 kB view details)

Uploaded Source

Built Distribution

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

nelgraph-1.0.9-py3-none-any.whl (399.5 kB view details)

Uploaded Python 3

File details

Details for the file nelgraph-1.0.9.tar.gz.

File metadata

  • Download URL: nelgraph-1.0.9.tar.gz
  • Upload date:
  • Size: 352.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for nelgraph-1.0.9.tar.gz
Algorithm Hash digest
SHA256 a01172d96cee4a01ee87b48162bf942f976a3a75e2fbbeb42c6f21da33b39c73
MD5 3ae7bce82f9590e45f100430d25d3b91
BLAKE2b-256 14e795357b77ded4fb997902f709663231ca40dd07ecacf3e95a445f73fcb193

See more details on using hashes here.

File details

Details for the file nelgraph-1.0.9-py3-none-any.whl.

File metadata

  • Download URL: nelgraph-1.0.9-py3-none-any.whl
  • Upload date:
  • Size: 399.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for nelgraph-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 96d1bf8423049bbf82ad5d5f59cffe4fdeb8fa9ddb0461491e67b58b1792e8b7
MD5 246b8bc5900a7499199185ba3e1afa2e
BLAKE2b-256 f9be5b9a9028a2bb64cacf9648ce114bf001c09c08ed0251f1c651916eec686d

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