Skip to main content

subcog/storage/graph/
mod.rs

1//! Graph storage backends for knowledge graph operations.
2//!
3//! This module provides implementations of the [`GraphBackend`] trait for
4//! storing and querying entities, relationships, and entity mentions.
5//!
6//! # Available Backends
7//!
8//! | Backend | Use Case | Features |
9//! |---------|----------|----------|
10//! | [`SqliteGraphBackend`] | Default; embedded | Recursive CTEs for traversal |
11//! | [`InMemoryGraphBackend`] | Testing | Fast, no persistence |
12//!
13//! # Example
14//!
15//! ```rust,ignore
16//! use subcog::storage::graph::SqliteGraphBackend;
17//! use subcog::storage::traits::GraphBackend;
18//! use subcog::models::graph::{Entity, EntityType};
19//!
20//! let backend = SqliteGraphBackend::new("graph.db")?;
21//!
22//! // Store an entity
23//! let entity = Entity::builder()
24//!     .name("Alice")
25//!     .entity_type(EntityType::Person)
26//!     .build();
27//! backend.store_entity(&entity)?;
28//!
29//! // Query entities
30//! let people = backend.query_entities(&EntityQuery::new().with_type(EntityType::Person))?;
31//! ```
32
33mod memory;
34mod sqlite;
35
36pub use memory::InMemoryGraphBackend;
37pub use sqlite::SqliteGraphBackend;
38
39// Re-export trait for convenience
40pub use crate::storage::traits::graph::{GraphBackend, GraphStats};