# shivam1981-leo/jarvis-agentic-ai-voice-assistant architecture

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

- Interactive diagram: https://gitdiagram.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant
- Repository: https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant

## Overview

#### Purpose and Entry Point
This is a Windows-focused autonomous voice desktop assistant. Its single apparent application entry point is `main.py`; the README’s `python jarvis.py` command does not match the supplied tree. The assistant combines local speech recognition, local Ollama reasoning/tool calls, desktop automation, speech output, and a Pygame holographic interface.

Relevant paths: `main.py`, `requirements.txt`, `README.md`.

#### Runtime Topology
The process is a Python 3.10+ desktop runtime with concurrent UI, agent, audio, and background-task work. It requires an NVIDIA CUDA-capable GPU for Faster-Whisper, local Ollama services/models for reasoning and vision, and Windows-specific desktop/system command support.

Relevant paths: `main.py`, `requirements.txt`.

#### Voice Interaction Pipeline
The primary interactive flow is microphone capture → Whisper `large-v3` transcription with VAD/artifact filtering → wake-word or command interpretation → agent processing. During TTS playback, a concurrent listener recognizes interruption terms such as stop/quiet/cancel and cancels output, returning control to listening.

Relevant paths: `main.py`, `startup.mp3`, `temp_voice_1107.mp3`.

#### Agent and Tool-Execution Boundary
A local Ollama `llama3.2` agent runs a bounded multi-round loop (up to five rounds): it receives user text plus prior tool observations, selects tools, executes them—potentially in parallel—and uses results to decide whether to continue or answer. Tool implementations and dynamically created tools are centered in `custom_tools.py`, separating privileged system/network actions from agent orchestration.

Relevant paths: `main.py`, `custom_tools.py`.

#### Desktop, Web, and Communication Capabilities
The tool layer spans Windows application/process control, terminal commands, keyboard/mouse automation, screenshots/OCR/window inspection, file writing, web/DuckDuckGo/Wikipedia retrieval, WhatsApp automation, and Gmail SMTP. These are high-privilege boundaries: model-produced tool arguments can affect the local machine, files, browser, and external communications.

Relevant paths: `custom_tools.py`, `word.txt`.

#### State, Background Work, and Persistence
Shared assistant state is intended to coordinate visual state, speech interruption, tool status, idle behavior, and asynchronous completion announcements using locks, queues, and thread pools. Persistent user memory is stored in the repository-root JSON file; tool-generated speech audio is written as transient `temp_voice_*.mp3` files.

Relevant paths: `main.py`, `memory.json`, `temp_voice_9950.mp3`.

#### UI and External Services
Pygame renders the live 60-FPS “arc reactor” UI and displays listening/thinking/speaking/task states. External dependencies include Microsoft Edge TTS, Ollama (`llama3.2`, optional `llava` screen vision), `wttr.in` weather, DuckDuckGo, Wikipedia/web targets, Gmail SMTP credentials from `.env`, and WhatsApp Web login.

Relevant paths: `main.py`, `requirements.txt`, `startup.mp3`.

Main entry points: [`main.py`](https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/main.py) (Bounded agent loop), [`custom_tools.py`](https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/custom_tools.py) (Tool implementations), [`memory.json`](https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/memory.json) (User memory), [`temp_voice_9950.mp3`](https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/temp_voice_9950.mp3) (Transient audio)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Desktop Runtime"]
  node_entry["Application entry<br/>Python entry point<br/>[main.py]"]
  node_ui["Arc reactor UI<br/>Pygame UI<br/>[main.py]"]
  node_shared_state["Shared state<br/>thread-safe state<br/>[main.py]"]
  node_microphone["Microphone capture<br/>audio input<br/>[main.py]"]
  node_transcription["Whisper transcription<br/>Faster-Whisper<br/>[main.py]"]
  node_command_gate["Wake word &amp; commands<br/>voice command parser<br/>[main.py]"]
  node_speech["Speech output<br/>TTS controller<br/>[main.py]"]
  node_background["Background tasks<br/>threads and queues<br/>[main.py]"]
  node_memory[("User memory<br/>JSON persistence<br/>[memory.json]")]
  node_temp_audio["Transient audio<br/>MP3 files"]
end

subgraph group_agent["Agent &amp; Tools"]
  node_agent_loop["Bounded agent loop<br/>Ollama orchestration<br/>[main.py]"]
  node_tool_layer{{"Tool implementations<br/>privileged tool boundary<br/>[custom_tools.py]"}}
  node_desktop_tools["Desktop automation<br/>Windows control tools<br/>[custom_tools.py]"]
  node_web_comms["Web &amp; communications<br/>network tools<br/>[custom_tools.py]"]
end

subgraph group_external["External Services"]
  node_ollama{{"Ollama models<br/>local AI service"}}
  node_edge_tts["Microsoft Edge TTS<br/>speech service"]
  node_web_services["Web information services<br/>external web APIs"]
  node_gmail_whatsapp["Messaging services<br/>external communications"]
end

