Storage Backends Overview
The Context Graph uses a polyglot persistence strategy with three complementary storage backends: Dgraph for graph relationships and thinking traces, Pinecone/Qdrant for vector similarity search, and PostgreSQL with TimescaleDB for bi-temporal versioning. Each backend is optimized for specific query patterns while maintaining tenant isolation across all layers.
Storage Architecture
+------------------+ +------------------+ +-------------------+
| Dgraph | | Pinecone | | PostgreSQL |
| (Graph Store) | | (Vector Store) | | (Bi-Temporal) |
| | | | | |
| - Entities | | - Entity embeds | | - Events |
| - Relationships | | - Decision vecs | | - Decisions |
| - Thinking traces| | - Trajectory vecs| | - Entity versions |
| - API call logs | | - Query patterns | | - Version history |
+------------------+ +------------------+ +-------------------+
| | |
+----------+------------+------------------------+
|
+-------v--------+
| Hybrid Store |
| (GraphRAG) |
+----------------+Backend Selection Guide
| Query Type | Recommended Backend | Reason |
|---|---|---|
| Entity relationships and lineage | Dgraph | Native graph traversal |
| Semantic similarity search | Pinecone | ANN vector search |
| Point-in-time entity state | PostgreSQL | Bi-temporal queries |
| Combined semantic + structural | Hybrid Store | Merges both backends |
| Decision precedent search | Pinecone + PostgreSQL | Embedding match + metadata filter |
| Version history and audit | PostgreSQL | Full version chain |
Subsections
| Page | Description |
|---|---|
| Dgraph Context Store | GraphQL-based CRUD for thinking traces and entity relationships |
| Hybrid Store (GraphRAG) | Combined graph + vector retrieval with configurable strategies |
| Vector Stores | Pinecone and Qdrant implementations for embedding storage |
| Bitemporal Versioning | PostgreSQL + TimescaleDB bi-temporal data management |
Singleton Pattern
All storage backends follow the singleton factory pattern for lifecycle management:
from context_graph.storage.dgraph_context_store import (
create_dgraph_context_store,
get_dgraph_context_store,
)
from context_graph.storage.hybrid_store import (
create_hybrid_store,
get_hybrid_store,
)
from context_graph.storage.bitemporal_store import (
create_bitemporal_store,
get_bitemporal_store,
)Each store exposes initialize(), close(), and health_check() methods for lifecycle management within the application startup and shutdown hooks.