Architecture
The memory system consists of three components:- Vector Store - Supabase PostgreSQL with pgvector for semantic search
- Graph Store - Neo4j for knowledge graph relationships (optional)
- Memory Backend - FastAPI server running Mem0
Configuration
Backend Environment
Configure the memory backend inbackend/.env:
Frontend Configuration
Point the frontend and Next.js backend to the memory API:Mem0 Configuration
The memory backend uses the following configuration (frombackend/main.py:36-76):
backend/main.py
Configuration Options
| Variable | Default | Description |
|---|---|---|
SUPABASE_COLLECTION_NAME | memories | Collection name for vector storage |
SUPABASE_INDEX_METHOD | hnsw | Vector index method (hnsw or ivfflat) |
SUPABASE_INDEX_MEASURE | cosine_distance | Distance metric for similarity search |
Vector Store Setup
Tabby uses a local Supabase instance running in Docker for vector storage.Note Credentials
Copy the DB URL from the output:Look for
DB URL (format: postgresql://postgres:[email protected]:54322/postgres)The database schema is automatically applied from
supabase/migrations/ when Supabase starts.Supabase Commands
| Command | Description |
|---|---|
npx supabase start | Start local Supabase |
npx supabase stop | Stop Supabase containers |
npx supabase status | View connection details |
npx supabase db reset | Reset database to migrations |
Neo4j Knowledge Graph (Optional)
Neo4j provides a knowledge graph visualization of memory relationships, enhancing contextual understanding.Setup Neo4j AuraDB
Create Free Instance
Visit Neo4j AuraDB and create a free instance.
Save Credentials
Download the credentials text file when creating the instance. It contains:
- URI (e.g.,
neo4j+s://xxx.databases.neo4j.io) - Username (usually
neo4j) - Password
The graph store is automatically enabled when
NEO4J_URL and NEO4J_PASSWORD are set.Benefits of Neo4j Integration
- Relationship Mapping - Visualize connections between memories
- Contextual Retrieval - Better understanding of related concepts
- Knowledge Graph - See how information connects over time
- Brain Panel Visualization - Interactive graph view in the app
Memory Types
Tabby automatically classifies memories into five types using AI:| Type | Description | Examples |
|---|---|---|
| SHORT_TERM | Temporary states, current activities | ”Currently working on…”, “Right now I’m…” |
| LONG_TERM | Permanent preferences, identity | ”I prefer dark mode”, “My name is…” |
| EPISODIC | Past events with time context | ”Yesterday I had a meeting” |
| SEMANTIC | General knowledge and facts | ”Python uses indentation” |
| PROCEDURAL | How-to knowledge, processes | ”To deploy, run npm build” |
Memory classification uses OpenAI’s
gpt-4.1-nano-2025-04-14 model and happens automatically when memories are added.Starting the Memory Backend
- Development
- Production (Azure)
http://localhost:8000 with auto-reload enabled.Memory API Endpoints
The FastAPI backend provides the following endpoints:Core Operations
| Endpoint | Method | Description |
|---|---|---|
/memory/add | POST | Add memories from conversation |
/memory/search | POST | Search memories by query |
/memory/get_all | POST | Get all memories for a user |
/memory/{memory_id} | GET | Get specific memory by ID |
/memory/update | PUT | Update existing memory |
/memory/{memory_id} | DELETE | Delete specific memory |
/memory/user/{user_id} | DELETE | Delete all user memories |
Special Features
| Endpoint | Method | Description |
|---|---|---|
/memory/add_image | POST | Add image-based memory with vision |
/memory/history/{memory_id} | GET | Get memory change history |
All memory operations support automatic type classification and metadata filtering.
Alternative Vector Store
Mem0 also supports ChromaDB as an alternative to Supabase. To use Chroma:backend/main.py
Troubleshooting
Memory backend won't start
Memory backend won't start
Check OpenAI API key: The backend requires Check Python dependencies:
OPENAI_API_KEY in backend/.envVerify Supabase is running:Memories not persisting
Memories not persisting
Verify connection string: Ensure Test database connection: Visit Studio at
SUPABASE_CONNECTION_STRING points to the correct local databaseCheck Supabase logs:http://localhost:54323 → SQL EditorNeo4j graph not showing
Neo4j graph not showing
Verify credentials: Check that all
NEO4J_* variables are set in backend/.envTest connection: Visit your Neo4j instance dashboard to verify it’s activeCheck backend logs: The startup message shows if graph store is enabledVision memories failing
Vision memories failing
Verify image URLs: Ensure image URLs are accessibleCheck OpenAI API: Vision features require
enable_vision: True and proper API accessReview request format: Image URLs must be in the correct format (see API endpoint docs)Best Practices
Memory Management
- Use memory types to organize and filter memories effectively
- Enable auto-classification for automatic memory categorization
- Add metadata for better search and filtering
- Regularly review memories in the Brain Panel
Performance
- Use HNSW indexing for faster similarity search (default)
- Set appropriate search limits to avoid overwhelming results
- Consider Neo4j for complex relationship queries
- Monitor vector store size and clean up old memories
Security
- Keep Supabase local for development (Docker)
- Use secure connections for production Neo4j (SSL/TLS)
- Rotate database passwords regularly
- Never commit
.envfiles with credentials
Next Steps
AI Providers
Configure OpenAI and other AI providers
Application Settings
Customize Tabby settings and preferences