node_entry -->|"starts"| node_ui
node_entry -->|"starts"| node_microphone
node_entry -->|"starts"| node_agent_loop
node_entry -->|"creates"| node_background
node_microphone -->|"audio"| node_transcription
node_transcription -->|"text"| node_command_gate
node_command_gate -->|"user request"| node_agent_loop
node_agent_loop -->|"reasoning and vision"| node_ollama
node_agent_loop -->|"tool calls"| node_tool_layer
node_tool_layer -->|"local actions"| node_desktop_tools
node_tool_layer -->|"network actions"| node_web_comms
node_desktop_tools -->|"reads and writes"| node_memory
node_web_comms -->|"retrieval"| node_web_services
node_web_comms -->|"messages"| node_gmail_whatsapp
node_tool_layer -->|"parallel execution"| node_background
node_agent_loop -->|"response"| node_speech
node_speech -->|"synthesis"| node_edge_tts
node_speech -->|"writes"| node_temp_audio
node_microphone -.->|"interruptions"| node_speech
node_shared_state -->|"display state"| node_ui
node_agent_loop -->|"updates status"| node_shared_state
node_background -->|"completion announcements"| node_speech

click node_entry "https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/main.py"
click node_ui "https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/main.py"
click node_shared_state "https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/main.py"
click node_microphone "https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/main.py"
click node_transcription "https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/main.py"
click node_command_gate "https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/main.py"
click node_speech "https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/main.py"
click node_background "https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/main.py"
click node_agent_loop "https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/main.py"
click node_tool_layer "https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/custom_tools.py"
click node_desktop_tools "https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/custom_tools.py"
click node_web_comms "https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/custom_tools.py"
click node_memory "https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/memory.json"
click node_temp_audio "https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/temp_voice_9950.mp3"

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_entry,node_ui,node_shared_state,node_microphone,node_transcription,node_command_gate,node_speech,node_background,node_memory,node_temp_audio toneBlue
class node_agent_loop,node_tool_layer,node_desktop_tools,node_web_comms toneAmber
class node_ollama,node_edge_tts,node_web_services,node_gmail_whatsapp toneMint
```

## Components

### Desktop Runtime

Windows Python assistant process.

- [Application entry](https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/main.py): Python entry point · Starts UI, audio, agent, and background work. · `main.py`
- [Arc reactor UI](https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/main.py): Pygame UI · Renders live assistant states at 60 FPS. · `main.py`
- [Shared state](https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/main.py): thread-safe state · Coordinates visual, speech, tool, idle, and task state. · `main.py`
- [Microphone capture](https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/main.py): audio input · `main.py`
- [Whisper transcription](https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/main.py): Faster-Whisper · Uses large-v3 with VAD and artifact filtering. · `main.py`
- [Wake word & commands](https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/main.py): voice command parser · `main.py`
- [Speech output](https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/main.py): TTS controller · Supports concurrent stop, quiet, and cancel interruption. · `main.py`
- [Background tasks](https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/main.py): threads and queues · Runs asynchronous work and completion announcements. · `main.py`
- [User memory](https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/memory.json): JSON persistence · `memory.json`
- [Transient audio](https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/temp_voice_9950.mp3): MP3 files · Generated tool speech output. · `temp_voice_9950.mp3`

### Agent & Tools

Local reasoning and privileged actions.

- [Bounded agent loop](https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/main.py): Ollama orchestration · Makes up to five reasoning and tool-use rounds. · `main.py`
- [Tool implementations](https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/custom_tools.py): privileged tool boundary · Executes model-selected local and external actions. · `custom_tools.py`
- [Desktop automation](https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/custom_tools.py): Windows control tools · Controls processes, terminal, input, windows, screenshots, OCR, and files. · `custom_tools.py`
- [Web & communications](https://github.com/shivam1981-leo/jarvis-agentic-ai-voice-assistant/blob/main/custom_tools.py): network tools · Retrieves web data and automates WhatsApp and Gmail. · `custom_tools.py`

### External Services

Local models and network-backed integrations.

- **Ollama models**: local AI service · Runs llama3.2 and optional llava screen vision.
- **Microsoft Edge TTS**: speech service
- **Web information services**: external web APIs · Includes wttr.in, DuckDuckGo, Wikipedia, and web targets.
- **Messaging services**: external communications · Uses Gmail SMTP credentials and WhatsApp Web login.

## Connections

- Application entry → Arc reactor UI: starts
- Application entry → Microphone capture: starts
- Application entry → Bounded agent loop: starts
- Application entry → Background tasks: creates
- Microphone capture → Whisper transcription: audio
- Whisper transcription → Wake word & commands: text
- Wake word & commands → Bounded agent loop: user request
- Bounded agent loop → Ollama models: reasoning and vision
- Bounded agent loop → Tool implementations: tool calls
- Tool implementations → Desktop automation: local actions
- Tool implementations → Web & communications: network actions
- Desktop automation → User memory: reads and writes
- Web & communications → Web information services: retrieval
- Web & communications → Messaging services: messages
- Tool implementations → Background tasks: parallel execution
- Bounded agent loop → Speech output: response
- Speech output → Microsoft Edge TTS: synthesis
- Speech output → Transient audio: writes
- Microphone capture → Speech output: interruptions
- Shared state → Arc reactor UI: display state
- Bounded agent loop → Shared state: updates status
- Background tasks → Speech output: completion announcements
