# davesimoes/crustai architecture

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

- Interactive diagram: https://gitdiagram.com/davesimoes/crustai
- Repository: https://github.com/davesimoes/crustai

## Overview

CrustAI is a local-first assistant that accepts chat through messaging platforms, a REST/web interface, or voice; routes requests through a shared message handler; and returns responses from a locally hosted Ollama model. The handler handles commands and otherwise combines conversation history, stored facts, and personality context before calling the model and saving the turn. The README documents the major capabilities; connections for those shown in sampled source are cited, while other documented relationships are cited to the README.

Main entry points: [`src/core/index.js`](https://github.com/davesimoes/crustai/blob/main/src/core/index.js) (Message Orchestrator), [`src/api/server.js`](https://github.com/davesimoes/crustai/blob/main/src/api/server.js) (REST API Server), [`src/voice/server.js`](https://github.com/davesimoes/crustai/blob/main/src/voice/server.js) (Voice Server), [`src/adapters/telegram/index.js`](https://github.com/davesimoes/crustai/blob/main/src/adapters/telegram/index.js) (Telegram Adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_channels["Chat Channels"]
  node_telegram["Telegram Adapter<br/>[index.js]"]
  node_discord["Discord Adapter<br/>[index.js]"]
  node_whatsapp["WhatsApp Adapter<br/>[index.js]"]
  node_slack["Slack Adapter<br/>[index.js]"]
end

subgraph group_runtime["Assistant Runtime"]
  node_orchestrator["Message Orchestrator<br/>[index.js]"]
  node_commands["Command Handler<br/>[commands.js]"]
  node_prompt["Prompt Builder<br/>[prompt.js]"]
  node_llm["Ollama Client<br/>[llm.js]"]
end

subgraph group_state["Memory and Configuration"]
  node_memory[("Memory Store<br/>[store.js]")]
  node_config["Configuration Loader<br/>[config.js]"]
  node_logger["Logger<br/>[logger.js]"]
end

subgraph group_interfaces["Web and Voice"]
  node_api["REST API Server<br/>[server.js]"]
  node_web_ui["Web Chat UI<br/>[index.html]"]
  node_voice["Voice Server<br/>[server.js]"]
end

node_telegram_user(("Telegram User"))
node_discord_user(("Discord User"))
node_whatsapp_user(("WhatsApp User"))
node_slack_user(("Slack User"))
node_ollama["Ollama Runtime"]
node_web_user(("Web/API Client"))
node_voice_user(("Voice Client"))
node_whisper["Whisper STT"]
node_piper["Piper TTS"]

node_telegram_user -->|"sends messages"| node_telegram
node_discord_user -->|"sends messages"| node_discord
node_whatsapp_user -->|"sends messages"| node_whatsapp
node_slack_user -->|"sends messages"| node_slack
node_telegram -->|"calls handler"| node_orchestrator
node_discord -->|"calls handler"| node_orchestrator
node_whatsapp -->|"calls handler"| node_orchestrator
node_slack -->|"calls handler"| node_orchestrator
node_orchestrator -->|"dispatches commands"| node_commands
node_orchestrator -->|"reads and writes"| node_memory
node_orchestrator -->|"builds prompt"| node_prompt
node_orchestrator -->|"requests reply"| node_llm
node_llm -->|"sends inference request"| node_ollama
node_orchestrator -->|"loads settings"| node_config
node_web_user -->|"sends requests"| node_api
node_api -->|"serves interface"| node_web_ui
node_api -->|"calls handler"| node_orchestrator
node_api -->|"reads and clears"| node_memory
node_voice_user -->|"sends audio or text"| node_voice
node_voice -->|"calls handler"| node_orchestrator
node_voice -->|"transcribes audio"| node_whisper
node_voice -->|"synthesizes reply"| node_piper

click node_telegram "https://github.com/davesimoes/crustai/blob/main/src/adapters/telegram/index.js"
click node_discord "https://github.com/davesimoes/crustai/blob/main/src/adapters/discord/index.js"
click node_whatsapp "https://github.com/davesimoes/crustai/blob/main/src/adapters/whatsapp/index.js"
click node_slack "https://github.com/davesimoes/crustai/blob/main/src/adapters/slack/index.js"
click node_orchestrator "https://github.com/davesimoes/crustai/blob/main/src/core/index.js"
click node_commands "https://github.com/davesimoes/crustai/blob/main/src/core/commands.js"
click node_prompt "https://github.com/davesimoes/crustai/blob/main/src/personality/prompt.js"
click node_llm "https://github.com/davesimoes/crustai/blob/main/src/core/llm.js"
click node_memory "https://github.com/davesimoes/crustai/blob/main/src/memory/store.js"
click node_config "https://github.com/davesimoes/crustai/blob/main/src/utils/config.js"
click node_logger "https://github.com/davesimoes/crustai/blob/main/src/utils/logger.js"
click node_api "https://github.com/davesimoes/crustai/blob/main/src/api/server.js"
click node_web_ui "https://github.com/davesimoes/crustai/blob/main/src/web/index.html"
click node_voice "https://github.com/davesimoes/crustai/blob/main/src/voice/server.js"

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_discord,node_whatsapp,node_slack,node_telegram_user,node_discord_user,node_whatsapp_user,node_slack_user,node_web_user,node_voice_user toneBlue
class node_orchestrator,node_commands,node_prompt,node_llm toneAmber
class node_memory,node_config,node_logger toneMint
class node_api,node_web_ui,node_voice toneRose
class node_ollama,node_whisper,node_piper toneIndigo
```

## Components

### Chat Channels

- [Telegram Adapter](https://github.com/davesimoes/crustai/blob/main/src/adapters/telegram/index.js): `src/adapters/telegram/index.js`
- [Discord Adapter](https://github.com/davesimoes/crustai/blob/main/src/adapters/discord/index.js): `src/adapters/discord/index.js`
- [WhatsApp Adapter](https://github.com/davesimoes/crustai/blob/main/src/adapters/whatsapp/index.js): `src/adapters/whatsapp/index.js`
- [Slack Adapter](https://github.com/davesimoes/crustai/blob/main/src/adapters/slack/index.js): `src/adapters/slack/index.js`

### Assistant Runtime

- [Message Orchestrator](https://github.com/davesimoes/crustai/blob/main/src/core/index.js): `src/core/index.js`
- [Command Handler](https://github.com/davesimoes/crustai/blob/main/src/core/commands.js): `src/core/commands.js`
- [Prompt Builder](https://github.com/davesimoes/crustai/blob/main/src/personality/prompt.js): `src/personality/prompt.js`
- [Ollama Client](https://github.com/davesimoes/crustai/blob/main/src/core/llm.js): `src/core/llm.js`

### Memory and Configuration

- [Memory Store](https://github.com/davesimoes/crustai/blob/main/src/memory/store.js): `src/memory/store.js`
- [Configuration Loader](https://github.com/davesimoes/crustai/blob/main/src/utils/config.js): `src/utils/config.js`
- [Logger](https://github.com/davesimoes/crustai/blob/main/src/utils/logger.js): `src/utils/logger.js`

### Web and Voice

- [REST API Server](https://github.com/davesimoes/crustai/blob/main/src/api/server.js): `src/api/server.js`
- [Web Chat UI](https://github.com/davesimoes/crustai/blob/main/src/web/index.html): `src/web/index.html`
- [Voice Server](https://github.com/davesimoes/crustai/blob/main/src/voice/server.js): `src/voice/server.js`

### Other components

- **Telegram User**
- **Discord User**
- **WhatsApp User**
- **Slack User**
- **Ollama Runtime**
- **Web/API Client**
- **Voice Client**
- **Whisper STT**
- **Piper TTS**

## Connections

- Telegram User → Telegram Adapter: sends messages (evidence: `README.md`)
- Discord User → Discord Adapter: sends messages (evidence: `README.md`)
- WhatsApp User → WhatsApp Adapter: sends messages (evidence: `README.md`)
- Slack User → Slack Adapter: sends messages (evidence: `README.md`)
- Telegram Adapter → Message Orchestrator: calls handler (evidence: `src/core/index.js`)
- Discord Adapter → Message Orchestrator: calls handler (evidence: `src/core/index.js`)
- WhatsApp Adapter → Message Orchestrator: calls handler (evidence: `src/core/index.js`)
- Slack Adapter → Message Orchestrator: calls handler (evidence: `src/core/index.js`)
- Message Orchestrator → Command Handler: dispatches commands (evidence: `src/core/index.js`)
- Message Orchestrator → Memory Store: reads and writes (evidence: `src/core/index.js`)
- Message Orchestrator → Prompt Builder: builds prompt (evidence: `src/core/index.js`)
- Message Orchestrator → Ollama Client: requests reply (evidence: `src/core/index.js`)
- Ollama Client → Ollama Runtime: sends inference request (evidence: `src/core/llm.js`)
- Message Orchestrator → Configuration Loader: loads settings (evidence: `src/core/index.js`)
- Web/API Client → REST API Server: sends requests (evidence: `README.md`)
- REST API Server → Web Chat UI: serves interface (evidence: `src/api/server.js`)
- REST API Server → Message Orchestrator: calls handler (evidence: `src/api/server.js`)
- REST API Server → Memory Store: reads and clears (evidence: `src/api/server.js`)
- Voice Client → Voice Server: sends audio or text (evidence: `src/voice/server.js`)
- Voice Server → Message Orchestrator: calls handler (evidence: `src/core/index.js`)
- Voice Server → Whisper STT: transcribes audio (evidence: `src/voice/server.js`)
- Voice Server → Piper TTS: synthesizes reply (evidence: `src/voice/server.js`)
