Skip to content
AH

🏛️ Architecture

The AI Memory Platform is built around a single action-routed API, a pluggable provider model, and a policy-first storage engine. Every component is designed for extensibility, traceability, and testability.

📊 High-Level Flow

┌─────────────┐     ┌──────────────┐     ┌───────────────┐
│  👤 User /   │────▶│  POST /api/v1 │────▶│  Policy       │
│  Agent       │     │  Action Router│     │  Engine       │
└─────────────┘     └──────────────┘     └───────┬───────┘
                                                  │
                    ┌─────────────────────────────┼─────────────────────────────┐
                    │                             │                             │
                    ▼                             ▼                             ▼
        ┌──────────────────┐         ┌──────────────────┐         ┌──────────────────┐
        │ 🔵 Mem0 Provider │         │ 🟢 Obsidian Prov.│         │ 🟠 Skills Prov.  │
        │ (PostgreSQL)     │         │ (Markdown vault) │         │ (JSON)           │
        └────────┬─────────┘         └────────┬─────────┘         └────────┬─────────┘
                 │                            │                            │
                 └──────────────┬─────────────┴──────────────┬──────────────┘
                                │                            │
                                ▼                            ▼
                    ┌──────────────────────┐     ┌──────────────────────┐
                    │  Context Builder     │     │  Archive Provider    │
                    │  (merge → rank →     │     │  (cold storage)      │
                    │   token budget)      │     │                      │
                    └──────────┬───────────┘     └──────────────────────┘
                               │
                               ▼
                    ┌──────────────────────┐
                    │  Explainability      │
                    │  (trace_id +         │
                    │   reasoning)         │
                    └──────────┬───────────┘
                               │
                               ▼
                    ┌──────────────────────┐
                    │  👤 Response to User  │
                    └──────────────────────┘

⚙️ Core Components

🎯 Action Router

The single entry point is a POST to /api/v1 which accepts an action field (memory.store, memory.query, memory.get, memory.delete, context.build). The router dispatches to the correct handler based on this action — no REST resource nesting, no multiple endpoints. This keeps the API surface minimal and makes every operation traceable through a single gateway.

🔍 Policy Engine

Before any data is stored, the Policy Engine evaluates each incoming memory candidate. It scores confidence, checks importance thresholds, and discards low-value memories before they reach any provider. This runs BEFORE storage so that providers only ever see high-confidence, policy-compliant data.

🧩 Context Builder

When the platform needs to answer a query, the Context Builder queries every registered provider in parallel, merges results, ranks them by relevance score, and applies a token budget. The merged context is then returned with explainability metadata (trace_id + reasoning) so callers know where each piece of information came from.

🔌 Provider Model

Every provider implements one of two ABCs — MemoryProvider or KnowledgeProvider. The InMemory provider is the gold standard reference; every other provider must pass the same conformance tests. Providers are pluggable: add a new one by implementing the contract and registering it. The Policy Engine and Context Builder treat all providers uniformly.

📡 Event Bus & Explainability

All operations emit structured events with a trace_id that follows the request end-to-end. Every response includes an explainability block listing which providers were queried, what they returned, how the context was assembled, and any policy decisions that were made along the way.

📐 Design Principles

Correctness First

Every provider must pass the same conformance test suite before it can be plugged in. The InMemory provider is the gold standard — all others must match its behavior.

Policy Before Storage

The Policy Engine evaluates every memory BEFORE it reaches a provider. Low-confidence memories are discarded early, saving storage and ensuring quality.

Pluggable Providers

Providers implement an ABC contract and are registered at startup. The system treats them uniformly — swap, add, or remove providers without changing core logic.

Trace Everything

Every request carries a trace_id. Every response includes explainability metadata showing which providers contributed, how context was assembled, and why.

Test-Driven Evolution

The Golden Dataset (200 cases) is the final judge. Any change that causes >5% regression blocks the merge. Mock providers validate behavior before production use.

Stable Contracts

Core interfaces (MemoryObject, ContextObject, Provider ABCs) and the API action set are frozen at v1.0. Changes require an RFC and full conformance re-run.

🔗 Related Resources