Skip to content

manalilatkar/digital-memory-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 MemVault - AI-Powered Digital Memory System

Your personal AI memory assistant via WhatsApp - Store, search, and retrieve memories using natural language through text and voice.

🎯 Overview

MemVault is a multi-tenant digital memory system that integrates with WhatsApp to provide seamless memory storage and retrieval. Send text or voice messages to store memories, and query them using natural languageβ€”all encrypted and secure.

Key Features

  • πŸ” Multi-Tenant Authentication - Per-user isolation with WhatsApp phone verification
  • 🎀 Voice-to-Memory - Automatic speech-to-text conversion using OpenAI Whisper
  • 🧠 Intelligent Intent Detection - LLM-powered classification of store vs. query intents
  • πŸ” Hybrid Search - BM25 + Vector search for optimal retrieval accuracy
  • πŸ”’ Encryption at Rest - AES-256-GCM encryption for all stored memories
  • ⚑ Scalable Architecture - Designed for 1000s of concurrent users

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                              MEMVAULT ARCHITECTURE                          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  WhatsApp   │────▢│   Twilio API    │────▢│     FastAPI Backend      β”‚  β”‚
β”‚  β”‚   Client    │◀────│   (Webhook)     │◀────│                          β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚                                              β”‚  β”‚   Authentication   β”‚  β”‚  β”‚
β”‚                                              β”‚  β”‚   (Phone-based)    β”‚  β”‚  β”‚
β”‚                                              β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚                                              β”‚           β”‚              β”‚  β”‚
β”‚                                              β”‚           β–Ό              β”‚  β”‚
β”‚                                              β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚                                              β”‚  β”‚    LangGraph Flow  β”‚  β”‚  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚  β”‚                    β”‚  β”‚  β”‚
β”‚  β”‚         LANGGRAPH WORKFLOW          β”‚    β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚  β”‚
│  │                                     │    │  │  │ Voice→Text   │  │  │  │
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚    β”‚  β”‚  β”‚  (Whisper)   β”‚  β”‚  β”‚  β”‚
β”‚  β”‚  β”‚  Input  │───▢│   Intent    β”‚    β”‚    β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚  β”‚
β”‚  β”‚  β”‚ Process β”‚    β”‚  Classifier β”‚    β”‚    β”‚  β”‚         β”‚          β”‚  β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚   (LLM)     β”‚    β”‚    β”‚  β”‚         β–Ό          β”‚  β”‚  β”‚
β”‚  β”‚                 β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜    β”‚    β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚  β”‚
β”‚  β”‚                        β”‚           β”‚    β”‚  β”‚  β”‚   Intent     β”‚  β”‚  β”‚  β”‚
β”‚  β”‚           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”   β”‚    β”‚  β”‚  β”‚  Classifier  β”‚  β”‚  β”‚  β”‚
β”‚  β”‚           β”‚                    β”‚   β”‚    β”‚  β”‚  β”‚    (LLM)     β”‚  β”‚  β”‚  β”‚
β”‚  β”‚           β–Ό                    β–Ό   β”‚    β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚  β”‚
β”‚  β”‚    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚    β”‚  β”‚         β”‚          β”‚  β”‚  β”‚
β”‚  β”‚    β”‚  STORE   β”‚         β”‚  QUERY  β”‚β”‚    β”‚  β”‚    β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”     β”‚  β”‚  β”‚
β”‚  β”‚    β”‚  Memory  β”‚         β”‚ Search  β”‚β”‚    β”‚  β”‚    β”‚         β”‚     β”‚  β”‚  β”‚
β”‚  β”‚    β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜β”‚    β”‚  β”‚    β–Ό         β–Ό     β”‚  β”‚  β”‚
β”‚  β”‚         β”‚                    β”‚     β”‚    β”‚  β”‚  Store    Search   β”‚  β”‚  β”‚
β”‚  β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚    β”‚  β”‚  Memory   Memory   β”‚  β”‚  β”‚
β”‚  β”‚                  β–Ό                 β”‚    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚  β”‚         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”‚    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚  β”‚         β”‚  Response   β”‚            β”‚                                  β”‚
β”‚  β”‚         β”‚  Generator  β”‚            β”‚                                  β”‚
β”‚  β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β”‚                                  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                 β”‚
β”‚                                                                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚                         DATA LAYER                                β”‚   β”‚
β”‚  β”‚                                                                   β”‚   β”‚
β”‚  β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚   β”‚
β”‚  β”‚   β”‚   PostgreSQL     β”‚    β”‚           Qdrant                  β”‚   β”‚   β”‚
β”‚  β”‚   β”‚                  β”‚    β”‚                                   β”‚   β”‚   β”‚
β”‚  β”‚   β”‚  β€’ User accounts β”‚    β”‚  β€’ Vector embeddings (encrypted)  β”‚   β”‚   β”‚
β”‚  β”‚   β”‚  β€’ Auth tokens   β”‚    β”‚  β€’ BM25 sparse vectors            β”‚   β”‚   β”‚
β”‚  β”‚   β”‚  β€’ Audit logs    β”‚    β”‚  β€’ Multi-tenant collections       β”‚   β”‚   β”‚
β”‚  β”‚   β”‚  β€’ Usage metrics β”‚    β”‚  β€’ Hybrid search indexes          β”‚   β”‚   β”‚
β”‚  β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚    β”‚
β”‚  β”‚                                                                   β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”‚                                                                           β”‚
β”‚                                                                           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Project Structure

