Skip to main content
04 / Case Study _04

Knowledge Graph Engine

Graph-Based Retrieval (RAG Alternative)

StatusActive — in development
Stack
PythonNeo4jClaude APICypherD3.jsNext.js 15FastAPI
Overview

A graph-based retrieval system designed as a principled alternative to traditional RAG. Instead of embedding documents into vector space and retrieving by cosine similarity, documents are decomposed into entities, relationships, and claims using Claude. These are stored as a knowledge graph in Neo4j. At query time, the LLM generates Cypher queries to traverse the graph, producing retrievals that are structurally accurate, explainable, and context-rich. Built for domains where accuracy matters more than speed — legal, financial, technical documentation.

Key Features

What Was Built

01

Document Ingestion Pipeline

PDF, Markdown, HTML documents decomposed into entities (people, companies, concepts, dates) and relationships (works_at, depends_on, contradicts) using Claude structured outputs with validation.

02

Knowledge Graph Storage

Neo4j with automatic schema evolution. New entity and relationship types are added dynamically as documents introduce novel concepts. Full-text indexing on entity properties.

03

Query Engine

natural language questions are translated to Cypher queries by Claude, executed against the graph, and results are synthesized into answers with citation paths. Multi-hop reasoning across relationship chains.

04

Graph Visualization

D3.js force-directed graph in the browser. Explore entities, relationships, and clusters interactively. Filter by entity type, relationship type, or source document.

05

Hybrid Retrieval

graph traversal for structured queries, pgvector fallback for fuzzy/unstructured queries. Automatic routing based on query classification.

06

Evaluation Framework

precision/recall benchmarks against traditional RAG on the same document corpus. Side-by-side comparison UI.

Architecture

How It's Built

01

FastAPI backend with async Neo4j driver for concurrent graph operations

02

Claude structured outputs for entity/relationship extraction with JSON schemas

03

Neo4j Aura for managed graph database with automatic backups

04

Cypher query generation with validation and injection prevention

05

pgvector (via Supabase) as hybrid fallback for unstructured queries

06

Next.js 15 frontend with D3.js graph visualization

07

Docker Compose for local development, Railway for production

08

Evaluation harness comparing graph retrieval vs. vector RAG accuracy

Tech Stack

Technical Stack

Layer
Technology
Backend
Python 3.12, FastAPI, async/await
Graph Database
Neo4j 5 (Aura managed)
Query Language
Cypher (LLM-generated with validation)
AI / LLM
Claude API — entity extraction, query generation, answer synthesis
Vector Fallback
pgvector via Supabase
Frontend
Next.js 15, React 19, TypeScript
Visualization
D3.js force-directed graph layout
Document Processing
pymupdf4llm (PDF), unified (Markdown/HTML)
Deployment
Docker Compose (local), Railway (production)
Outcomes

Results & Impact

01

Higher retrieval accuracy than vector RAG on structured domain queries

02

Explainable results — every answer traces through a relationship path

03

Interactive graph exploration reveals document relationships invisible to embeddings

04

Hybrid mode captures both structured and fuzzy query patterns

Tags
PythonNeo4jClaude APICypherD3.jsNext.js 15FastAPI