cognee_graph/lib.rs
1//! Graph database abstraction layer for Cognee.
2//!
3//! This crate provides a trait-based interface for graph database operations,
4//! enabling pluggable graph database backends for knowledge graph storage.
5//!
6//! # Architecture
7//!
8//! - `GraphDBTrait` - Async trait defining graph database operations
9//! - `LadybugAdapter` - Implementation using Ladybug (lbug) embedded graph database
10//! - `GraphNode` / `GraphEdge` - Type aliases for node and edge data
11//!
12//! # Example
13//!
14//! ```ignore
15//! use cognee_graph::{GraphDBTrait, LadybugAdapter};
16//! use cognee_models::Entity;
17//!
18//! let db = LadybugAdapter::new("./graph_data").await?;
19//! db.initialize().await?;
20//!
21//! let entity = Entity::new("Alice", EntityType::new("Person", None), Some("user-1"));
22//! db.add_node(&entity).await?;
23//! ```
24
25mod error;
26mod formatted;
27mod traits;
28mod types;
29
30#[cfg(feature = "ladybug")]
31mod ladybug;
32
33#[cfg(feature = "postgres")]
34mod pg_graph_adapter;
35
36#[cfg(any(test, feature = "testing"))]
37pub mod mock;
38
39pub use error::{GraphDBError, GraphDBResult};
40pub use formatted::get_formatted_graph_data;
41pub use traits::{EdgeKey, GraphDBTrait, GraphDBTraitExt};
42pub use types::{EdgeData, GraphEdge, GraphNode, NodeData};
43
44#[cfg(feature = "ladybug")]
45pub use ladybug::LadybugAdapter;
46
47#[cfg(feature = "postgres")]
48pub use pg_graph_adapter::PgGraphAdapter;
49
50#[cfg(any(test, feature = "testing"))]
51pub use mock::MockGraphDB;