- Configure mem0 to use self-hosted Supabase instead of Qdrant for vector storage - Update docker-compose to connect containers to localai network - Install vecs library for Supabase pgvector integration - Create comprehensive test suite for Supabase + mem0 integration - Update documentation to reflect Supabase configuration - All containers now connected to shared localai network - Successful vector storage and retrieval tests completed 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
151 lines
3.8 KiB
Plaintext
151 lines
3.8 KiB
Plaintext
---
|
|
title: 'Architecture Overview'
|
|
description: 'Understanding the Mem0 Memory System architecture and components'
|
|
---
|
|
|
|
## System Architecture
|
|
|
|
The Mem0 Memory System follows a modular, local-first architecture designed for maximum privacy, performance, and control.
|
|
|
|
```mermaid
|
|
graph TB
|
|
A[AI Applications] --> B[MCP Server - Port 8765]
|
|
B --> C[Memory API - Port 8080]
|
|
C --> D[Mem0 Core v0.1.115]
|
|
D --> E[Vector Store - Qdrant]
|
|
D --> F[Graph Store - Neo4j]
|
|
D --> G[LLM Provider]
|
|
G --> H[Ollama - Port 11434]
|
|
G --> I[OpenAI/Remote APIs]
|
|
E --> J[Qdrant - Port 6333]
|
|
F --> K[Neo4j - Port 7687]
|
|
```
|
|
|
|
## Core Components
|
|
|
|
### Memory Layer (Mem0 Core)
|
|
- **Version**: 0.1.115
|
|
- **Purpose**: Central memory management and coordination
|
|
- **Features**: Memory operations, provider abstraction, configuration management
|
|
|
|
### Vector Storage (Qdrant)
|
|
- **Port**: 6333 (REST), 6334 (gRPC)
|
|
- **Purpose**: High-performance vector search and similarity matching
|
|
- **Features**: Collections management, semantic search, embeddings storage
|
|
|
|
### Graph Storage (Neo4j)
|
|
- **Port**: 7474 (HTTP), 7687 (Bolt)
|
|
- **Version**: 5.23.0
|
|
- **Purpose**: Entity relationships and contextual memory connections
|
|
- **Features**: Knowledge graph, relationship mapping, graph queries
|
|
|
|
### LLM Providers
|
|
|
|
#### Ollama (Local)
|
|
- **Port**: 11434
|
|
- **Models Available**: 21+ including Llama, Qwen, embeddings
|
|
- **Benefits**: Privacy, cost control, offline operation
|
|
|
|
#### OpenAI (Remote)
|
|
- **API**: External service
|
|
- **Models**: GPT-4, embeddings
|
|
- **Benefits**: State-of-the-art performance, reliability
|
|
|
|
## Data Flow
|
|
|
|
### Memory Addition
|
|
1. **Input**: User messages or content
|
|
2. **Processing**: LLM extracts facts and relationships
|
|
3. **Storage**:
|
|
- Facts stored as vectors in Qdrant
|
|
- Relationships stored as graph in Neo4j
|
|
4. **Indexing**: Content indexed for fast retrieval
|
|
|
|
### Memory Retrieval
|
|
1. **Query**: Semantic search query
|
|
2. **Vector Search**: Qdrant finds similar memories
|
|
3. **Graph Traversal**: Neo4j provides contextual relationships
|
|
4. **Ranking**: Combined scoring and relevance
|
|
5. **Response**: Structured memory results
|
|
|
|
## Configuration Architecture
|
|
|
|
### Environment Management
|
|
```bash
|
|
# Core Services
|
|
NEO4J_URI=bolt://localhost:7687
|
|
QDRANT_URL=http://localhost:6333
|
|
OLLAMA_BASE_URL=http://localhost:11434
|
|
|
|
# Provider Selection
|
|
LLM_PROVIDER=ollama # or openai
|
|
VECTOR_STORE=qdrant
|
|
GRAPH_STORE=neo4j
|
|
```
|
|
|
|
### Provider Abstraction
|
|
The system supports multiple providers through a unified interface:
|
|
|
|
- **LLM Providers**: OpenAI, Ollama, Anthropic, etc.
|
|
- **Vector Stores**: Qdrant, Pinecone, Weaviate, etc.
|
|
- **Graph Stores**: Neo4j, Amazon Neptune, etc.
|
|
|
|
## Security Architecture
|
|
|
|
### Local-First Design
|
|
- All data stored locally
|
|
- No external dependencies required
|
|
- Full control over data processing
|
|
|
|
### Authentication Layers
|
|
- API key management
|
|
- Rate limiting
|
|
- Access control per user/application
|
|
|
|
### Network Security
|
|
- Services bound to localhost by default
|
|
- Configurable network policies
|
|
- TLS support for remote connections
|
|
|
|
## Scalability Considerations
|
|
|
|
### Horizontal Scaling
|
|
- Qdrant cluster support
|
|
- Neo4j clustering capabilities
|
|
- Load balancing for API layer
|
|
|
|
### Performance Optimization
|
|
- Vector search optimization
|
|
- Graph query optimization
|
|
- Caching strategies
|
|
- Connection pooling
|
|
|
|
## Deployment Patterns
|
|
|
|
### Development
|
|
- Docker Compose for local services
|
|
- Python virtual environment
|
|
- File-based configuration
|
|
|
|
### Production
|
|
- Container orchestration
|
|
- Service mesh integration
|
|
- Monitoring and logging
|
|
- Backup and recovery
|
|
|
|
## Integration Points
|
|
|
|
### MCP Protocol
|
|
- Standardized AI tool integration
|
|
- Claude Code compatibility
|
|
- Protocol-based communication
|
|
|
|
### API Layer
|
|
- RESTful endpoints
|
|
- OpenAPI specification
|
|
- SDK support multiple languages
|
|
|
|
### Webhook Support
|
|
- Event-driven updates
|
|
- Real-time notifications
|
|
- Integration with external systems |