CORTEX is a production-grade, agentic Knowledge Graph platform that transforms unstructured documents and web content into an intelligent, queryable knowledge graph β with a full-featured React UI, streaming AI chat, real-time graph visualization, simulation personas, and deep ontology governance.
LLM-powered refinement: POST /api/ontology/refine β refine schema with optional human feedback
Versioning: Each schema change bumps the version (v1.0 β v1.1, etc.)
Document-scoped stats: /api/ontology/stats?document_id=... returns entity/relationship breakdowns for a specific document
Visual editor: Ontology view in UI with editable entity types and relationship types
Ontology Drift Detection: Automated drift detection compares live graph against new chunk samples; exposes pending/approved/rejected drift reports with admin approve/reject workflow
π€ Agentic Retrieval System
LangGraph orchestration: State-machine ReACT agent with multi-step reasoning and fallback mechanisms
Tool routing: Dynamically selects from Naive Vector, Hybrid, Metadata Filtering, Global Community Search, HippoRAG, Graph of Thoughts (GoT), and Cypher.
Retrieval Modes: Switch seamlessly between AUTO, HYBRID, HIPPO-RAG, LOCAL GRAPH, GLOBAL COMMUNITY, GOT, CYPHER, NAIVE, and SIMULATION.
Streaming responses: Server-Sent Events (SSE) with real-time reasoning steps surfaced in the UI
Multi-turn conversations: Persistent conversation threads stored in Neo4j, per-user
Document-scoped queries: Filter retrieval to a specific document via document_id
Graph of Thoughts (GoT): Advanced multi-hop reasoning mode exploring the graph neighborhood
HippoRAG: Personalized PageRank (PPR) fallback strategies mapped to entity seeding
Global Community Search: Vector similarity search over pre-computed hierarchical Leiden reports
LLM-as-a-Judge (inline): Optional per-response quality scoring with hallucination risk, grounded/ungrounded claims, and confidence reasoning displayed in chat
Confidence display: Confidence score, hallucination risk, and judge reasoning shown directly in the chat bubble
π RAGAS Evaluation & Quality Dashboard
POST /api/eval/score: Run RAGAS-style evaluation on any Q&A pair (faithfulness, relevancy, context precision, hallucination detection)
GET /api/eval/dashboard: Aggregate evaluation history β avg scores, hallucination rate, trend timeline
Results persisted in Neo4j for longitudinal quality tracking
πΊοΈ Graph Intelligence
D3 force-directed visualization: Interactive knowledge graph with zoom, pan, node selection, and a details modal
Graph Export: Export full or document-scoped graph as JSON, Cypher, or GraphML
Community Detection: Hierarchical Leiden community clustering with POST /api/graph/communities/assign
Community listing: GET /api/graph/communities β top communities by entity count
Temporal Queries: GET /api/entities/{entity_name}/at-time β retrieve entity relationships at a historical point in time
docker run -d --name redis -p 6379:6379 redis:alpine
Hugging Face Spaces / All-in-One Docker
You can easily deploy CORTEX to Hugging Face Spaces or as a standalone container.
Our Dockerfile automatically installs Python 3.12, Redis, Neo4j, and the GDS plugin to run the entire platform on a single port (7860).
5. Launch Everything
npm run rag
This starts three color-coded processes concurrently:
Deep multi-page Playwright crawl β ingest (API Only)
GET
/api/documents
List all ingested documents
DELETE
/api/documents/{id}
Delete document + graph chunks
GET
/api/documents/{id}/download
Download source file
GET
/api/documents/{id}/preview
Preview text content
GET
/api/documents/status/{task_id}
Ingestion task status
Query & Chat
Method
Endpoint
Description
POST
/api/query
Agentic query (streaming or JSON); supports document_id, use_got
GET
/api/conversations
List conversation threads
GET
/api/conversations/{id}
Get conversation + messages
DELETE
/api/conversations/{id}
Delete conversation
Ontology
Method
Endpoint
Description
GET
/api/ontology
Get current ontology
PUT
/api/ontology
Update ontology (admin)
POST
/api/ontology/refine
LLM-powered ontology refinement
GET
/api/ontology/stats
Entity/relationship counts (optional doc filter)
POST
/api/ontology/drift/detect
Trigger drift detection
GET
/api/ontology/drift
List drift reports
POST
/api/ontology/drift/{id}/approve
Approve drift β merge into ontology
POST
/api/ontology/drift/{id}/reject
Reject drift report
Graph
Method
Endpoint
Description
GET
/api/graph/visualization
Graph nodes + edges for D3 rendering
GET
/api/graph/export
Export graph (json | cypher | graphml)
POST
/api/graph/update
Push raw text β merge into live graph
POST
/api/graph/communities/assign
Run Hierarchical Leiden clustering & generate reports
GET
/api/graph/communities
List top communities
Entities
Method
Endpoint
Description
POST
/api/entities/deduplicate
Semantic entity resolution + merge
POST
/api/entities/enrich
Generate LLM summaries for all entities
GET
/api/entities/{name}/summary
Get enriched entity profile
POST
/api/entities/{name}/chat
Multi-turn entity-scoped chat
GET
/api/entities/{name}/at-time
Temporal query (ISO 8601 date)
Reports & Evaluation
Method
Endpoint
Description
POST
/api/report
Generate ReACT analytical report (markdown)
POST
/api/eval/score
RAGAS evaluation of a Q&A pair
GET
/api/eval/dashboard
Evaluation history dashboard
Simulation
Method
Endpoint
Description
POST
/api/v1/simulation/interview
Live persona interview (in-character LLM)
GET
/api/v1/simulation/report
Sandbox analytical report (API Only)
POST
/api/v1/simulation/generate_personas
Queue persona generation task (API Only)
POST
/api/v1/simulation/tick
Advance simulation tick (API Only)
System & Admin
Method
Endpoint
Description
GET
/api/system/health
Neo4j + Redis + Celery health
GET
/api/system/stats
Document, entity, relationship counts
GET
/api/system/my-stats
Current user's activity stats
GET
/api/system/formats
Supported ingestion file formats
GET
/api/admin/stats
Admin-only system stats
GET
/api/admin/users
List all users
PUT
/api/admin/users/{username}/role
Update user scopes
GET
/api/admin/tasks
View Celery tasks
GET
/api/admin/documents
Admin document vault
POST
/api/admin/documents/{id}/reingest
Re-queue document for ingestion
GET
/api/admin/graph/nodes
Search graph nodes
DELETE
/api/admin/graph/nodes/{id}
Delete a graph node
π§ͺ Testing & Benchmarking
# Run tests
uv run pytest
# With coverage
uv run pytest --cov=src/graph_rag_service
# Run SOTA Benchmarks against Hugging Face datasets (e.g. HotpotQA, MuSiQue)
uv run python benchmarks/run_benchmark.py
π Production Deployment
Process
Command
API Server
uv run python main.py
Celery Worker
uv run celery -A src.graph_rag_service.workers.celery_worker worker --loglevel=info --concurrency=4 --pool=threads
React Build
cd frontend-react && npm run build
The built React assets can be served directly by FastAPI (static file mount), or deployed to a CDN separately. Neo4j and Redis can be run via Docker, managed cloud services (AuraDB, Redis Cloud), or self-hosted.
π Additional Documentation
ARCHITECTURE.md β Deep dive into the system design, data flow, and component interactions