# isair/jarvis architecture

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

- Interactive diagram: https://gitdiagram.com/isair/jarvis
- Repository: https://github.com/isair/jarvis
- Video tour (about a minute): https://gitdiagram.com/isair/jarvis/video

## Overview

#### Purpose and entry points
Jarvis is a local-first Python desktop voice assistant. It combines continuous microphone listening, local LLM inference via Ollama, long-term memory, tool execution, and local speech output; it also offers hold-to-talk dictation. Core runtime entry points are `src/jarvis/main.py` and `src/jarvis/daemon.py`; the packaged desktop shell starts through `src/desktop_app/__main__.py` and `src/desktop_app/app.py`.

#### Desktop lifecycle and configuration
The desktop application owns tray/UI lifecycle, first-run setup, settings, updates, and visibility into stored memory. It launches/configures the assistant daemon rather than implementing reply logic itself. Configuration is centralized in `src/jarvis/config.py`; desktop-specific paths and setup flow live in `src/desktop_app/paths.py`, `src/desktop_app/setup_wizard.py`, and `src/desktop_app/settings_window.py`.

#### Voice ingestion and intent boundary
Audio handling separates transcription and conversational control from downstream reasoning. `src/jarvis/listening/listener.py` orchestrates microphone capture; `src/jarvis/listening/wake_detection.py`, `intent_judge.py`, and `echo_detection.py` identify directed requests, extract query text, recognize stop/follow-up behavior, and suppress assistant-speech echoes. The shared Whisper-backed transcription layer is `src/jarvis/dictation/dictation_engine.py`. Dictation is a parallel interaction mode in `src/jarvis/dictation/dictation_engine.py` and `src/jarvis/dictation/history.py`, with the listener paused as needed.

#### Reply orchestration and LLM calls
`src/jarvis/reply/engine.py` is the central turn coordinator: it receives an accepted utterance, assembles context, selects/plans tools, runs the agentic response loop, and returns a response for speech. Local Ollama model access is abstracted in `src/jarvis/llm.py`. Planning and quality control are distinct stages: `src/jarvis/reply/planner.py` decomposes multistep work and can resolve steps to calls; `src/jarvis/reply/evaluator.py` validates or steers generated work. Prompt policy and model-specific variants reside in `src/jarvis/reply/prompts/system.py` and `src/jarvis/reply/prompts/model_variants.py`.

#### Memory, privacy, and context assembly
Persistent conversation and knowledge memory are local storage concerns under `src/jarvis/memory/`. `src/jarvis/memory/db.py` manages persistence, `conversation.py` supplies dialogue history, and `graph.py`/`graph_ops.py` maintain a self-organizing knowledge graph. `src/jarvis/memory/recall_gate.py` controls what recalled information enters a turn; embeddings and vector retrieval are in `src/jarvis/memory/embeddings.py` and `src/jarvis/utils/vector_store.py`. Sensitive values are redacted before disk persistence through `src/jarvis/utils/redact.py`. The reply engine’s enrichment/digest boundary is `src/jarvis/reply/enrichment.py`, limiting memory and tool payload growth for smaller models.

#### Tool catalogue, selection, and execution
Tools implement a common interface under `src/jarvis/tools/base.py` and are registered by `src/jarvis/tools/registry.py`. Before the main model sees tools, `src/jarvis/tools/selection.py` filters the catalogue using LLM, embeddings, keywords, or all-tools strategies; `src/jarvis/tools/builtin/tool_search.py` lets the agent expand its accessible set mid-turn. Built-ins cover web/search, screen, filesystem, weather, and nutrition, e.g. `src/jarvis/tools/builtin/web_search.py`, `src/jarvis/tools/builtin/screenshot.py`, and `src/jarvis/tools/builtin/nutrition/log_meal.py`.

#### External and runtime services
Ollama is the material local inference dependency for chat, intent classification, routing/planning, and optional digest passes. Whisper transcription may use GPU acceleration; desktop packaging includes CUDA recovery support in `src/desktop_app/cuda_recovery.py`. Speech output is handled by `src/jarvis/output/tts.py` with Piper default and optional Chatterbox. MCP servers are external subprocess/stdin-stdout integrations managed by `src/jarvis/tools/external/mcp_runtime.py` and `mcp_client.py`, maintaining sessions for stateful tools such as browser automation. Optional network boundaries are explicit: web search/fetch tools, configured MCP services, and location detection in `src/jarvis/utils/location.py`.

