This file provides project context for AI coding assistants (Claude Code, GitHub Copilot, Cursor, Codeium, etc.) to better understand and work with this project.
Maintainer Note: Keep this file updated when project structure changes.
EverMemOS is an enterprise-grade long-term memory system for conversational AI agents.
| Attribute | Value |
|---|---|
| Language | Python 3.12 |
| Framework | FastAPI + LangChain |
| Package Manager | uv |
| Version | v1.1.0 |
| License | Apache 2.0 |
┌─────────────────────────────────────────────────────┐
│ API Layer (FastAPI) │
│ infra_layer/adapters/input/api/ │
├─────────────────────────────────────────────────────┤
│ Service Layer │
│ service/ │
├─────────────────────────────────────────────────────┤
│ Business Logic Layer │
│ biz_layer/ │
├─────────────────────────────────────────────────────┤
│ Agentic Layer │
│ (Memory Management, Vectorization, Retrieval) │
│ agentic_layer/ │
├─────────────────────────────────────────────────────┤
│ Memory Layer │
│ (MemCell, Episode, Profile Extraction) │
│ memory_layer/ │
├─────────────────────────────────────────────────────┤
│ Core Layer │
│ (DI, Middleware, Multi-tenancy, Cache) │
│ core/ │
├─────────────────────────────────────────────────────┤
│ Infrastructure Layer │
│ (MongoDB, Milvus, Elasticsearch, Redis) │
│ infra_layer/adapters/out/ │
└─────────────────────────────────────────────────────┘
EverMemOS/
├── src/ # Main source code
│ ├── run.py # Application entry point
│ ├── app.py # FastAPI app configuration
│ ├── base_app.py # Base application setup
│ ├── bootstrap.py # Bootstrap and initialization
│ ├── application_startup.py # Startup hooks
│ ├── manage.py # Management commands
│ ├── run_memorize.py # Batch memorization runner
│ ├── task.py # Task definitions
│ ├── addon.py # Plugin system
│ ├── project_meta.py # Project metadata
│ │
│ ├── agentic_layer/ # Memory orchestration
│ │ ├── memory_manager.py # Core memory manager
│ │ ├── vectorize_service.py # Embedding service
│ │ ├── rerank_service.py # Reranking service
│ │ ├── fetch_mem_service.py # Memory retrieval
│ │ ├── agentic_utils.py # Agentic utilities
│ │ ├── retrieval_utils.py # Retrieval utilities
│ │ ├── vectorize_base.py # Base vectorizer
│ │ ├── vectorize_vllm.py # VLLM vectorizer
│ │ ├── vectorize_deepinfra.py # DeepInfra vectorizer
│ │ ├── rerank_vllm.py # VLLM reranker
│ │ ├── rerank_deepinfra.py # DeepInfra reranker
│ │ └── metrics/ # Performance metrics
│ │
│ ├── memory_layer/ # Memory extraction
│ │ ├── memory_manager.py # Memory extraction coordinator
│ │ ├── constants.py # Constants
│ │ ├── memcell_extractor/ # Atomic memory extraction
│ │ ├── memory_extractor/ # High-level extractors
│ │ │ ├── episode_memory_extractor.py
│ │ │ ├── profile_memory_extractor.py
│ │ │ ├── group_profile_memory_extractor.py
│ │ │ ├── foresight_extractor.py
│ │ │ └── event_log_extractor.py
│ │ ├── cluster_manager/ # Memory clustering
│ │ ├── profile_manager/ # Profile management
│ │ ├── llm/ # LLM providers
│ │ │ ├── llm_provider.py
│ │ │ ├── openai_provider.py
│ │ │ ├── protocol.py
│ │ │ └── config.py
│ │ └── prompts/ # Prompt templates
│ │ ├── en/ # English prompts
│ │ └── zh/ # Chinese prompts
│ │
│ ├── core/ # Framework infrastructure
│ │ ├── di/ # Dependency injection
│ │ ├── tenants/ # Multi-tenancy
│ │ ├── middleware/ # HTTP middleware
│ │ ├── cache/ # Caching layer
│ │ ├── events/ # Event system
│ │ ├── addons/ # Plugin framework
│ │ ├── asynctasks/ # Async task framework
│ │ ├── authorize/ # Authorization
│ │ ├── capability/ # Capability framework
│ │ ├── class_annotations/ # Class annotations
│ │ ├── component/ # Component system
│ │ ├── config/ # Configuration
│ │ ├── constants/ # Constants
│ │ ├── context/ # Context management
│ │ ├── interface/ # Interface definitions
│ │ ├── lifespan/ # FastAPI lifespan
│ │ ├── lock/ # Distributed locks
│ │ ├── longjob/ # Long-running jobs
│ │ ├── nlp/ # NLP utilities
│ │ ├── observation/ # Logging & observability
│ │ ├── oxm/ # Object mapping base
│ │ ├── queue/ # Queue management
│ │ ├── rate_limit/ # Rate limiting
│ │ └── request/ # Request handling
│ │
│ ├── infra_layer/ # External adapters
│ │ ├── adapters/
│ │ │ ├── input/ # Inbound adapters
│ │ │ │ ├── api/ # REST controllers
│ │ │ │ │ ├── memory/ # Memory API
│ │ │ │ │ ├── health/ # Health check
│ │ │ │ │ ├── status/ # Status API
│ │ │ │ │ ├── dto/ # Data transfer objects
│ │ │ │ │ └── mapper/ # Request mappers
│ │ │ │ ├── jobs/ # Job handlers
│ │ │ │ ├── mcp/ # MCP protocol
│ │ │ │ └── mq/ # Message queue consumers
│ │ │ └── out/ # Outbound adapters
│ │ │ ├── persistence/ # Data persistence
│ │ │ │ ├── document/memory/ # MongoDB documents
│ │ │ │ ├── repository/ # Data repositories
│ │ │ │ └── mapper/ # Data mappers
│ │ │ ├── search/ # Search adapters
│ │ │ │ ├── milvus/ # Vector search
│ │ │ │ │ ├── memory/ # Collections
│ │ │ │ │ └── converter/ # Converters
│ │ │ │ ├── elasticsearch/ # Full-text search
│ │ │ │ │ ├── memory/ # Indices
│ │ │ │ │ └── converter/ # Converters
│ │ │ │ └── repository/ # Search repositories
│ │ │ └── event/ # Event publishers
│ │ └── scripts/ # Infrastructure scripts
│ │ └── migrations/ # DB migrations
│ │
│ ├── biz_layer/ # Business logic
│ │ ├── mem_memorize.py # Memorization logic
│ │ ├── mem_db_operations.py # Database operations
│ │ ├── mem_sync.py # Data synchronization
│ │ └── memorize_config.py # Memorization config
│ │
│ ├── service/ # Service implementations
│ │ ├── memory_request_log_service.py
│ │ ├── conversation_meta_service.py
│ │ ├── request_status_service.py
│ │ └── memcell_delete_service.py
│ │
│ ├── api_specs/ # API specifications
│ │ ├── memory_models.py # Memory data models
│ │ ├── memory_types.py # Memory type enums
│ │ ├── request_converter.py # Request converters
│ │ └── dtos/ # Data transfer objects
│ │
│ ├── common_utils/ # Shared utilities
│ │ ├── language_utils.py # Language detection
│ │ ├── text_utils.py # Text processing
│ │ ├── datetime_utils.py # Date/time helpers
│ │ ├── url_extractor.py # URL extraction
│ │ ├── base62_utils.py # Base62 encoding
│ │ ├── cli_ui.py # CLI utilities
│ │ ├── app_meta.py # App metadata
│ │ ├── project_path.py # Project paths
│ │ └── load_env.py # Environment loading
│ │
│ ├── migrations/ # Database migrations
│ │ ├── mongodb/ # MongoDB migrations
│ │ └── postgresql/ # PostgreSQL migrations
│ │
│ ├── config/ # Configuration files
│ │ └── stopwords/ # Stopword lists
│ │
│ └── devops_scripts/ # DevOps utilities
│ ├── data_fix/ # Data repair scripts
│ ├── i18n/ # Internationalization
│ └── sensitive_info/ # Sensitive data handling
│
├── tests/ # Test suite
├── demo/ # Demo examples
│ ├── simple_demo.py
│ ├── chat_with_memory.py
│ ├── extract_memory.py
│ ├── chat/ # Chat interface
│ ├── config/ # Demo configs
│ ├── tools/ # Demo tools
│ └── utils/ # Demo utilities
├── docs/ # Documentation
├── evaluation/ # Evaluation framework
├── data/ # Sample data
├── data_format/ # Data format specs
├── figs/ # Figures/images
│
├── docker-compose.yaml # Infrastructure stack
├── Dockerfile # Container build
├── pyproject.toml # Project dependencies
├── Makefile # Build commands
├── config.json # App configuration
├── env.template # Environment template
├── pytest.ini # Pytest config
├── pyrightconfig.json # Type checker config
└── .pre-commit-config.yaml # Pre-commit hooks
| Category | Technology |
|---|---|
| Web Framework | FastAPI, Uvicorn |
| LLM Integration | LangChain, OpenAI, Anthropic, Google GenAI |
| Document Store | MongoDB with Beanie ODM |
| Vector Database | Milvus 2.5 |
| Full-text Search | Elasticsearch 8.x |
| Cache | Redis |
| Message Queue | Kafka, ARQ |
| Validation | Pydantic 2.x |
| Package Manager | uv |
- Formatter: Black (line width 88)
- Import Sorting: isort
- Type Checker: Pyright
- Naming: PEP 8 conventions
- Async/await for all I/O operations
- Dependency injection via
core/di/ - Repository pattern for data access
- Adapter pattern for external services
- Snake_case for modules:
memory_manager.py - Classes in PascalCase:
MemoryManager - Constants in UPPER_CASE:
DEFAULT_TIMEOUT
| Type | Description | Location |
|---|---|---|
| MemCell | Atomic memory unit | memory_layer/memcell_extractor/ |
| Episode | Aggregated memories by topic | memory_layer/memory_extractor/episode_memory_extractor.py |
| Profile | User characteristics | memory_layer/memory_extractor/profile_memory_extractor.py |
| GroupProfile | Group chat memories | memory_layer/memory_extractor/group_profile_memory_extractor.py |
| Foresight | Predictive memories | memory_layer/memory_extractor/foresight_extractor.py |
| EventLog | Timeline events | memory_layer/memory_extractor/event_log_extractor.py |
| Strategy | Description |
|---|---|
| KEYWORD | BM25 keyword search |
| VECTOR | Milvus vector similarity |
| HYBRID | Combined keyword + vector |
| RRF | Reciprocal Rank Fusion |
| AGENTIC | LLM-guided multi-turn retrieval |
Located in infra_layer/adapters/out/persistence/document/memory/:
EpisodicMemory- Episodic memoriesUserProfile- User profilesGroupProfile- Group profilesGroupUserProfileMemory- Group user profile memoriesMemCell- Atomic memory unitsEntity- EntitiesRelationship- RelationshipsCoreMemory- Core memoriesEventLogRecord- Event logsForesightRecord- Foresight recordsBehaviorHistory- Behavior historyConversationMeta- Conversation metadataConversationStatus- Conversation statusClusterState- Cluster state
Located in infra_layer/adapters/out/search/milvus/memory/:
EpisodicMemoryCollection- Episodic memory vectorsEventLogCollection- Event log vectorsForesightCollection- Foresight memory vectors
Located in infra_layer/adapters/out/search/elasticsearch/memory/:
episodic_memory- Episodic memory full-text indexevent_log- Event log indexforesight- Foresight memory index
# Development
uv sync # Install dependencies
make run # Run application
python src/run.py # Alternative run
# Testing
pytest # Run all tests
pytest tests/test_memory_layer/ # Specific tests
pytest --cov=src # With coverage
# Code Quality
black src/ # Format code
isort src/ # Sort imports
pyright # Type check
make format # Format all
# Infrastructure
docker-compose up -d # Start databases
docker-compose down # Stop databases
docker-compose logs -f # View logsRequired in .env (copy from env.template):
# LLM (at least one required)
OPENAI_API_KEY=
ANTHROPIC_API_KEY=
GOOGLE_API_KEY=
# Databases (defaults work with docker-compose)
MONGODB_URI=mongodb://localhost:27017
REDIS_URL=redis://localhost:6379
MILVUS_HOST=localhost
ELASTICSEARCH_URL=http://localhost:19200- Define enum in
src/api_specs/memory_types.py - Create extractor in
src/memory_layer/memory_extractor/ - Add MongoDB document in
src/infra_layer/adapters/out/persistence/document/memory/ - Create repository in
src/infra_layer/adapters/out/persistence/repository/ - Add vector collection if needed in
src/infra_layer/adapters/out/search/milvus/memory/ - Add ES index if needed in
src/infra_layer/adapters/out/search/elasticsearch/memory/
- Create controller in
src/infra_layer/adapters/input/api/ - Define request/response DTOs in
src/api_specs/dtos/ - Implement service in
src/service/ - Register route in app configuration (
src/app.py)
- Create provider in
src/memory_layer/llm/ - Implement
LLMProviderinterface fromprotocol.py - Register in DI container
- Multi-tenancy: All data operations are tenant-scoped via
core/tenants/ - Async First: Use
async/awaitfor all I/O operations - Type Safety: Add type hints to all functions
- Error Handling: Use custom exceptions from
core/ - Logging: Use logger from
core/observation/logger.py - Configuration: Main config in
config.json, env variables in.env
- Architecture
- Setup Guide
- Docker Setup
- API Reference
- Development Guide
- Usage Examples
- Configuration Guide
- Unit tests in
tests/mirroringsrc/structure - Use pytest fixtures for database mocking
- Async tests with
pytest-asyncio - Integration tests require running infrastructure (
docker-compose up -d)
Located in demo/ directory:
simple_demo.py- Basic usagechat_with_memory.py- Interactive chat with memoryextract_memory.py- Memory extraction exampletools/- Additional demo tools and utilities