This guide will help you quickly set up and launch the Intelligent Memory System project.
- Requirements
- Install Dependencies
- Environment Configuration
- Start Infrastructure
- Start Services
- VSCode Debug Launch
- Run Test Scripts
- Development Debugging
- Common Issues
- Operating System: macOS, Linux, Windows
- Python Version: 3.12+
- Package Manager: uv (recommended)
- Docker: Required for local infrastructure (MongoDB, Elasticsearch, Milvus, Redis)
- MongoDB: For storing memory data
- Redis: For caching and task queues
- Elasticsearch: For full-text search
- Milvus: For vector retrieval
uv is a fast Python package manager, highly recommended.
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows (PowerShell)
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
# Verify installation
uv --versiongit clone <project-url>
cd memsys_opensource# uv will automatically create a virtual environment and install all dependencies
uv synccp env.template .envEdit the .env file and fill in actual values for the following required items:
# LLM provider and model
LLM_PROVIDER=openrouter
LLM_MODEL=x-ai/grok-4-fast
LLM_TEMPERATURE=0.3
LLM_MAX_TOKENS=32768
# OpenRouter API key (or your preferred provider)
OPENROUTER_API_KEY=sk-or-v1-your-key
OPENROUTER_BASE_URL=https://openrouter.ai/api/v1Supported providers: openrouter, openai. Set the corresponding {PROVIDER}_API_KEY and {PROVIDER}_BASE_URL.
# Primary provider: vllm (self-deployed) or deepinfra (commercial API)
VECTORIZE_PROVIDER=deepinfra
VECTORIZE_API_KEY=your-deepinfra-key
VECTORIZE_BASE_URL=https://api.deepinfra.com/v1/openai
VECTORIZE_MODEL=Qwen/Qwen3-Embedding-4B
VECTORIZE_DIMENSIONS=1024# Primary provider: vllm or deepinfra
RERANK_PROVIDER=deepinfra
RERANK_API_KEY=your-deepinfra-key
RERANK_BASE_URL=https://api.deepinfra.com/v1/inference
RERANK_MODEL=Qwen/Qwen3-Reranker-4BThe defaults in env.template match the Docker Compose services. If using local Docker, no changes needed:
# Tenant ID (required, use t_{yourname} for local dev)
TENANT_SINGLE_TENANT_ID=t_yourname
# MongoDB (default: local Docker)
MONGODB_HOST=localhost
MONGODB_PORT=27017
MONGODB_USERNAME=admin
MONGODB_PASSWORD=memsys123
# Elasticsearch (default: local Docker, port 19200)
ES_HOSTS=http://localhost:19200
ES_VERIFY_CERTS=false
# Milvus (default: local Docker)
MILVUS_HOST=localhost
MILVUS_PORT=19530
# Redis (default: local Docker)
REDIS_HOST=localhost
REDIS_PORT=6379Note:
TENANT_SINGLE_TENANT_IDis required. All storage resources will be prefixed with this value (e.g.,t_yourname_memsys). Uset_{yourname}to avoid conflicts with other developers on shared infrastructure.
- OpenRouter: Register at openrouter.ai and create an API key
- DeepInfra: Register at deepinfra.com and create an API key (for Embedding + Rerank)
Start MongoDB, Elasticsearch, Milvus, and Redis via Docker Compose:
docker-compose up -dWait for all services to be healthy (about 30-60 seconds on first run). Check status:
docker-compose ps# Default port 1995
uv run python src/run.py
# Specify port
uv run python src/run.py --port 8080
# Enable debug logging
LOG_LEVEL=DEBUG uv run python src/run.py| Parameter | Description | Default |
|---|---|---|
--host |
Listening address | 0.0.0.0 |
--port |
Port | 1995 |
--env-file |
Environment variable file | .env |
--mock |
Enable Mock mode | disabled |
After startup, visit API documentation: http://localhost:1995/docs
For async task processing:
uv run .venv/bin/arq task.WorkerSettingsFor persistent background processes (e.g., Kafka consumer):
uv run python src/run.py --longjob kafka_consumerThe project includes pre-configured launch configurations in .vscode/launch.json. Open the project in VSCode and press F5 or use the Run and Debug panel:
| Configuration | Description |
|---|---|
Python 调试程序: run |
Start API service (most common) |
Python 调试程序: task |
Start Task Worker |
Python 调试程序: longjob |
Start Long Job (e.g., Kafka consumer) |
Python 调试程序: run_this_file |
Run the currently open file via bootstrap |
All configurations automatically read the .env file and support full breakpoint debugging.
src/bootstrap.py is a universal script runner that handles environment setup, DI initialization, and application context automatically.
# Basic usage
uv run python src/bootstrap.py <script-path> [args...]
# Examples
uv run python src/bootstrap.py demo/extract_memory.py
uv run python src/bootstrap.py demo/chat_with_memory.py
# Enable mock mode
uv run python src/bootstrap.py your_script.py --mock
# Use custom env file
uv run python src/bootstrap.py your_script.py --env-file .env.testPYTHONPATH=src pytest tests/
PYTHONPATH=src pytest tests/path/to/test_file.pyUse Mock mode to bypass external dependencies during development:
# Command line
uv run python src/run.py --mock
# Environment variable
export MOCK_MODE=true
uv run python src/run.pyLOG_LEVEL=DEBUG uv run python src/run.pyuv cache clean
uv synccp env.template .env# Check logs
docker-compose logs mongodb
docker-compose logs elasticsearch
# Restart specific service
docker-compose restart milvus# Check port usage
lsof -i :1995
# Use a different port
uv run python src/run.py --port 8080# Ensure running from project root
pwd # Should be .../memsys_opensource
# Reinstall dependencies
uv sync --reinstallAfter running uv sync in memsys_opensource, enterprise's editable install is lost. Re-install:
source .venv/bin/activate
cd ../memsys_enterprise
pip install -e .- Read Development Guide: Check development_guide.md for architecture and best practices
- View API Documentation: Visit
http://localhost:1995/docsfor available API endpoints - Run Demos: Try example scripts in the
demo/directory - Read Bootstrap Guide: See bootstrap_usage.md for script runner details