Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a2fdb97
Add SurrealDB output support to graphify-dotnet
Jul 16, 2026
3b58350
Merge pull request #1 from cornelha/feat/surrealdb-phase1-adapter
cornelhattingh Jul 16, 2026
0985dc9
Refactor GraphTools API descriptions, improve query functionality, an…
Jul 16, 2026
5178d34
Update package versions to 0.8.0 and enhance installation instruction…
Jul 16, 2026
79a5f68
Refactor MCP server into CLI; remove Graphify.Mcp project
Jul 16, 2026
cb96d12
Add SurrealDB submodule for integration with the project
Jul 17, 2026
4081223
Integrate SurrealDB projects and update version to 0.9.0-preview.4; a…
Jul 17, 2026
0bb00ce
Merge pull request #2 from cornelha/SurrealDB_API_Integration
cornelha Jul 20, 2026
7a354ed
Add .claude and .tokensave directories to .gitignore
Jul 20, 2026
d2a9adb
Merge branch 'main' of https://github.com/cornelha/graphify-dotnext
Jul 20, 2026
1e0f221
feat(cli): add init command and SurrealDB backend support for serve
Jul 21, 2026
e641aae
feat(openai): add support for OpenAI-compatible provider
Jul 21, 2026
7de84b5
docs(cli): add OpenAI-compatible provider and update related docs
Jul 21, 2026
3720666
feat(config): add support for .env file loading in CLI app
Jul 21, 2026
d0c1db0
docs(openai): add comprehensive OpenAI-compatible setup guide
Jul 21, 2026
124600f
chore(config): add comprehensive .env example and update config loading
Jul 21, 2026
fe01fbf
feat(surrealdb): add SurrealDB graph export and backend integration
Jul 22, 2026
600a470
fix(surrealdb): split DELETE and INSERT into separate requests to avo…
Jul 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
474 changes: 474 additions & 0 deletions .claude/PRPs/plans/completed/surrealdb-phase1-schema.plan.md

Large diffs are not rendered by default.

85 changes: 85 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# =============================================================================
# Graphify Configuration (.env)
# =============================================================================
# Place this file in the project root directory. Graphify loads it automatically
# at startup. Settings use the GRAPHIFY__ prefix with double-underscore nesting.
#
# Configuration priority (highest wins):
# 1. CLI arguments (--provider, --endpoint, etc.)
# 2. dotnet user-secrets
# 3. .env file ← You are here
# 4. Environment variables (GRAPHIFY__*)
# 5. appsettings.local.json (wizard-saved)
# 6. appsettings.json (built-in defaults)
# =============================================================================

# ── Global Settings ──────────────────────────────────────────────────────────

# Active AI provider: azureopenai, openai, ollama, copilotsdk
GRAPHIFY__Provider=openai

# Project folder to analyze (default: current directory)
GRAPHIFY__WorkingFolder=.

# Output directory (default: graphify-out)
GRAPHIFY__OutputFolder=graphify-out

# Export formats, comma-separated (default: json,html,report)
# Available: json, html, svg, neo4j, ladybug, obsidian, wiki, surrealdb, report
GRAPHIFY__ExportFormats=surrealdb

# ── OpenAI (Compatible) Provider ─────────────────────────────────────────────
# Works with any OpenAI-compatible endpoint: OpenAI API, OpenCode Zen,
# LocalAI, LiteLLM, vLLM, Groq, Together AI, etc.

# Base endpoint URL (required)
GRAPHIFY__OpenAi__Endpoint=https://opencode.ai/zen/v1

# API key (required)
GRAPHIFY__OpenAi__ApiKey=sk-k3mky4zwHRNIgfTbfqtVRJN8J5HNPin7NbJRA9X74giDjIGE8vSGSrrpiUDTl6Ns

# Model identifier, e.g. gpt-4o, gpt-4o-mini, deepseek-v4-flash-free
GRAPHIFY__OpenAi__ModelId=opencode/deepseek-v4-flash-free

# ── Azure OpenAI Provider ────────────────────────────────────────────────────

# Azure resource endpoint (required)
GRAPHIFY__AzureOpenAI__Endpoint=https://my-resource.openai.azure.com/

# API key (required)
GRAPHIFY__AzureOpenAI__ApiKey=sk-your-key-here

# Model deployment name (required)
GRAPHIFY__AzureOpenAI__DeploymentName=gpt-4o

# Optional model ID override (defaults to DeploymentName)
GRAPHIFY__AzureOpenAI__ModelId=gpt-4o