memvault/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/              # FastAPI routes & webhooks
β”‚   β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”‚   β”œβ”€β”€ routes.py     # API endpoints
β”‚   β”‚   β”‚   └── webhooks.py   # WhatsApp/Twilio webhooks
β”‚   β”‚   β”œβ”€β”€ core/             # Core configuration
β”‚   β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”‚   β”œβ”€β”€ config.py     # Settings & environment
β”‚   β”‚   β”‚   β”œβ”€β”€ security.py   # Encryption & auth
β”‚   β”‚   β”‚   └── exceptions.py # Custom exceptions
β”‚   β”‚   β”œβ”€β”€ db/               # Database layer
β”‚   β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”‚   β”œβ”€β”€ postgres.py   # PostgreSQL models & queries
β”‚   β”‚   β”‚   └── qdrant.py     # Qdrant vector DB operations
β”‚   β”‚   β”œβ”€β”€ llm/              # LangGraph & AI components
β”‚   β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”‚   β”œβ”€β”€ graph.py      # LangGraph workflow
β”‚   β”‚   β”‚   β”œβ”€β”€ embeddings.py # Text embeddings
β”‚   β”‚   β”‚   └── whisper.py    # Speech-to-text
β”‚   β”‚   β”œβ”€β”€ services/         # Business logic
β”‚   β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”‚   β”œβ”€β”€ memory.py     # Memory CRUD operations
β”‚   β”‚   β”‚   └── search.py     # Hybrid search implementation 
β”‚   β”‚   └── main.py           # FastAPI application entry
β”‚   β”œβ”€β”€ tests/                # Test suite
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ conftest.py       # Pytest fixtures
β”‚   β”‚   β”œβ”€β”€ test_api.py       # API endpoint tests
β”‚   β”‚   β”œβ”€β”€ test_graph.py     # LangGraph workflow tests
β”‚   β”‚   β”œβ”€β”€ test_search.py    # Search functionality tests
β”‚   β”‚   └── test_security.py  # Encryption tests
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── pyproject.toml                 # Kubernetes manifests
β”œβ”€β”€ docs/                     # Documentation
β”‚   β”œβ”€β”€ api.md                # API documentation
β”‚   β”œβ”€β”€ deployment.md         # Deployment guide
β”‚   └── architecture.png      # Architecture diagram
β”œβ”€β”€ scripts/                  # Utility scripts
β”‚   β”œβ”€β”€ setup.sh              # Development setup
β”‚   └── migrate.py            # Database migrations
β”œβ”€β”€ .env.example              # Environment template
β”œβ”€β”€ .gitignore
β”œβ”€β”€ LICENSE
└── README.md

πŸš€ Quick Start

Prerequisites

  • Python 3.11+
  • Docker & Docker Compose
  • Twilio account with WhatsApp sandbox
  • OpenAI API key
  • Qdrant Cloud or local instance

