# robersonnaves/mem0 architecture

> Architecture diagram of the GitHub repository robersonnaves/mem0, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/robersonnaves/mem0
- Repository: https://github.com/robersonnaves/mem0

## Overview

Mem0 is a long-term memory layer for AI agents, available as an OSS library, hosted API, self-hosted service, CLI and agent integrations. Its main workflow accepts scoped messages, extracts and embeds memories, stores them for later search, and returns relevant context; the platform client also exposes retrieval and management operations. The graph includes the README’s major deployment and access branches. Core calls are supported by sampled source; some server, dashboard and integration wiring is based on documented capabilities and tree structure, not sampled implementation.

Main entry points: [`mem0/memory/main.py`](https://github.com/robersonnaves/mem0/blob/main/mem0/memory/main.py) (Memory extraction), [`server/main.py`](https://github.com/robersonnaves/mem0/blob/main/server/main.py) (Self-hosted API), [`mem0/proxy/main.py`](https://github.com/robersonnaves/mem0/blob/main/mem0/proxy/main.py) (Chat proxy), [`mem0/client/main.py`](https://github.com/robersonnaves/mem0/blob/main/mem0/client/main.py) (Python platform client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_memory["Memory engine"]
  node_memory["Memory API<br/>[main.py]"]
  node_extract["Memory extraction<br/>[main.py]"]
  node_search["Memory search<br/>[main.py]"]
end

subgraph group_providers["Model and storage providers"]
  node_embedder["Embedding providers"]
  node_llm["LLM providers"]
  node_vector[("Vector stores")]
  node_history[("History and messages<br/>[storage.py]")]
  node_reranker["Rerankers"]
end

subgraph group_access["SDK and CLI access"]
  node_pythonclient["Python platform client<br/>[main.py]"]
  node_tsclient["TypeScript SDK<br/>[mem0.ts]"]
  node_cli["Mem0 CLI<br/>[app.py]"]
  node_proxy["Chat proxy<br/>[main.py]"]
end

subgraph group_service["Self-hosted service"]
  node_server["Self-hosted API<br/>[main.py]"]
  node_auth["Auth and API keys<br/>[auth.py]"]
  node_routers["Management routes"]
  node_dashboard["Admin dashboard"]
end

subgraph group_integrations["Agent integrations"]
  node_agentplugins["Agent plugins"]
  node_openclaw["OpenClaw integration<br/>[index.ts]"]
end

node_developer(("Developer or agent"))
node_platform{{"Mem0 Platform API"}}
node_externalagent(("AI agent"))

node_developer -->|"submits messages"| node_memory
node_memory -->|"extracts facts"| node_extract
node_extract -->|"requests extraction"| node_llm
node_extract -->|"embeds facts"| node_embedder
node_extract -->|"stores memories"| node_vector
node_extract -->|"saves messages"| node_history
node_memory -->|"searches memories"| node_search
node_search -->|"embeds query"| node_embedder
node_search -->|"retrieves candidates"| node_vector
node_search -.->|"reranks results"| node_reranker
node_memory -->|"returns memories"| node_developer
node_developer -->|"calls SDK"| node_pythonclient
node_developer -->|"calls SDK"| node_tsclient
node_developer -->|"runs commands"| node_cli
node_pythonclient -->|"sends API requests"| node_platform
node_tsclient -->|"sends API requests"| node_platform
node_cli -->|"manages memories"| node_platform
node_platform -.->|"serves client calls"| node_proxy
node_developer -.->|"uses chat API"| node_proxy
node_proxy -->|"adds and searches"| node_memory
node_developer -->|"calls self-hosted API"| node_server
node_server -->|"checks access"| node_auth
node_server -->|"mounts routes"| node_routers
node_dashboard -->|"manages service"| node_server
node_externalagent -->|"uses integration"| node_agentplugins
node_agentplugins -.->|"accesses memory API"| node_platform
node_externalagent -->|"uses integration"| node_openclaw
node_openclaw -.->|"recalls and captures"| node_platform

click node_memory "https://github.com/robersonnaves/mem0/blob/main/mem0/memory/main.py"
click node_extract "https://github.com/robersonnaves/mem0/blob/main/mem0/memory/main.py"
click node_search "https://github.com/robersonnaves/mem0/blob/main/mem0/memory/main.py"
click node_embedder "https://github.com/robersonnaves/mem0/tree/main/mem0/embeddings"
click node_llm "https://github.com/robersonnaves/mem0/tree/main/mem0/llms"
click node_vector "https://github.com/robersonnaves/mem0/tree/main/mem0/vector_stores"
click node_history "https://github.com/robersonnaves/mem0/blob/main/mem0/memory/storage.py"
click node_reranker "https://github.com/robersonnaves/mem0/tree/main/mem0/reranker"
click node_pythonclient "https://github.com/robersonnaves/mem0/blob/main/mem0/client/main.py"
click node_tsclient "https://github.com/robersonnaves/mem0/blob/main/mem0-ts/src/client/mem0.ts"
click node_cli "https://github.com/robersonnaves/mem0/blob/main/cli/python/src/mem0_cli/app.py"
click node_proxy "https://github.com/robersonnaves/mem0/blob/main/mem0/proxy/main.py"
click node_server "https://github.com/robersonnaves/mem0/blob/main/server/main.py"
click node_auth "https://github.com/robersonnaves/mem0/blob/main/server/auth.py"
click node_routers "https://github.com/robersonnaves/mem0/tree/main/server/routers"
click node_dashboard "https://github.com/robersonnaves/mem0/tree/main/server/dashboard/src/app/(root)/dashboard"
click node_agentplugins "https://github.com/robersonnaves/mem0/tree/main/integrations/agent-plugin-core"
click node_openclaw "https://github.com/robersonnaves/mem0/blob/main/integrations/openclaw/index.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_memory,node_extract,node_search toneBlue
class node_embedder,node_llm,node_vector,node_history,node_reranker toneAmber
class node_pythonclient,node_tsclient,node_cli,node_proxy,node_platform toneMint
class node_server,node_auth,node_routers,node_dashboard toneRose
class node_agentplugins,node_openclaw,node_developer,node_externalagent toneIndigo
```

## Components

### Memory engine

- [Memory API](https://github.com/robersonnaves/mem0/blob/main/mem0/memory/main.py): `mem0/memory/main.py`
- [Memory extraction](https://github.com/robersonnaves/mem0/blob/main/mem0/memory/main.py): `mem0/memory/main.py`
- [Memory search](https://github.com/robersonnaves/mem0/blob/main/mem0/memory/main.py): `mem0/memory/main.py`

### Model and storage providers

- [Embedding providers](https://github.com/robersonnaves/mem0/tree/main/mem0/embeddings): `mem0/embeddings`
- [LLM providers](https://github.com/robersonnaves/mem0/tree/main/mem0/llms): `mem0/llms`
- [Vector stores](https://github.com/robersonnaves/mem0/tree/main/mem0/vector_stores): `mem0/vector_stores`
- [History and messages](https://github.com/robersonnaves/mem0/blob/main/mem0/memory/storage.py): `mem0/memory/storage.py`
- [Rerankers](https://github.com/robersonnaves/mem0/tree/main/mem0/reranker): `mem0/reranker`

### SDK and CLI access

- [Python platform client](https://github.com/robersonnaves/mem0/blob/main/mem0/client/main.py): `mem0/client/main.py`
- [TypeScript SDK](https://github.com/robersonnaves/mem0/blob/main/mem0-ts/src/client/mem0.ts): `mem0-ts/src/client/mem0.ts`
- [Mem0 CLI](https://github.com/robersonnaves/mem0/blob/main/cli/python/src/mem0_cli/app.py): `cli/python/src/mem0_cli/app.py`
- [Chat proxy](https://github.com/robersonnaves/mem0/blob/main/mem0/proxy/main.py): `mem0/proxy/main.py`

### Self-hosted service

- [Self-hosted API](https://github.com/robersonnaves/mem0/blob/main/server/main.py): `server/main.py`
- [Auth and API keys](https://github.com/robersonnaves/mem0/blob/main/server/auth.py): `server/auth.py`
- [Management routes](https://github.com/robersonnaves/mem0/tree/main/server/routers): `server/routers`
- [Admin dashboard](https://github.com/robersonnaves/mem0/tree/main/server/dashboard/src/app/(root)/dashboard): `server/dashboard/src/app/(root)/dashboard`

### Agent integrations

- [Agent plugins](https://github.com/robersonnaves/mem0/tree/main/integrations/agent-plugin-core): `integrations/agent-plugin-core`
- [OpenClaw integration](https://github.com/robersonnaves/mem0/blob/main/integrations/openclaw/index.ts): `integrations/openclaw/index.ts`

### Other components

- **Developer or agent**
- **Mem0 Platform API**
- **AI agent**

## Connections

- Developer or agent → Memory API: submits messages
- Memory API → Memory extraction: extracts facts
- Memory extraction → LLM providers: requests extraction
- Memory extraction → Embedding providers: embeds facts
- Memory extraction → Vector stores: stores memories
- Memory extraction → History and messages: saves messages
- Memory API → Memory search: searches memories
- Memory search → Embedding providers: embeds query
- Memory search → Vector stores: retrieves candidates
- Memory search → Rerankers: reranks results
- Memory API → Developer or agent: returns memories
- Developer or agent → Python platform client: calls SDK
- Developer or agent → TypeScript SDK: calls SDK
- Developer or agent → Mem0 CLI: runs commands
- Python platform client → Mem0 Platform API: sends API requests
- TypeScript SDK → Mem0 Platform API: sends API requests
- Mem0 CLI → Mem0 Platform API: manages memories
- Mem0 Platform API → Chat proxy: serves client calls
- Developer or agent → Chat proxy: uses chat API
- Chat proxy → Memory API: adds and searches
- Developer or agent → Self-hosted API: calls self-hosted API
- Self-hosted API → Auth and API keys: checks access
- Self-hosted API → Management routes: mounts routes
- Admin dashboard → Self-hosted API: manages service
- AI agent → Agent plugins: uses integration
- Agent plugins → Mem0 Platform API: accesses memory API
- AI agent → OpenClaw integration: uses integration
- OpenClaw integration → Mem0 Platform API: recalls and captures
