# memovai/mimiclaw architecture

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

- Interactive diagram: https://gitdiagram.com/memovai/mimiclaw
- Repository: https://github.com/memovai/mimiclaw

## Overview

MimiClaw is an ESP32-S3 AI assistant: users send messages through chat or a local interface; channel adapters queue them for the agent, which builds context, consults an LLM and tools, uses persistent memory, and returns a response through outbound dispatch. The product also includes WiFi onboarding, scheduled and heartbeat messages, skills, a WebSocket gateway, and device tools. Runtime wiring is supported by the excerpts and source index; tool implementations and some auxiliary subsystems were not sampled, so uncertain links are marked dashed.

Main entry points: [`main/bus/message_bus.c`](https://github.com/memovai/mimiclaw/blob/main/main/bus/message_bus.c) (Message bus), [`main/tools/tool_registry.c`](https://github.com/memovai/mimiclaw/blob/main/main/tools/tool_registry.c) (Tool registry), [`main/agent/agent_loop.c`](https://github.com/memovai/mimiclaw/blob/main/main/agent/agent_loop.c) (Agent loop), [`main/mimi.c`](https://github.com/memovai/mimiclaw/blob/main/main/mimi.c) (Outbound dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Interfaces &amp; connectivity"]
  node_telegram["Telegram bot<br/>[telegram_bot.c]"]
  node_feishu["Feishu bot<br/>[feishu_bot.c]"]
  node_serial["Serial CLI<br/>[serial_cli.c]"]
  node_onboard["WiFi onboarding<br/>[wifi_onboard.c]"]
  node_wifi["WiFi manager<br/>[wifi_manager.c]"]
  node_websocket["WebSocket gateway<br/>[ws_server.c]"]
end

subgraph group_conversation["Agent &amp; conversation"]
  node_bus["Message bus<br/>[message_bus.c]"]
  node_agent["Agent loop<br/>[agent_loop.c]"]
  node_context["Context builder<br/>[context_builder.c]"]
  node_llm["LLM proxy<br/>[llm_proxy.c]"]
  node_sessions[("Session manager<br/>[session_mgr.c]")]
  node_memory[("Long-term memory<br/>[memory_store.c]")]
  node_dispatch["Outbound dispatch<br/>[mimi.c]"]
end

subgraph group_capabilities["Assistant capabilities"]
  node_registry["Tool registry<br/>[tool_registry.c]"]
  node_websearch["Web search<br/>[tool_web_search.c]"]
  node_toolcron["Cron tools<br/>[tool_cron.c]"]
  node_files["File tools<br/>[tool_files.c]"]
  node_gpio["GPIO tools<br/>[tool_gpio.c]"]
  node_gettime["Time tool<br/>[tool_get_time.c]"]
  node_skills["Skills loader<br/>[skill_loader.c]"]
end

subgraph group_operations["Device operations"]
  node_cron["Cron service<br/>[cron_service.c]"]
  node_heartbeat["Heartbeat service<br/>[heartbeat.c]"]
  node_proxy["HTTP proxy<br/>[http_proxy.c]"]
  node_ota["OTA manager<br/>[ota_manager.c]"]
end

node_user(("User"))
node_llm_service{{"LLM provider"}}
node_search_service{{"Search providers"}}
node_flash[("SPIFFS storage")]
node_nvs[("NVS config")]

node_user -->|"sends message"| node_telegram
node_telegram -->|"queues inbound"| node_bus
node_feishu -->|"queues inbound"| node_bus
node_serial -.->|"queues inbound"| node_bus
node_websocket -->|"queues inbound"| node_bus
node_bus -->|"delivers inbound"| node_agent
node_agent -->|"builds context"| node_context
node_agent -->|"requests completion"| node_llm
node_agent -->|"loads and appends"| node_sessions
node_agent -->|"executes tools"| node_registry
node_context -->|"reads memory"| node_memory
node_context -->|"loads skill summary"| node_skills
node_llm -->|"calls provider"| node_llm_service
node_registry -.->|"dispatches tool"| node_websearch
node_registry -.->|"dispatches tool"| node_toolcron
node_registry -.->|"dispatches tool"| node_files
node_registry -.->|"dispatches tool"| node_gpio
node_registry -.->|"dispatches tool"| node_gettime
node_websearch -.->|"queries providers"| node_search_service
node_telegram -->|"uses HTTPS proxy"| node_proxy
node_feishu -->|"uses HTTPS proxy"| node_proxy
node_llm -->|"uses HTTPS proxy"| node_proxy
node_websearch -->|"uses HTTPS proxy"| node_proxy
node_cron -->|"queues due message"| node_bus
node_heartbeat -->|"queues check message"| node_bus
node_toolcron -.->|"manages schedules"| node_cron
node_dispatch -->|"pops responses"| node_bus
node_dispatch -->|"sends response"| node_telegram
node_dispatch -->|"sends response"| node_feishu
node_dispatch -->|"sends response"| node_websocket
node_onboard -->|"sets up WiFi"| node_wifi
node_user -.->|"configures network"| node_onboard
node_sessions -.->|"stores histories"| node_flash
node_memory -.->|"stores memory"| node_flash
node_cron -->|"persists jobs"| node_flash
node_wifi -.->|"stores credentials"| node_nvs
node_llm -.->|"stores settings"| node_nvs
node_ota -.->|"updates firmware"| node_user

click node_telegram "https://github.com/memovai/mimiclaw/blob/main/main/channels/telegram/telegram_bot.c"
click node_feishu "https://github.com/memovai/mimiclaw/blob/main/main/channels/feishu/feishu_bot.c"
click node_serial "https://github.com/memovai/mimiclaw/blob/main/main/cli/serial_cli.c"
click node_onboard "https://github.com/memovai/mimiclaw/blob/main/main/onboard/wifi_onboard.c"
click node_wifi "https://github.com/memovai/mimiclaw/blob/main/main/wifi/wifi_manager.c"
click node_websocket "https://github.com/memovai/mimiclaw/blob/main/main/gateway/ws_server.c"
click node_bus "https://github.com/memovai/mimiclaw/blob/main/main/bus/message_bus.c"
click node_agent "https://github.com/memovai/mimiclaw/blob/main/main/agent/agent_loop.c"
click node_context "https://github.com/memovai/mimiclaw/blob/main/main/agent/context_builder.c"
click node_llm "https://github.com/memovai/mimiclaw/blob/main/main/llm/llm_proxy.c"
click node_sessions "https://github.com/memovai/mimiclaw/blob/main/main/memory/session_mgr.c"
click node_memory "https://github.com/memovai/mimiclaw/blob/main/main/memory/memory_store.c"
click node_dispatch "https://github.com/memovai/mimiclaw/blob/main/main/mimi.c"
click node_registry "https://github.com/memovai/mimiclaw/blob/main/main/tools/tool_registry.c"
click node_websearch "https://github.com/memovai/mimiclaw/blob/main/main/tools/tool_web_search.c"
click node_toolcron "https://github.com/memovai/mimiclaw/blob/main/main/tools/tool_cron.c"
click node_files "https://github.com/memovai/mimiclaw/blob/main/main/tools/tool_files.c"
click node_gpio "https://github.com/memovai/mimiclaw/blob/main/main/tools/tool_gpio.c"
click node_gettime "https://github.com/memovai/mimiclaw/blob/main/main/tools/tool_get_time.c"
click node_skills "https://github.com/memovai/mimiclaw/blob/main/main/skills/skill_loader.c"
click node_cron "https://github.com/memovai/mimiclaw/blob/main/main/cron/cron_service.c"
click node_heartbeat "https://github.com/memovai/mimiclaw/blob/main/main/heartbeat/heartbeat.c"
click node_proxy "https://github.com/memovai/mimiclaw/blob/main/main/proxy/http_proxy.c"
click node_ota "https://github.com/memovai/mimiclaw/blob/main/main/ota/ota_manager.c"

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_telegram,node_feishu,node_serial,node_onboard,node_wifi,node_websocket,node_user toneBlue
class node_bus,node_agent,node_context,node_llm,node_sessions,node_memory,node_dispatch,node_flash,node_nvs toneAmber
class node_registry,node_websearch,node_toolcron,node_files,node_gpio,node_gettime,node_skills toneMint
class node_cron,node_heartbeat,node_proxy,node_ota toneRose
class node_llm_service,node_search_service toneIndigo
```

## Components

### Interfaces & connectivity

- [Telegram bot](https://github.com/memovai/mimiclaw/blob/main/main/channels/telegram/telegram_bot.c): `main/channels/telegram/telegram_bot.c`
- [Feishu bot](https://github.com/memovai/mimiclaw/blob/main/main/channels/feishu/feishu_bot.c): `main/channels/feishu/feishu_bot.c`
- [Serial CLI](https://github.com/memovai/mimiclaw/blob/main/main/cli/serial_cli.c): `main/cli/serial_cli.c`
- [WiFi onboarding](https://github.com/memovai/mimiclaw/blob/main/main/onboard/wifi_onboard.c): `main/onboard/wifi_onboard.c`
- [WiFi manager](https://github.com/memovai/mimiclaw/blob/main/main/wifi/wifi_manager.c): `main/wifi/wifi_manager.c`
- [WebSocket gateway](https://github.com/memovai/mimiclaw/blob/main/main/gateway/ws_server.c): `main/gateway/ws_server.c`

### Agent & conversation

- [Message bus](https://github.com/memovai/mimiclaw/blob/main/main/bus/message_bus.c): `main/bus/message_bus.c`
- [Agent loop](https://github.com/memovai/mimiclaw/blob/main/main/agent/agent_loop.c): `main/agent/agent_loop.c`
- [Context builder](https://github.com/memovai/mimiclaw/blob/main/main/agent/context_builder.c): `main/agent/context_builder.c`
- [LLM proxy](https://github.com/memovai/mimiclaw/blob/main/main/llm/llm_proxy.c): `main/llm/llm_proxy.c`
- [Session manager](https://github.com/memovai/mimiclaw/blob/main/main/memory/session_mgr.c): `main/memory/session_mgr.c`
- [Long-term memory](https://github.com/memovai/mimiclaw/blob/main/main/memory/memory_store.c): `main/memory/memory_store.c`
- [Outbound dispatch](https://github.com/memovai/mimiclaw/blob/main/main/mimi.c): `main/mimi.c`

### Assistant capabilities

- [Tool registry](https://github.com/memovai/mimiclaw/blob/main/main/tools/tool_registry.c): `main/tools/tool_registry.c`
- [Web search](https://github.com/memovai/mimiclaw/blob/main/main/tools/tool_web_search.c): `main/tools/tool_web_search.c`
- [Cron tools](https://github.com/memovai/mimiclaw/blob/main/main/tools/tool_cron.c): `main/tools/tool_cron.c`
- [File tools](https://github.com/memovai/mimiclaw/blob/main/main/tools/tool_files.c): `main/tools/tool_files.c`
- [GPIO tools](https://github.com/memovai/mimiclaw/blob/main/main/tools/tool_gpio.c): `main/tools/tool_gpio.c`
- [Time tool](https://github.com/memovai/mimiclaw/blob/main/main/tools/tool_get_time.c): `main/tools/tool_get_time.c`
- [Skills loader](https://github.com/memovai/mimiclaw/blob/main/main/skills/skill_loader.c): `main/skills/skill_loader.c`

### Device operations

- [Cron service](https://github.com/memovai/mimiclaw/blob/main/main/cron/cron_service.c): `main/cron/cron_service.c`
- [Heartbeat service](https://github.com/memovai/mimiclaw/blob/main/main/heartbeat/heartbeat.c): `main/heartbeat/heartbeat.c`
- [HTTP proxy](https://github.com/memovai/mimiclaw/blob/main/main/proxy/http_proxy.c): `main/proxy/http_proxy.c`
- [OTA manager](https://github.com/memovai/mimiclaw/blob/main/main/ota/ota_manager.c): `main/ota/ota_manager.c`

### Other components

- **User**
- **LLM provider**
- **Search providers**
- **SPIFFS storage**
- **NVS config**

## Connections

- User → Telegram bot: sends message (evidence: `README.md`)
- Telegram bot → Message bus: queues inbound (evidence: `main/channels/telegram/telegram_bot.c`)
- Feishu bot → Message bus: queues inbound (evidence: `main/channels/feishu/feishu_bot.c`)
- Serial CLI → Message bus: queues inbound
- WebSocket gateway → Message bus: queues inbound (evidence: `main/gateway/ws_server.c`)
- Message bus → Agent loop: delivers inbound (evidence: `main/agent/agent_loop.c`)
- Agent loop → Context builder: builds context (evidence: `main/agent/agent_loop.c`)
- Agent loop → LLM proxy: requests completion (evidence: `main/agent/agent_loop.c`)
- Agent loop → Session manager: loads and appends (evidence: `main/agent/agent_loop.c`)
- Agent loop → Tool registry: executes tools (evidence: `main/agent/agent_loop.c`)
- Context builder → Long-term memory: reads memory (evidence: `main/agent/context_builder.c`)
- Context builder → Skills loader: loads skill summary (evidence: `main/agent/context_builder.c`)
- LLM proxy → LLM provider: calls provider (evidence: `README.md`)
- Tool registry → Web search: dispatches tool
- Tool registry → Cron tools: dispatches tool
- Tool registry → File tools: dispatches tool
- Tool registry → GPIO tools: dispatches tool
- Tool registry → Time tool: dispatches tool
- Web search → Search providers: queries providers
- Telegram bot → HTTP proxy: uses HTTPS proxy (evidence: `main/channels/telegram/telegram_bot.c`)
- Feishu bot → HTTP proxy: uses HTTPS proxy (evidence: `main/channels/feishu/feishu_bot.c`)
- LLM proxy → HTTP proxy: uses HTTPS proxy (evidence: `main/llm/llm_proxy.c`)
- Web search → HTTP proxy: uses HTTPS proxy (evidence: `main/tools/tool_web_search.c`)
- Cron service → Message bus: queues due message (evidence: `main/cron/cron_service.c`)
- Heartbeat service → Message bus: queues check message (evidence: `main/heartbeat/heartbeat.c`)
- Cron tools → Cron service: manages schedules
- Outbound dispatch → Message bus: pops responses (evidence: `main/mimi.c`)
- Outbound dispatch → Telegram bot: sends response (evidence: `main/mimi.c`)
- Outbound dispatch → Feishu bot: sends response (evidence: `main/mimi.c`)
- Outbound dispatch → WebSocket gateway: sends response (evidence: `main/mimi.c`)
- WiFi onboarding → WiFi manager: sets up WiFi (evidence: `main/onboard/wifi_onboard.c`)
- User → WiFi onboarding: configures network
- Session manager → SPIFFS storage: stores histories
- Long-term memory → SPIFFS storage: stores memory
- Cron service → SPIFFS storage: persists jobs (evidence: `main/cron/cron_service.c`)
- WiFi manager → NVS config: stores credentials
- LLM proxy → NVS config: stores settings
- OTA manager → User: updates firmware
