zoey-storage-mongo

Crates.iozoey-storage-mongo
lib.rszoey-storage-mongo
version0.1.1
created_at2026-01-09 23:40:02.34412+00
updated_at2026-01-09 23:56:20.269482+00
descriptionMongoDB database adapter for ZoeyAI
homepage
repositoryhttps://github.com/Agent-Zoey/Zoey.git
max_upload_size
id2033163
size233,289
Christopher Freytes (Freytes)

documentation

README

Zoey

Always watching over your data

πŸ—„οΈ zoey-storage-mongo

Crates.io Documentation License: MIT

MongoDB storage adapter for ZoeyAI

A MongoDB implementation of the IDatabaseAdapter trait from zoey-core. Provides document-based storage with local vector search capabilities.

Installation

Add to your Cargo.toml:

[dependencies]
zoey-core = "0.1"
zoey-storage-mongo = "0.1"

Features

  • πŸƒ MongoDB Native - Full MongoDB driver integration
  • πŸ” Vector Search - Local cosine similarity search (no Atlas required)
  • πŸ“Š Schema Management - Automatic collection and index creation
  • πŸ” HIPAA Ready - Optional compliance features

Quick Start

use zoey_core::{AgentRuntime, RuntimeOpts, IDatabaseAdapter};
use zoey_storage_mongo::MongoAdapter;
use std::sync::Arc;

#[tokio::main]
async fn main() -> zoey_core::Result<()> {
    // Create MongoDB adapter
    let mut adapter = MongoAdapter::new(
        "mongodb://localhost:27017",
        "zoey_db"
    );
    
    // Initialize (creates collections and indexes)
    adapter.init().await?;
    
    // Use with runtime
    let opts = RuntimeOpts::default()
        .with_adapter(Arc::new(adapter));
    
    let runtime = AgentRuntime::new(opts).await?;
    
    Ok(())
}

Vector Search

This adapter implements local vector search using MongoDB aggregation pipelines with cosine similarity calculationβ€”no MongoDB Atlas required.

use zoey_storage_mongo::vector_search::MongoVectorSearch;

let searcher = MongoVectorSearch::new(collection, 1536);

let results = searcher.search(SearchMemoriesParams {
    embedding: query_vector,
    count: 10,
    ..Default::default()
}).await?;

Configuration

Environment Variables

MONGODB_URI=mongodb://localhost:27017
MONGODB_DATABASE=zoey_db

Connection Options

// Local development
let adapter = MongoAdapter::new("mongodb://localhost:27017", "zoey_db");

// With authentication
let adapter = MongoAdapter::new(
    "mongodb://user:password@localhost:27017",
    "zoey_db"
);

// Replica set
let adapter = MongoAdapter::new(
    "mongodb://host1:27017,host2:27017,host3:27017/?replicaSet=rs0",
    "zoey_db"
);

Related Crates

Crate Description
zoey-core Core runtime and IDatabaseAdapter trait
zoey-storage-sql SQLite & PostgreSQL adapters
zoey-storage-supabase Supabase adapter
zoey-storage-vector Local vector storage

License

MIT License - See LICENSE for details.


πŸ” Your secrets are safe with Zoey

Commit count: 12

cargo fmt