Architecture Deep Dive
A guided tour through SmartMemory's architecture: how content flows through the ingestion pipeline, how the five memory types relate, how the Zettelkasten layer organises atomic knowledge, how clustering deduplicates entities, how MCP integration works, and how it all sits on the storage substrate. Aimed at readers evaluating whether SmartMemory fits their architecture, and at integrators who want a complete mental model before reaching for the API reference.
For the short version, see Introduction. For task-oriented usage see the Guides. For the API surface see SmartMemory.
π Repository: smartmemory-ai/smart-memory
π Issues: Report bugs or request features
π Documentation: View online docs
π§ SmartMemory - Advanced Agentic Memory System for Intelligent Applications with Enterprise-Grade Multi-User Support
π What is SmartMemory?
SmartMemory is a next-generation memory system that goes far beyond simple storage and retrieval. It's designed specifically for AI agents and intelligent applications that need sophisticated memory capabilities with human-like cognitive processing and complete user isolation.
π Key Features
- π§ Cognitive Memory Types: Pending, semantic, episodic, and procedural memory systems
- π Automatic Evolution: Memories improve and consolidate over time
- π― Entity Extraction: LLM, SpaCy, and GLiNER extractors with automatic fallback
- π Entity Clustering: deduplication (SemHash + KMeans + LLM)
- π Knowledge Grounding: Automatic Wikipedia linking for entity provenance
- π Assertion Challenging: Detect contradictions between new and existing facts
- π Semantic Search: Vector embeddings + graph traversal + text fallbacks
- β±οΈ Temporal Versioning: Bi-temporal tracking with time-travel queries
- π Framework Integration: Works with LangChain, CrewAI, AutoGen, and more
π Ingestion Pipeline
When you call memory.ingest(), content flows through an 11-stage pipeline:
flowchart LR
A["π₯ Input"] --> B["π·οΈ Classification"]
B --> C["π Extraction"]
C --> D["πΎ Storage"]
D --> E["π Linking"]
E --> F["π Vector"]
F --> G["β¨ Enrichment"]
G --> H["π Grounding"]
H --> I["π Evolution"]
I --> J["𧬠Clustering"]
J --> K["π Versioning"]
style A fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
style C fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
style J fill:#fff3e0,stroke:#f57c00,stroke-width:2px
style K fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
| Stage | Description |
|---|---|
| classify | Determine memory type (semantic, episodic, procedural, pending, zettel) |
| coreference | Resolve pronouns and entity mentions in the content |
| simplify | Optional sentence simplification for cleaner extraction |
| entity_ruler | Pattern-based entity tagging from public knowledge + workspace patterns |
| llm_extract | LLM entity & relation extraction (with SpaCy fallback) |
| ontology_constrain | Constrain extracted types against the active ontology |
| store | Persist memory node + entity nodes (and embeddings) in FalkorDB |
| link | Connect the new item to related existing memories |
| enrich | Optional enrichers (sentiment, topic, temporal, link expansion, etc.) |
| ground | Link entities to Wikidata/Wikipedia via GROUNDED_IN edges |
| evolve | Run evolvers (episodicβsemantic, decay, opinion synthesis, β¦) |
π§ Memory Type Distribution
SmartMemory organizes information into five distinct cognitive memory types, each optimized for different kinds of knowledge and usage patterns, mimicking human cognitive architecture.
flowchart TD
A["π§ Classified Memory"] --> B{"Memory Type?"}
B -->|Facts & Knowledge| C["π Semantic Memory"]
B -->|Personal Events| D["π Episodic Memory"]
B -->|Skills & Procedures| E["βοΈ Procedural Memory"]
B -->|Active Context| F["π Pending Memory"]
B -->|Atomic Knowledge| G["ποΈ Zettelkasten Memory"]
C --> H["π Relationship Mapping"]
D --> H
E --> H
G --> H
F --> H
H --> I["πΎ Storage Layer"]
style A fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
style C fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
style D fill:#fff3e0,stroke:#f57c00,stroke-width:2px
style E fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
𧬠Memory Evolution & Intelligence
Memory improves itself in the background while you continue chatting. Memories consolidate, prune, and enhance relationships as well as create new memories to self-improve. The system also goes out to the web to find new information and ground existing memories in facts.
flowchart TB
subgraph "Memory Lifecycle"
A["π₯ New Memory"] --> B["π Initial Processing"]
B --> C["πΎ Storage"]
C --> D["π Background Evolution"]
D --> E{"Evolution Type?"}
E -->|Consolidate| F["𧬠Memory Consolidation"]
E -->|Prune| G["βοΈ Strategic Pruning"]
E -->|Link| H["π Relationship Enhancement"]
E -->|Organize| I["π Hierarchical Organization"]
F --> J["π Quality Assessment"]
G --> J
H --> J
I --> J
J --> K{"Quality Score?"}
K -->|High| L["β Promote Memory"]
K -->|Medium| M["π Continue Evolution"]
K -->|Low| N["ποΈ Archive/Remove"]
L --> O["π― Enhanced Retrieval"]
M --> D
N --> P["π Archive Storage"]
end
subgraph "Intelligence Features"
Q["π€ Agent Query"] --> R["π Smart Search"]
R --> S["π― Context Building"]
S --> T["π Relevance Scoring"]
T --> U["π€ Intelligent Response"]
O --> R
C --> R
end
style A fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
style J fill:#fff3e0,stroke:#f57c00,stroke-width:2px
style O fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
style U fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
ποΈ Zettelkasten Memory System
SmartMemory includes a sophisticated Zettelkasten system for atomic knowledge management, automatically creating interconnected knowledge networks that evolve and strengthen over time.
Zettelkasten Creation
flowchart LR
A["π Knowledge Input"] --> B["π Atomic Concept Extraction"]
B --> C["π Zettel Creation"]
C --> D["π·οΈ Auto-Tagging"]
D --> E["π Link Discovery"]
style A fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
style E fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
Knowledge Graph Evolution
flowchart LR
F["πΈοΈ Concept Network"] --> G["π Hierarchical Clusters"]
G --> H["π― Topic Modeling"]
H --> I["π Semantic Relationships"]
I --> J["𧬠Link Strengthening"]
J --> K["π Concept Merging"]
K --> L["βοΈ Redundancy Pruning"]
L --> M["π± New Connection Discovery"]
style F fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
style M fill:#fff3e0,stroke:#f57c00,stroke-width:2px
Intelligent Retrieval
flowchart LR
N["π Query Processing"] --> O["π― Relevance Scoring"]
O --> P["π Context Assembly"]
P --> Q["π€ Knowledge Response"]
style N fill:#fff3e0,stroke:#f57c00,stroke-width:2px
style Q fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
𧬠Entity Clustering & Deduplication
SmartMemory provides multi-level entity resolution:
flowchart LR
A["π€ Entities"] --> B["#οΈβ£ SemHash"]
B --> C["π KMeans"]
C --> D["π€ LLM Clustering"]
D --> E["π Merge Nodes"]
style A fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
style B fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
style D fill:#fff3e0,stroke:#f57c00,stroke-width:2px
style E fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
| Layer | Method | Purpose |
|---|---|---|
| SemHash | Semantic hashing + singularization | Fast deterministic dedup (0.95 threshold) |
| KMeans | Embedding clustering | Group similar entities (~128 per cluster) |
| LLM | semantic analysis (default llama-3.3-70b-versatile) | Find aliases (Joe β Joseph, ML β machine learning) |
| Merge | Graph node consolidation | Rewire edges, merge properties |
Runs automatically after each ingest() call, or manually via memory.run_clustering().
π Advanced Search & Retrieval
Multi-dimensional search capabilities that go beyond simple keyword matching, using semantic understanding, graph traversal, and temporal patterns to find the most relevant memories.
flowchart TD
subgraph "Search Input"
A["π€ User Query"] --> B["π Query Analysis"]
B --> C["π― Intent Detection"]
C --> D["π Context Extraction"]
end
subgraph "Search Strategies"
D --> E["π Semantic Search"]
D --> F["πΈοΈ Graph Traversal"]
D --> G["β° Temporal Search"]
D --> H["π Hybrid Search"]
D --> I["π Similarity Search"]
end
subgraph "Memory Sources"
E --> J["π Semantic Memory"]
F --> K["π Episodic Memory"]
G --> L["βοΈ Procedural Memory"]
H --> M["π Pending Memory"]
I --> N["ποΈ Zettelkasten Memory"]
end
subgraph "Result Processing"
J --> O["π Relevance Scoring"]
K --> O
L --> O
M --> O
N --> O
O --> P["π Relationship Mapping"]
P --> Q["π Ranking Algorithm"]
Q --> R["π€ Contextual Results"]
end
style A fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
style E fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
style O fill:#fff3e0,stroke:#f57c00,stroke-width:2px
style R fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
π MCP Server Integration
Seamless integration with AI agents through the Model Context Protocol, providing standardized tools and interfaces for memory operations within agentic workflows.
flowchart TD
subgraph "AI Agent Layer"
A["π€ AI Agent"] --> B["π‘ MCP Client"]
B --> C["π Protocol Handler"]
end
subgraph "SmartMemory MCP Server"
C --> D["π₯ Request Router"]
D --> E["π οΈ Tool Interface"]
E --> F["πΎ Memory Operations"]
E --> G["π Search Operations"]
E --> H["π Relationship Operations"]
E --> I["π Analytics Operations"]
end
subgraph "Core Memory Engine"
F --> J["π§ Memory Manager"]
G --> K["π Search Engine"]
H --> L["πΈοΈ Graph Engine"]
I --> M["π Analytics Engine"]
end
subgraph "Storage Layer"
J --> N["π Graph Database"]
K --> O["ποΈ Vector Store"]
L --> P["π Metadata Store"]
M --> Q["π Analytics Store"]
end
subgraph "Background Processing"
N --> R["π Evolution Engine"]
O --> R
P --> R
Q --> R
R --> S["𧬠Memory Consolidation"]
R --> T["βοΈ Strategic Pruning"]
R --> U["π Link Enhancement"]
end
style A fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
style E fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
style J fill:#fff3e0,stroke:#f57c00,stroke-width:2px
style R fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
πΎ Storage Architecture
SmartMemory uses a unified FalkorDB backend for both graph and vector storage:
flowchart TD
subgraph "SmartMemory API"
A["π€ SmartMemory"] --> B["π SmartGraph"]
A --> C["ποΈ VectorStore"]
end
subgraph "FalkorDB (Unified Backend)"
B --> D["πΈοΈ Graph Storage"]
C --> E["π HNSW Vector Index"]
D --> F["Memory Nodes"]
D --> G["Entity Nodes"]
D --> H["Wikipedia Nodes"]
D --> I["Version Nodes"]
D --> J["Edges (CONTAINS, GROUNDED_IN, HAS_VERSION)"]
E --> K["vecf32 embeddings"]
E --> L["Cosine similarity"]
end
subgraph "Redis Cache"
M["β‘ Embeddings"]
N["β‘ Search Results"]
O["β‘ Entity Extraction"]
end
style A fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
style D fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
style E fill:#fff3e0,stroke:#f57c00,stroke-width:2px
style M fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
Key Features:
- Dual-node pattern: Memory nodes + separate entity nodes for reuse
- Global Wikipedia nodes: Shared across users (
is_global=True) - HNSW vector index: Native FalkorDB vector search with configurable M, efConstruction
- Multi-tenant isolation:
ScopeProviderfilters all queries by tenant/user/workspace
π― Agentic Framework Integration
Seamless integration with major AI agent frameworks through specialized adapters, enabling SmartMemory to work natively within your existing agentic workflows and toolchains.
flowchart LR
subgraph "AI Agent Frameworks"
A["π¦ LangChain"]
B["π¦ LlamaIndex"]
C["πΎ Haystack"]
D["π€ AutoGen"]
E["π’ CrewAI"]
F["π§ Custom Agents"]
end
subgraph "SmartMemory Integration Layer"
A --> G["π LangChain Adapter"]
B --> H["π LlamaIndex Adapter"]
C --> I["π Haystack Adapter"]
D --> J["π AutoGen Adapter"]
E --> K["π CrewAI Adapter"]
F --> L["π Generic MCP Adapter"]
end
subgraph "Core SmartMemory"
G --> M["π§ Memory Engine"]
H --> M
I --> M
J --> M
K --> M
L --> M
M --> N["πΎ Storage Layer"]
M --> O["π Search Engine"]
M --> P["𧬠Evolution Engine"]
M --> Q["π Analytics Engine"]
end
subgraph "Agent Capabilities"
N --> R["π Memory Persistence"]
O --> S["π Intelligent Retrieval"]
P --> T["𧬠Continuous Learning"]
Q --> U["π Performance Insights"]
end
style A fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
style G fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
style M fill:#fff3e0,stroke:#f57c00,stroke-width:2px
style R fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
π― Key Differentiators
| Feature | Traditional Databases | SmartMemory |
|---|---|---|
| Storage Architecture | Static records | Hybrid triple storage (Graph + Vector + Metadata) |
| Relationships | Manual foreign keys | Automatic intelligent linking + evolution |
| Processing | Query-time only | Continuous background enrichment + evolution |
| Intelligence | None | Entity extraction, semantic analysis, ontology management |
| Memory Types | Single table/collection | 5 cognitive memory types (Semantic, Episodic, Procedural, Pending, Zettelkasten) |
| Agent Integration | Basic CRUD | MCP protocol, tool interfaces, agentic workflows |
| Evolution | Static data | Memory consolidation, pruning, quality enhancement |
| Ontology Management | None | Hybrid freeform + structured knowledge extraction |
| Human-in-the-Loop | Manual queries only | HITL ontology editing, validation, and refinement |
| Similarity Framework | Basic text matching | Multi-dimensional similarity (semantic, temporal, structural) |
| Background Processing | None | Asynchronous enrichment, evolution, and optimization |
| Context Awareness | None | Temporal patterns, user context, cross-session intelligence |
π Key Features & Architecture Blocks
π§ Cognitive Memory Types
| Memory Type | Description | Key Features |
|---|---|---|
| π Semantic | Facts, concepts, and general knowledge | Automatic concept extraction and linking, ontology-guided organization |
| π Episodic | Personal experiences and events | Rich temporal context, narrative understanding |
| βοΈ Procedural | Skills, procedures, and how-to knowledge | Step-by-step process understanding, action sequences |
| π Pending | Temporary, active information processing | Context-aware short-term storage, dynamic attention management |
| ποΈ Zettelkasten | Atomic knowledge notes | Interconnected knowledge networks, automatic linking |
Core Processing Capabilities:
- π€ Automatic Entity Extraction: Identify people, places, concepts, and relationships
- πΈοΈ Intelligent Linking: Discover connections between memories automatically
- π Semantic Enrichment: Enhance memories with contextual information
- π― Similarity Analysis: Multi-dimensional similarity scoring and clustering
- π Evolution Algorithms: Continuous memory consolidation and optimization
β‘ High-Performance Architecture
π Key Performance Benefits:
- Asynchronous Processing: Non-blocking memory enhancement
- Fast Ingestion: Store immediately, process in background
- Multi-Backend Support: Graph databases, vector stores, hybrid approaches
- Intelligent Caching: Smart retrieval optimization
- Scalable Components: Modular, extensible architecture
π€ Agent-First Design
- π MCP Integration: Model Context Protocol support for seamless LLM integration
- π οΈ Tool Interface: Ready-to-use tools for agentic workflows
- 𧬠Evolution Algorithms: Memory optimization designed specifically for AI agents
- π― Contextual Retrieval: Intelligent memory access patterns
Quick Start
from smartmemory import SmartMemory
# Initialize SmartMemory
memory = SmartMemory()
# Ingest memories (full 11-stage pipeline)
# classify β coreference β simplify β entity_ruler β llm_extract β
# ontology_constrain β store β link β enrich β ground β evolve
memory.ingest("I learned Python programming in 2020")
memory.ingest("Paris is the capital of France")
memory.ingest("John works at Google as an engineer")
# Search memories (vector + graph + text fallbacks)
results = memory.search("programming languages")
print(results)
# Get related memories via graph traversal
related = memory.get_neighbors(results[0].item_id)
print(related)
# Run clustering to deduplicate entities
stats = memory.run_clustering()
print(f"Merged {stats['merged_count']} duplicate entities")| Feature | SmartMemory | Zep | Mem0 |
|---|---|---|---|
| Core Memory Types | |||
| Semantic Memory | β Advanced with entity extraction | β Basic | β Basic |
| Episodic Memory | β Temporal + contextual | β Limited | β Basic |
| Procedural Memory | β Skills + workflows | β No | β No |
| Pending Memory | β Adaptive capacity | β No | β No |
| Zettelkasten Memory | β Atomic knowledge notes | β No | β No |
| Intelligence & Processing | |||
| Entity Extraction | β LLM + SpaCy + GLiNER (fallback chain) | β Basic | β Basic |
| Relationship Discovery | β Automatic + intelligent | β Manual | β Limited |
| Entity Clustering | β SemHash + KMeans + LLM | β No | β No |
| Grounding & Provenance | β Wikipedia linking + GROUNDED_IN edges | β No | β Limited |
| Background Processing | β Async + configurable | β No | β Basic |
| Evolution Algorithms | β 14+ sophisticated evolvers | β No | β Basic |
| Storage & Architecture | |||
| Storage Architecture | β Unified FalkorDB (Graph + Vector) | β Vector only | β Vector + basic |
| Graph Database Support | β FalkorDB (primary), SQLite (lite) | β No | β Limited |
| Vector Database Support | β FalkorDB HNSW (native, default), usearch (optional) | β Multiple | β Multiple |
| Multi-Backend Support | β Pluggable backends | β Limited | β Yes |
| Hybrid Search | β Semantic + Graph + Metadata | β Vector only | β Semantic |
| AI Agent Integration | |||
| MCP Protocol | β Full MCP tool suite | β No | β Limited |
| LangChain Integration | β Native support | β Yes | β Yes |
| AutoGen Compatible | β Multi-agent support | β Limited | β Basic |
| Custom Tool Creation | β Extensible toolbox | β Limited | β Basic |
| Agent Memory Isolation | β Multi-tenant + namespaces | β Basic | β User-based |
| Search & Retrieval | |||
| Semantic Search | β Advanced embeddings | β Yes | β Yes |
| Graph Traversal | β Relationship-based discovery | β No | β Limited |
| Multi-Modal Queries | β Content+Meta+Temporal | β Basic | β Content |
| Context-Aware Search | β User+Time+Type filtering | β Limited | β Basic |
| Real-Time Performance | β Sub-millisecond | β Fast | β Fast |
| Developer Experience | |||
| API Completeness | β Full CRUD + advanced ops | β Basic CRUD | β CRUD + search |
| Configuration System | β JSON/YAML + env vars | β Basic | β Config files |
| Documentation Quality | β Comprehensive + examples | β Limited | β Good |
| Testing Framework | β Full test suite + benchmarks | β Basic | β Tests |
| Monitoring & Analytics | β Metrics + health checks | β No | β Basic |
| Scalability & Performance | |||
| Horizontal Scaling | β Multi-worker + load balancing | β Limited | β Cloud-native |
| Caching Strategy | β Multi-level intelligent caching | β Basic | β Basic |
| Batch Processing | β Efficient bulk operations | β No | β Limited |
| Background Evolution | β Continuous optimization | β No | β No |
| Resource Management | β Connection pooling + optimization | β Basic | β Cloud-managed |
| Enterprise Features | |||
| Multi-Tenancy | β Secure namespace isolation | β No | β User isolation |
| Audit Trails | β Full provenance tracking | β No | β Limited |
| Temporal Versioning | β Bi-temporal with time-travel queries | β No | β No |
| Security Model | β Comprehensive access control | β Basic | β User-based |
| Backup & Recovery | β Point-in-time recovery | β Manual | β Cloud backup |
| Compliance Support | β GDPR + audit ready | β No | β Basic |
Key Differentiators
π§ SmartMemory: Most comprehensive system with 5 memory types, advanced evolution algorithms, hybrid storage, and enterprise-grade features
π§ Zep: Lightweight vector-based system focused on simplicity and basic retrieval
βοΈ Mem0: Cloud-native solution with good LLM integration but limited memory sophistication
Best Use Cases
- SmartMemory: Complex AI agents, enterprise applications, research systems, sophisticated conversational AI
- Zep: Simple chatbots, basic RAG applications, proof-of-concepts
- Mem0: Cloud-first applications, basic personalization, simple memory needs
Use Cases
- Conversational AI: Persistent memory for chatbots and assistants
- Learning Systems: Educational applications with knowledge tracking
- Knowledge Management: Enterprise knowledge bases with intelligent organization
- Research Tools: Academic and scientific knowledge organization
- Personal AI: Individual memory systems for personal assistants
Next Steps
- Installation - Set up SmartMemory in your environment
- Quick Start - Build your first memory-enabled application
- Core Concepts - Understand the fundamental concepts
- API Reference - Detailed API documentation
SmartMemory is designed for developers building intelligent applications that need sophisticated memory capabilities. Whether you're creating conversational AI, learning systems, or knowledge management tools, SmartMemory provides the foundation for intelligent memory processing.