Service Architecture
The server is built around a “Shared Spec” architecture. Both the server and the client rely on a common set of Pydantic models (found inspec.py) to ensure that data validation is consistent across the network boundary.
Core Architectural Pillars
Technical Organization
The server’s logic is partitioned to mirror the two primary memory types:Episodic Logic
Focuses on the high-frequency ingestion of conversational data. The server implementation handles:- Metadata Casting: Ensuring raw JSON metadata is properly typed for the vector store.
- Context Injection: Managing the
short_term_memoryandlong_term_memorycomponents within a single session.
Semantic Logic
Focuses on structured knowledge organization. The server implementation handles:- Set & Category Management: Creating the hierarchical structures (Sets -> Categories -> Tags) that organize long-term facts.
- Template Application: Managing category templates for consistent knowledge extraction.
Infrastructure Features
Health & Monitoring
The server includes built-in endpoints for container orchestration (Kubernetes/Docker):/health: Returns service status and semantic versioning./metrics: Exposes Prometheus-formatted metrics for request latency and memory ingestion counts.
Dependency Injection
The server utilizes FastAPI dependencies to manage theMemMachine core instance, allowing for safe asynchronous access to the underlying storage engines across concurrent API requests.
Next Steps
To dive deeper into the specific implementation details of each module, explore the following sections:Memory Types
The atomic building blocks and Enums used by the server.
Episodic Memory
Deep dive into session management and search logic.
Semantic Memory
Understanding the knowledge graph and tag management.
Memory Manager
Reference counting and instance lifecycle details.