Main entry points: [`src/jarvis/reply/engine.py`](https://github.com/isair/jarvis/blob/main/src/jarvis/reply/engine.py) (Reply engine), [`src/jarvis/tools/registry.py`](https://github.com/isair/jarvis/blob/main/src/jarvis/tools/registry.py) (Tool registry), [`src/desktop_app/app.py`](https://github.com/isair/jarvis/blob/main/src/desktop_app/app.py) (Desktop application), [`src/jarvis/daemon.py`](https://github.com/isair/jarvis/blob/main/src/jarvis/daemon.py) (Assistant daemon)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop shell"]
  node_desktop_app["Desktop application<br/>desktop shell<br/>[app.py]"]
  node_desktop_setup["Setup and settings<br/>desktop configuration<br/>[setup_wizard.py]"]
end

subgraph group_voice["Voice interaction"]
  node_listener["Microphone listener<br/>audio orchestrator<br/>[listener.py]"]
  node_intent_boundary["Wake and intent gate<br/>utterance control<br/>[intent_judge.py]"]
  node_transcription["Whisper transcription<br/>speech-to-text"]
  node_tts["Local speech output<br/>text-to-speech<br/>[tts.py]"]
end

subgraph group_reasoning["Turn reasoning"]
  node_reply_engine{{"Reply engine<br/>turn coordinator<br/>[engine.py]"}}
  node_planning["Planning and evaluation<br/>agent control<br/>[planner.py]"]
  node_prompts["Prompt policy<br/>prompt definitions<br/>[system.py]"]
  node_enrichment["Context enrichment<br/>payload boundary<br/>[enrichment.py]"]
end

subgraph group_memory["Local memory"]
  node_memory_db[("Memory persistence<br/>local database<br/>[db.py]")]
  node_recall["Recall gate and graph<br/>memory retrieval<br/>[recall_gate.py]"]
  node_redaction["Sensitive-data redaction<br/>privacy boundary<br/>[redact.py]"]
end

subgraph group_tools["Tool runtime"]
  node_tool_selection["Tool selection<br/>catalogue filter<br/>[selection.py]"]
  node_tool_registry["Tool registry<br/>tool catalogue<br/>[registry.py]"]
  node_builtin_tools["Built-in tools<br/>tool implementations<br/>[web_search.py]"]
  node_mcp_runtime["MCP runtime<br/>external tool bridge<br/>[mcp_runtime.py]"]
end

node_daemon{{"Assistant daemon<br/>runtime entry point<br/>[daemon.py]"}}
node_config["Shared configuration<br/>[config.py]"]
node_ollama[("Ollama<br/>local inference service<br/>[llm.py]")]

node_desktop_app -->|"hosts"| node_desktop_setup
node_desktop_app -->|"launches and configures"| node_daemon
node_daemon -->|"runs"| node_listener
node_config -.->|"configures"| node_desktop_app
node_config -.->|"configures"| node_daemon
node_listener -->|"audio to text"| node_transcription
node_transcription -->|"utterance text"| node_intent_boundary
node_intent_boundary -->|"accepted request"| node_reply_engine
node_reply_engine -->|"assembles bounded context"| node_enrichment
node_enrichment -->|"requests recall"| node_recall
node_recall -->|"retrieves local memory"| node_memory_db
node_reply_engine -->|"plans and evaluates"| node_planning
node_planning -->|"local inference"| node_ollama
node_reply_engine -->|"applies policy"| node_prompts
node_reply_engine -->|"selects tools"| node_tool_selection
node_tool_selection -->|"filters catalogue"| node_tool_registry
node_tool_registry -->|"executes"| node_builtin_tools
node_tool_registry -->|"opens external sessions"| node_mcp_runtime
node_reply_engine -->|"agent loop"| node_ollama
node_reply_engine -->|"response text"| node_tts
node_reply_engine -->|"memory writes"| node_redaction
node_redaction -->|"safe persistence"| node_memory_db

click node_desktop_app "https://github.com/isair/jarvis/blob/main/src/desktop_app/app.py"
click node_desktop_setup "https://github.com/isair/jarvis/blob/main/src/desktop_app/setup_wizard.py"
click node_daemon "https://github.com/isair/jarvis/blob/main/src/jarvis/daemon.py"
click node_config "https://github.com/isair/jarvis/blob/main/src/jarvis/config.py"
click node_listener "https://github.com/isair/jarvis/blob/main/src/jarvis/listening/listener.py"
click node_intent_boundary "https://github.com/isair/jarvis/blob/main/src/jarvis/listening/intent_judge.py"
click node_transcription "https://github.com/isair/jarvis/blob/main/src/jarvis/dictation/dictation_engine.py"
click node_reply_engine "https://github.com/isair/jarvis/blob/main/src/jarvis/reply/engine.py"
click node_planning "https://github.com/isair/jarvis/blob/main/src/jarvis/reply/planner.py"
click node_prompts "https://github.com/isair/jarvis/blob/main/src/jarvis/reply/prompts/system.py"
click node_ollama "https://github.com/isair/jarvis/blob/main/src/jarvis/llm.py"
click node_enrichment "https://github.com/isair/jarvis/blob/main/src/jarvis/reply/enrichment.py"
click node_memory_db "https://github.com/isair/jarvis/blob/main/src/jarvis/memory/db.py"
click node_recall "https://github.com/isair/jarvis/blob/main/src/jarvis/memory/recall_gate.py"
click node_redaction "https://github.com/isair/jarvis/blob/main/src/jarvis/utils/redact.py"
click node_tool_selection "https://github.com/isair/jarvis/blob/main/src/jarvis/tools/selection.py"
click node_tool_registry "https://github.com/isair/jarvis/blob/main/src/jarvis/tools/registry.py"
click node_builtin_tools "https://github.com/isair/jarvis/blob/main/src/jarvis/tools/builtin/web_search.py"
click node_mcp_runtime "https://github.com/isair/jarvis/blob/main/src/jarvis/tools/external/mcp_runtime.py"
click node_tts "https://github.com/isair/jarvis/blob/main/src/jarvis/output/tts.py"

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_desktop_app,node_desktop_setup toneBlue
class node_listener,node_intent_boundary,node_transcription,node_tts toneAmber
class node_reply_engine,node_planning,node_prompts,node_enrichment toneMint
class node_memory_db,node_recall,node_redaction toneRose
class node_tool_selection,node_tool_registry,node_builtin_tools,node_mcp_runtime toneIndigo
class node_daemon,node_config,node_ollama toneNeutral
```

## Components

### Desktop shell

- [Desktop application](https://github.com/isair/jarvis/blob/main/src/desktop_app/app.py): desktop shell · Owns tray, setup, settings, updates, and daemon lifecycle. · `src/desktop_app/app.py`
- [Setup and settings](https://github.com/isair/jarvis/blob/main/src/desktop_app/setup_wizard.py): desktop configuration · `src/desktop_app/setup_wizard.py`

### Voice interaction

- [Microphone listener](https://github.com/isair/jarvis/blob/main/src/jarvis/listening/listener.py): audio orchestrator · `src/jarvis/listening/listener.py`
- [Wake and intent gate](https://github.com/isair/jarvis/blob/main/src/jarvis/listening/intent_judge.py): utterance control · Detects directed requests, follow-ups, stops, and echoes. · `src/jarvis/listening/intent_judge.py`
- [Whisper transcription](https://github.com/isair/jarvis/blob/main/src/jarvis/dictation/dictation_engine.py): speech-to-text · Shared by continuous listening and hold-to-talk dictation. · `src/jarvis/dictation/dictation_engine.py`
- [Local speech output](https://github.com/isair/jarvis/blob/main/src/jarvis/output/tts.py): text-to-speech · Uses Piper by default with optional Chatterbox. · `src/jarvis/output/tts.py`

### Turn reasoning

- [Reply engine](https://github.com/isair/jarvis/blob/main/src/jarvis/reply/engine.py): turn coordinator · Builds context, drives the agent loop, and returns speech-ready replies. · `src/jarvis/reply/engine.py`
- [Planning and evaluation](https://github.com/isair/jarvis/blob/main/src/jarvis/reply/planner.py): agent control · Decomposes work and validates or steers generated work. · `src/jarvis/reply/planner.py`
- [Prompt policy](https://github.com/isair/jarvis/blob/main/src/jarvis/reply/prompts/system.py): prompt definitions · `src/jarvis/reply/prompts/system.py`
- [Context enrichment](https://github.com/isair/jarvis/blob/main/src/jarvis/reply/enrichment.py): payload boundary · Limits memory and tool payload growth for smaller models. · `src/jarvis/reply/enrichment.py`

### Local memory

- [Memory persistence](https://github.com/isair/jarvis/blob/main/src/jarvis/memory/db.py): local database · Stores conversation and knowledge memory locally. · `src/jarvis/memory/db.py`
- [Recall gate and graph](https://github.com/isair/jarvis/blob/main/src/jarvis/memory/recall_gate.py): memory retrieval · Controls recalled context and maintains the knowledge graph. · `src/jarvis/memory/recall_gate.py`
- [Sensitive-data redaction](https://github.com/isair/jarvis/blob/main/src/jarvis/utils/redact.py): privacy boundary · Redacts sensitive values before persistence. · `src/jarvis/utils/redact.py`

### Tool runtime

- [Tool selection](https://github.com/isair/jarvis/blob/main/src/jarvis/tools/selection.py): catalogue filter · Narrows tools before they are exposed to the model. · `src/jarvis/tools/selection.py`
- [Tool registry](https://github.com/isair/jarvis/blob/main/src/jarvis/tools/registry.py): tool catalogue · Registers common-interface built-in and external tools. · `src/jarvis/tools/registry.py`
- [Built-in tools](https://github.com/isair/jarvis/blob/main/src/jarvis/tools/builtin/web_search.py): tool implementations · Includes web, screen, filesystem, weather, and nutrition actions. · `src/jarvis/tools/builtin/web_search.py`
- [MCP runtime](https://github.com/isair/jarvis/blob/main/src/jarvis/tools/external/mcp_runtime.py): external tool bridge · Manages stateful subprocess stdin/stdout tool sessions. · `src/jarvis/tools/external/mcp_runtime.py`

### Other components

- [Assistant daemon](https://github.com/isair/jarvis/blob/main/src/jarvis/daemon.py): runtime entry point · Runs the continuous local assistant. · `src/jarvis/daemon.py`
- [Shared configuration](https://github.com/isair/jarvis/blob/main/src/jarvis/config.py): configuration · `src/jarvis/config.py`
- [Ollama](https://github.com/isair/jarvis/blob/main/src/jarvis/llm.py): local inference service · Provides chat, classification, routing, planning, and optional digest inference. · `src/jarvis/llm.py`

## Connections

- Desktop application → Setup and settings: hosts
- Desktop application → Assistant daemon: launches and configures
- Assistant daemon → Microphone listener: runs
- Shared configuration → Desktop application: configures
- Shared configuration → Assistant daemon: configures
- Microphone listener → Whisper transcription: audio to text
- Whisper transcription → Wake and intent gate: utterance text
- Wake and intent gate → Reply engine: accepted request
- Reply engine → Context enrichment: assembles bounded context
- Context enrichment → Recall gate and graph: requests recall
- Recall gate and graph → Memory persistence: retrieves local memory
- Reply engine → Planning and evaluation: plans and evaluates
- Planning and evaluation → Ollama: local inference
- Reply engine → Prompt policy: applies policy
- Reply engine → Tool selection: selects tools
- Tool selection → Tool registry: filters catalogue
- Tool registry → Built-in tools: executes
- Tool registry → MCP runtime: opens external sessions
- Reply engine → Ollama: agent loop
- Reply engine → Local speech output: response text
- Reply engine → Sensitive-data redaction: memory writes
- Sensitive-data redaction → Memory persistence: safe persistence
