How hydra-db/selfgraph works
SelfGraph is a Python and TypeScript SDK for turning text or supplied facts into a versioned, queryable knowledge graph. The main workflow accepts input through the graph client, optionally extracts facts, resolves entities, applies ontology and temporal rules, and stores them through a pluggable graph backend; retrieval returns graph-grounded context. The product also exposes schema/answerability, maintenance, change history, CLI, and MCP capabilities. The README documents the broad workflow and capabilities; source-index references support sampled module relationships, but unsampled internals are not asserted in detail.
Main entry points: client.py Graph Client · _ops.py Graph Records · insert.py Fact Insertion · schema.py Ontology and Schema
Components 20
SDK and Interfaces
- Graph Client
src/selfgraph/client.py - CLI
src/selfgraph/cli.py - MCP Server
src/selfgraph/mcp/server.py
Knowledge Processing
- Text Extraction
src/selfgraph/extraction/extractor.py - LLM Adapter
src/selfgraph/llm/base.py - Entity Resolution
src/selfgraph/resolution.py - Fact Insertion
src/selfgraph/insert.py
Query and Ontology
- Ontology and Schema
src/selfgraph/schema.py - Graph Retrieval
src/selfgraph/retrieval.py - Answerability Check
src/selfgraph/retrieval.py
Graph State
- Temporal Contradictions
src/selfgraph/contradiction.py - Graph Maintenance
src/selfgraph/_maintenance.py - Diff and Export
src/selfgraph/_diff.py - Graph Records
src/selfgraph/_ops.py
Graph Backends
- Neo4j / Bolt
src/selfgraph/stores/cypher.py - FalkorDB
src/selfgraph/stores/falkordb.py - HydraDB
src/selfgraph/stores/hydradb.py - Kuzu
src/selfgraph/stores/kuzu.py
Other components
- Application or Agent
- LLM Provider
Connections 24
- Application or Agent → Graph Client: uses
README.md - Application or Agent → CLI: invokes
README.md - Application or Agent → MCP Server: connects
README.md - Graph Client → Text Extraction: inserts text
src/selfgraph/client.py - Text Extraction → LLM Adapter: uses optionally
src/selfgraph/extraction/extractor.py - LLM Adapter → LLM Provider: calls optionally
README.md - Graph Client → Fact Insertion: inserts facts
README.md - Fact Insertion → Entity Resolution: resolves entities
README.md - Fact Insertion → Ontology and Schema: applies schema
src/selfgraph/schema.py - Fact Insertion → Temporal Contradictions: checks conflicts
README.md - Fact Insertion → Graph Records: writes graph
README.md - Graph Client → Graph Retrieval: retrieves context
README.md - Graph Retrieval → Ontology and Schema: grounds terms
src/selfgraph/retrieval.py - Graph Client → Answerability Check: checks question
README.md - Answerability Check → Ontology and Schema: checks grounding
README.md - Graph Client → Graph Maintenance: manages graph
src/selfgraph/client.py - Graph Client → Diff and Export: gets changes
README.md - Graph Maintenance → Graph Records: updates graph
src/selfgraph/resources/maintenance.py - Diff and Export → Graph Records: reads changes
README.md - Graph Records → Neo4j / Bolt: persists through
README.md - Graph Records → FalkorDB: persists through
README.md - Graph Records → HydraDB: persists through
README.md - Graph Records → Kuzu: persists through
README.md - MCP Server → Graph Client: serves API
src/selfgraph/mcp/server.py