# ── Ollama Provider (Local) ──────────────────────────────────────────────────

# Ollama server URL (default: http://localhost:11434)
GRAPHIFY__Ollama__Endpoint=http://localhost:11434

# Model to use (default: llama3.2)
GRAPHIFY__Ollama__ModelId=llama3.2

# ── GitHub Copilot SDK Provider ──────────────────────────────────────────────
# Authentication via GitHub Copilot CLI session (no API key needed)

# Model to use (default: gpt-4.1)
GRAPHIFY__CopilotSdk__ModelId=gpt-4.1

# ── SurrealDB (MCP Backend) ──────────────────────────────────────────────────
# Configure when using `graphify serve` with a remote SurrealDB instance.
# When Endpoint is set, remote mode is used; otherwise embedded mode.

# Remote SurrealDB endpoint (e.g., http://localhost:8000)
GRAPHIFY__SurrealDb__Endpoint=http://localhost:8000

# Authentication credentials
GRAPHIFY__SurrealDb__Username=root
GRAPHIFY__SurrealDb__Password=root

# Namespace and database (defaults: graphify / codebase)
GRAPHIFY__SurrealDb__Namespace=archsentinal
GRAPHIFY__SurrealDb__Database=codebase
6 changes: 3 additions & 3 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ graphify-dotnet/
│ ├── Graphify/ # Core library (graph pipeline, data structures, export)
│ ├── Graphify.Cli/ # CLI tool (System.CommandLine)
│ ├── Graphify.Sdk/ # GitHub Copilot SDK integration
│ ├── Graphify.Mcp/ # MCP stdio server
│ ├── Graphify.Cli/Mcp/ # MCP server built into CLI
│ └── tests/
│ ├── Graphify.Tests/ # Unit tests (xUnit)
│ └── Graphify.Integration.Tests/ # Integration tests
Expand Down Expand Up @@ -48,7 +48,7 @@ graphify-dotnet/
- `src/Graphify/` — Core library (graph pipeline, data structures, export)
- `src/Graphify.Cli/` — CLI tool (dotnet tool, System.CommandLine)
- `src/Graphify.Sdk/` — GitHub Copilot SDK integration
- `src/Graphify.Mcp/` — MCP stdio server (ModelContextProtocol)
- `src/Graphify.Cli/Mcp/` — MCP server built into the CLI (ModelContextProtocol)
- `src/tests/Graphify.Tests/` — Unit tests (xUnit)
- `src/tests/Graphify.Integration.Tests/` — Integration tests

Expand All @@ -68,7 +68,7 @@ graphify-dotnet/

### Library / Application Projects
- Target `net10.0` only (single target — this is a .NET 10 project, not multi-target)
- Project naming: `Graphify`, `Graphify.Cli`, `Graphify.Sdk`, `Graphify.Mcp`
- Project naming: `Graphify`, `Graphify.Cli`, `Graphify.Sdk`
- Enable deterministic CI builds: `<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">true</ContinuousIntegrationBuild>`
- Include `<InternalsVisibleTo>` for the corresponding test project where needed
- `Graphify.Cli` includes `<PackAsTool>true</PackAsTool>` for NuGet dotnet-tool publishing
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ obj/