1. Clone & Setup

git clone https://github.com/yourusername/memvault.git
cd memvault

# Copy environment template
cp .env.example .env

2. Configure Environment Variables

Edit .env with your credentials:

# API Keys
OPENAI_API_KEY=sk-...
TWILIO_ACCOUNT_SID=AC...
TWILIO_AUTH_TOKEN=...
TWILIO_WHATSAPP_NUMBER=

# Database
POSTGRES_URL=postgresql://user:pass@localhost:5432/memvault
QDRANT_URL=http://localhost:6333
QDRANT_API_KEY=your-qdrant-key

# Security
ENCRYPTION_KEY=your-32-byte-base64-key
JWT_SECRET=your-jwt-secret

# Observability
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
PROMETHEUS_PORT=9090

3. Start with Docker Compose

# Start all services (dev mode)
docker-compose up -d

# Check logs
docker-compose logs -f backend

4. Configure Twilio Webhook

  1. Go to Twilio Console
  2. Set webhook URL: https://your-domain.com/api/v1/webhook/whatsapp
  3. Join the sandbox: Send "join " to the WhatsApp number

5. Test It Out

Send a message to your WhatsApp bot:

  • Store a memory: "Remember that my favorite restaurant is Sushi Ko on Main Street"
  • Query memories: "What's my favorite restaurant?"
  • Voice notes: Send a voice message and it will be transcribed and processed

πŸ”§ Configuration

Environment Variables Reference

Variable Description Required
OPENAI_API_KEY OpenAI API key for embeddings & LLM βœ…
TWILIO_ACCOUNT_SID Twilio account SID βœ…
TWILIO_AUTH_TOKEN Twilio auth token βœ…
TWILIO_WHATSAPP_NUMBER WhatsApp-enabled number βœ…
POSTGRES_URL PostgreSQL connection string βœ…
QDRANT_URL Qdrant server URL βœ…
QDRANT_API_KEY Qdrant API key ❌
ENCRYPTION_KEY 32-byte base64 key for AES-256 βœ…
JWT_SECRET Secret for JWT tokens βœ…
LOG_LEVEL Logging level (DEBUG/INFO/WARNING) ❌
MAX_MEMORIES_PER_USER Memory limit per user ❌
OTEL_EXPORTER_OTLP_ENDPOINT OpenTelemetry endpoint ❌

Generating Encryption Key

python -c "import secrets; import base64; print(base64.b64encode(secrets.token_bytes(32)).decode())"

πŸ§ͺ Testing

# Run all tests
pytest

# Run with coverage
pytest --cov=app --cov-report=html

# Run specific test file
pytest tests/test_api.py -v

# Run integration tests
pytest tests/ -m integration

🚒 Deployment

Docker (Recommended)

# Build production image
docker build -t memvault:latest ./backend

# Run with production compose
docker-compose -f infra/docker-compose.prod.yml up -d

Environment-Specific Configs

Environment Config File Notes
Development docker-compose.yml Hot reload, debug logging
Staging docker-compose.staging.yml Test webhooks, sandbox
Production docker-compose.prod.yml Full HA, autoscaling

πŸ” Security

Encryption

  • At Rest: AES-256-GCM encryption for all memory content
  • In Transit: TLS 1.3 for all connections
  • Keys: Environment-based key management (use Vault in production)

Authentication

  • Phone number verification via Twilio
  • JWT tokens with configurable expiry
  • Rate limiting per user

Multi-Tenancy

  • Complete data isolation per user
  • Separate Qdrant collections per tenant
  • Row-level security in PostgreSQL

πŸ“ˆ Scaling

Database Scaling

  • PostgreSQL: Connection pooling with PgBouncer
  • Qdrant: Distributed mode with sharding

Horizontal Scaling

  • Stateless FastAPI workers behind load balancer
  • Redis for session state (if needed)
  • Kubernetes HPA for auto-scaling

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/great-feature)
  3. Commit changes (git commit -m 'Add great feature')
  4. Push to branch (git push origin feature/great-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file.

πŸ™ Acknowledgments



vibe coded with ❀️ for the future of personal memory

About

A vector DB based digital memory tool with whatsapp interface

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors