synaptic_postgres/lib.rs
1//! PostgreSQL integration for the Synaptic framework.
2//!
3//! This crate provides PostgreSQL-backed implementations of Synaptic traits:
4//!
5//! - [`PgVectorStore`] — [`VectorStore`](synaptic_core::VectorStore) using the
6//! [pgvector](https://github.com/pgvector/pgvector) extension for cosine-distance
7//! similarity search.
8//! - [`PgStore`] — [`Store`](synaptic_core::Store) for key-value storage with JSONB
9//! values and optional full-text search via `tsvector`.
10//! - [`PgCache`] — [`LlmCache`](synaptic_core::LlmCache) for caching LLM responses
11//! with optional TTL expiration.
12//! - [`PgCheckpointer`] — Graph checkpoint persistence (requires `checkpointer` feature).
13//!
14//! # Quick start
15//!
16//! ```rust,no_run
17//! use sqlx::postgres::PgPoolOptions;
18//! use synaptic_postgres::{PgVectorConfig, PgVectorStore};
19//!
20//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
21//! let pool = PgPoolOptions::new()
22//! .max_connections(5)
23//! .connect("postgres://user:pass@localhost/mydb")
24//! .await?;
25//!
26//! let config = PgVectorConfig::new("documents", 1536);
27//! let store = PgVectorStore::new(pool, config);
28//! store.initialize().await?;
29//! # Ok(())
30//! # }
31//! ```
32
33mod cache;
34#[cfg(feature = "checkpointer")]
35pub mod checkpointer;
36mod store;
37mod vector_store;
38
39pub use cache::{PgCache, PgCacheConfig};
40#[cfg(feature = "checkpointer")]
41pub use checkpointer::PgCheckpointer;
42pub use store::{PgStore, PgStoreConfig};
43pub use vector_store::{PgVectorConfig, PgVectorStore};
44
45// Re-export core traits/types for convenience.
46pub use synaptic_core::{ChatResponse, Document, Embeddings, Item, LlmCache, Store, VectorStore};