# Local config (may contain secrets)
appsettings.local.json
.tokensave/*
.claude/PRPs/reports/surrealdb-phase1-schema-report.md
nupkg/*
.claude/*
.tokensave/*
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "lib/surrealdb.net"]
path = lib/surrealdb.net
url = https://github.com/surrealdb/surrealdb.net.git
4 changes: 2 additions & 2 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ graphify-dotnet/
│ └── PipelineRunner.cs # Pipeline orchestration
├── src/Graphify.Sdk/ # GitHub Copilot SDK integration
│ └── CopilotExtractor.cs # Copilot-specific extractors
├── src/Graphify.Mcp/ # MCP stdio server
── McpServer.cs # ModelContextProtocol server
├── src/Graphify.Cli/ # CLI + MCP server
── Mcp/GraphTools.cs # ModelContextProtocol tool definitions
└── src/tests/ # Test projects
├── Graphify.Tests/ # Unit tests
└── Graphify.Integration.Tests/ # Integration tests
Expand Down
117 changes: 117 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# graphify-dotnet — ECC Project Guide

**Project:** AI-powered knowledge graph builder for codebases (.NET 10)
**Architecture:** Multi-project solution with pipeline-based design
**Status:** Active development (AST extraction, semantic analysis, graph export)

## Quick Commands

```bash
# Build
dotnet build

# Test (all)
dotnet test

# Test (specific)
dotnet test --filter "FullyQualifiedName~Graphify.Tests"

# Run CLI
dotnet run --project src/Graphify.Cli -- --help

# Package
dotnet pack src/Graphify.Sdk -o ./nupkg

# Clean build artifacts
dotnet clean
```

## Project Structure

### Core Library (`src/Graphify/`)
- **Pipeline**: File detection → extraction → graph building → clustering → analysis → export
- **Models**: Immutable records for nodes, edges, analysis results
- **Export**: JSON, HTML (vis.js), SVG, Wiki (Markdown), Obsidian, Neo4j, Ladybug graph database
- **Extraction**: Hybrid AST + semantic analysis (configurable AI provider)
- **Cache**: SHA256-based semantic cache for reproducible runs

### CLI (`src/Graphify.Cli/`)
- Entry point for command-line usage
- Configuration wizard (interactive setup for AI provider + analysis folder)
- Pipeline orchestration

### SDK (`src/Graphify.Sdk/`)
- GitHub Copilot SDK integration
- Copilot-specific extractors

### MCP Server (built into CLI)
- `graphify serve` — Model Context Protocol server (stdio-based)
- Exposes graph operations to Claude and other MCP clients
- Tools defined in `src/Graphify.Cli/Mcp/GraphTools.cs`

### Tests
- **Unit tests** (`Graphify.Tests`): Component-level testing
- **Integration tests** (`Graphify.Integration.Tests`): Pipeline & export validation

## Design Principles

- **Composition over inheritance**: Interfaces + DI instead of deep hierarchies
- **Immutable data**: Records for thread-safety
- **.NET idioms**: `IOptions<T>`, `ILogger<T>`, `async/await`, `CancellationToken`
- **Type safety**: Nullable reference types enabled; strong typing throughout
- **Pipeline pattern**: Each stage is an `IPipelineStage<TIn, TOut>` implementation
- **Decoupled stages**: Output from one stage feeds into the next via well-defined models

## Code Health

**Language Settings** (see `Directory.Build.props`):
- C# latest (13)
- Nullable reference types: enabled
- Implicit usings: enabled
- Code analysis: enforced
- Warnings as errors: nullable violations only

**Key Dependencies**:
- **QuikGraph**: Graph data structures & algorithms (stable, 2.x)
- **ModelContextProtocol**: MCP protocol for Claude integration (pre-1.0, monitor for CVEs)
- **Spectre.Console**: CLI output formatting (pre-1.0, track releases)
- **System.CommandLine**: CLI parsing (stable, 2.x)
- **Microsoft.Extensions.*** packages: Follow .NET 10 preview releases (10.x)

## AI Provider Setup

The project supports three extraction modes:

1. **Azure OpenAI**: Enterprise-grade semantic analysis (recommended for production)
2. **Ollama**: Local/self-hosted LLM for privacy-first analysis
3. **None (AST-only)**: Fast, zero-config extraction (no semantic relationships)

Configure via the interactive wizard: `dotnet run --project src/Graphify.Cli -- config`

## Code Review Guidance

**Required for C# changes**: `/code-review` (ecc:csharp-reviewer)

**Focus areas**:
- Nullable reference type correctness (no #nullable disable)
- Pipeline stage contracts (ensure `IPipelineStage<TIn, TOut>` invariants)
- DI registration (Microsoft.Extensions.DependencyInjection patterns)
- Async correctness (ConfigureAwait, CancellationToken propagation)
- Export path safety (prevent directory traversal attacks)

**Known constraints**:
- MCP server uses stdio (not TCP) — test message framing end-to-end
- Semantic cache keys are SHA256(file path + content) — invalidate on API changes
- QuikGraph uses ref-based edges — be careful with value-type copies

## Integration Points

- **GitHub Actions**: CI build & publish workflows (see `.github/workflows/`)
- **MCP Clients**: Claude, IDEs, chat applications via model context protocol
- **Export formats**: Neo4j, Obsidian, vis.js visualization, custom wikis

## Getting Help

- See `docs/getting-started.md` for step-by-step walkthrough
- See `ROADMAP.md` for planned features
- See `ARCHITECTURE.md` for deep technical details
85 changes: 85 additions & 0 deletions docs/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# =============================================================================
# Graphify Configuration (.env)
# =============================================================================
# Place this file in the project root directory. Graphify loads it automatically
# at startup. Settings use the GRAPHIFY__ prefix with double-underscore nesting.
#
# Configuration priority (highest wins):
# 1. CLI arguments (--provider, --endpoint, etc.)
# 2. dotnet user-secrets
# 3. .env file ← You are here
# 4. Environment variables (GRAPHIFY__*)
# 5. appsettings.local.json (wizard-saved)
# 6. appsettings.json (built-in defaults)
# =============================================================================

# ── Global Settings ──────────────────────────────────────────────────────────

# Active AI provider: azureopenai, openai, ollama, copilotsdk
GRAPHIFY__Provider=openai

# Project folder to analyze (default: current directory)
GRAPHIFY__WorkingFolder=.

# Output directory (default: graphify-out)
GRAPHIFY__OutputFolder=graphify-out

# Export formats, comma-separated (default: json,html,report)
# Available: json, html, svg, neo4j, ladybug, obsidian, wiki, surrealdb, report
GRAPHIFY__ExportFormats=json,html,report

# ── OpenAI (Compatible) Provider ─────────────────────────────────────────────
# Works with any OpenAI-compatible endpoint: OpenAI API, OpenCode Zen,
# LocalAI, LiteLLM, vLLM, Groq, Together AI, etc.

# Base endpoint URL (required)
GRAPHIFY__OpenAi__Endpoint=https://api.openai.com/v1

# API key (required)
GRAPHIFY__OpenAi__ApiKey=sk-your-key-here

# Model identifier, e.g. gpt-4o, gpt-4o-mini, deepseek-v4-flash-free
GRAPHIFY__OpenAi__ModelId=gpt-4o

# ── Azure OpenAI Provider ────────────────────────────────────────────────────

# Azure resource endpoint (required)
GRAPHIFY__AzureOpenAI__Endpoint=https://my-resource.openai.azure.com/

# API key (required)
GRAPHIFY__AzureOpenAI__ApiKey=sk-your-key-here

# Model deployment name (required)
GRAPHIFY__AzureOpenAI__DeploymentName=gpt-4o

# Optional model ID override (defaults to DeploymentName)
GRAPHIFY__AzureOpenAI__ModelId=gpt-4o

# ── Ollama Provider (Local) ──────────────────────────────────────────────────

# Ollama server URL (default: http://localhost:11434)
GRAPHIFY__Ollama__Endpoint=http://localhost:11434

# Model to use (default: llama3.2)
GRAPHIFY__Ollama__ModelId=llama3.2

# ── GitHub Copilot SDK Provider ──────────────────────────────────────────────
# Authentication via GitHub Copilot CLI session (no API key needed)

# Model to use (default: gpt-4.1)
GRAPHIFY__CopilotSdk__ModelId=gpt-4.1

# ── SurrealDB (MCP Backend) ──────────────────────────────────────────────────
# Configure when using `graphify serve` with a remote SurrealDB instance.
# When Endpoint is set, remote mode is used; otherwise embedded mode.

# Remote SurrealDB endpoint (e.g., http://localhost:8000)
GRAPHIFY__SurrealDb__Endpoint=http://localhost:8000

# Authentication credentials
GRAPHIFY__SurrealDb__Username=root
GRAPHIFY__SurrealDb__Password=your-password

# Namespace and database (defaults: graphify / codebase)
GRAPHIFY__SurrealDb__Namespace=graphify
GRAPHIFY__SurrealDb__Database=codebase
12 changes: 11 additions & 1 deletion docs/blog-post.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,21 @@ dotnet run --project src/Graphify.Cli -- benchmark graphify-out/graph.json
**Export to multiple formats:**

```bash
dotnet run --project src/Graphify.Cli -- run . --format json,html,svg,neo4j,obsidian,wiki,report
dotnet run --project src/Graphify.Cli -- run . --format json,html,svg,neo4j,obsidian,wiki,report,surrealdb
```

The HTML export gives you an interactive vis.js graph. Click nodes, search by concept, filter by community. The Neo4j export lets you load the entire graph into a real graph database.

**Query through AI assistants with the MCP server:**

```bash
# Build the graph first, then run the MCP server
dotnet run --project src/Graphify.Cli -- run . --format json
graphify serve graphify-out/graph.json
```

Connect Claude Desktop or VS Code and ask "Find the shortest path between the auth module and the database." The server exposes 5 tools for searching, navigating, and analyzing your codebase graph. See the [MCP Server docs](mcp-server.md) for client setup.

## Key Features

- **Multi-language parsing**: Python, TypeScript, JavaScript, Go, Rust, Java, C#, C++, and more via tree-sitter AST extraction
Expand Down
Loading