# gurunesh30/voice-agent architecture

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

- Interactive diagram: https://gitdiagram.com/gurunesh30/voice-agent
- Repository: https://github.com/gurunesh30/voice-agent

## Overview

#### Purpose and Entry Points
This repository implements a Python voice assistant for microphone-driven commands, speech output, and optional internet/email integrations. The documented runtime entry point is `main.py`; it instantiates and runs the assistant core in `src/voice_assistant.py`. A separate Vite/Bun-compatible frontend exists, with browser entry `frontend/src/main.jsx`, but no backend/web bridge is evident from the supplied tree.

#### Assistant Orchestration
`src/voice_assistant.py` is the control-plane class: it manages interaction lifecycle, mode selection (beginner versus advanced), command interpretation, dispatch, and user-facing responses. `main.py` is the CLI bootstrap boundary. The assistant is intended to register command handlers rather than embedding each integration directly.
- `main.py`
- `src/voice_assistant.py`
- `src/commands/__init__.py`

#### Speech I/O Boundary
Speech capture, Google-backed speech-to-text, ambient-noise handling, recognition failure handling, and text-to-speech are centralized behind the speech utility. The core assistant should consume recognized text and emit response text through this boundary, isolating audio-device and recognition-provider concerns from command logic.
- `src/utils/speech.py`
- `src/voice_assistant.py`

#### Command Processing Layers
Basic commands handle local, deterministic intents such as greetings, time/date/day, help, thanks, and exit. Advanced commands extend that surface with query extraction and remote/task-oriented operations. The assistant dispatches normalized recognized text to these modules according to selected mode; advanced mode includes basic behavior.
- `src/commands/basic_commands.py`
- `src/commands/advanced_commands.py`
- `src/voice_assistant.py`

#### External Services and Side Effects
Advanced handlers form the integration boundary for web search, OpenWeather lookups, joke APIs, and Gmail SMTP email delivery. These paths require network access; weather and email depend on credentials/settings. Email is the highest-impact side effect and should remain explicitly invoked rather than inferred from arbitrary recognition text.
- `src/commands/advanced_commands.py`
- `config/settings.json`
- `src/utils/helpers.py`

#### Configuration, Logging, and Runtime
Configuration holds API keys and user preferences, keeping credentials outside command source. Logging captures interactions and operational failures, with the README indicating logs are created at runtime. Python 3.7+ and dependencies from `requirements.txt` provide the primary execution environment.
- `config/settings.json`
- `src/utils/logger.py`
- `requirements.txt`

#### Optional Visual Frontend
The frontend is an independent React/Vite interface styled as an assistant console, with visual/audio/transcript components and a WebSocket hook. It appears architecturally separate from the Python CLI because no server or WebSocket endpoint is present in the listed Python files; integration would require a new transport/API layer.
- `frontend/src/App.jsx`
- `frontend/src/hooks/useWebSocket.js`
- `frontend/src/components/AssistantContext.jsx`

Main entry points: [`src/voice_assistant.py`](https://github.com/gurunesh30/voice-agent/blob/main/src/voice_assistant.py) (Assistant Core), [`src/commands/advanced_commands.py`](https://github.com/gurunesh30/voice-agent/blob/main/src/commands/advanced_commands.py) (Advanced Commands), [`src/commands/__init__.py`](https://github.com/gurunesh30/voice-agent/blob/main/src/commands/__init__.py) (Command Registry), [`frontend/src/App.jsx`](https://github.com/gurunesh30/voice-agent/blob/main/frontend/src/App.jsx) (Assistant Console)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_python["Python Assistant"]
  node_cli["CLI Bootstrap<br/>Python entry point<br/>[main.py]"]
  node_assistant{{"Assistant Core<br/>orchestrator<br/>[voice_assistant.py]"}}
  node_speech["Speech I/O<br/>audio adapter<br/>[speech.py]"]
  node_commands["Command Registry<br/>command package<br/>[__init__.py]"]
  node_basic["Basic Commands<br/>local intent handlers<br/>[basic_commands.py]"]
  node_advanced["Advanced Commands<br/>integration handlers"]
  node_helpers["Integration Helpers<br/>utility layer<br/>[helpers.py]"]
  node_settings["Settings<br/>configuration<br/>[settings.json]"]
  node_logger["Runtime Logging<br/>logging utility<br/>[logger.py]"]
  node_deps["Python Dependencies<br/>runtime manifest<br/>[requirements.txt]"]
end

subgraph group_integrations["External Integrations"]
  node_services(("Web, Weather, Joke &amp; Gmail<br/>external services"))
end

subgraph group_frontend["Optional Frontend"]
  node_app["Assistant Console<br/>React application<br/>[App.jsx]"]
  node_websocket["WebSocket Hook<br/>browser transport hook<br/>[useWebSocket.js]"]
  node_context["Assistant Context<br/>React context"]
  node_browserentry["Browser Entry<br/>frontend entry point<br/>[main.jsx]"]
end

node_cli -->|"starts"| node_assistant
node_assistant -->|"listens / speaks"| node_speech
node_assistant -->|"loads handlers"| node_commands
node_commands -->|"registers"| node_basic
node_commands -->|"registers"| node_advanced
node_assistant -->|"beginner dispatch"| node_basic
node_assistant -->|"advanced dispatch"| node_advanced
node_advanced -->|"uses"| node_helpers
node_advanced -->|"reads credentials"| node_settings
node_helpers -->|"calls"| node_services
node_assistant -->|"logs lifecycle"| node_logger
node_deps -.->|"provides runtime packages"| node_assistant
node_browserentry -->|"mounts"| node_app
node_app -->|"consumes state"| node_context
node_app -->|"uses transport"| node_websocket
node_websocket -.->|"no endpoint shown"| node_assistant

click node_cli "https://github.com/gurunesh30/voice-agent/blob/main/main.py"
click node_assistant "https://github.com/gurunesh30/voice-agent/blob/main/src/voice_assistant.py"
click node_speech "https://github.com/gurunesh30/voice-agent/blob/main/src/utils/speech.py"
click node_commands "https://github.com/gurunesh30/voice-agent/blob/main/src/commands/__init__.py"
click node_basic "https://github.com/gurunesh30/voice-agent/blob/main/src/commands/basic_commands.py"
click node_advanced "https://github.com/gurunesh30/voice-agent/blob/main/src/commands/advanced_commands.py"
click node_helpers "https://github.com/gurunesh30/voice-agent/blob/main/src/utils/helpers.py"
click node_settings "https://github.com/gurunesh30/voice-agent/blob/main/config/settings.json"
click node_logger "https://github.com/gurunesh30/voice-agent/blob/main/src/utils/logger.py"
click node_deps "https://github.com/gurunesh30/voice-agent/blob/main/requirements.txt"
click node_app "https://github.com/gurunesh30/voice-agent/blob/main/frontend/src/App.jsx"
click node_websocket "https://github.com/gurunesh30/voice-agent/blob/main/frontend/src/hooks/useWebSocket.js"
click node_context "https://github.com/gurunesh30/voice-agent/blob/main/frontend/src/components/AssistantContext.jsx"
click node_browserentry "https://github.com/gurunesh30/voice-agent/blob/main/frontend/src/main.jsx"

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_cli,node_assistant,node_speech,node_commands,node_basic,node_advanced,node_helpers,node_settings,node_logger,node_deps toneBlue
class node_services toneAmber
class node_app,node_websocket,node_context,node_browserentry toneMint
```

## Components

### Python Assistant

Microphone-driven CLI runtime.

- [CLI Bootstrap](https://github.com/gurunesh30/voice-agent/blob/main/main.py): Python entry point · `main.py`
- [Assistant Core](https://github.com/gurunesh30/voice-agent/blob/main/src/voice_assistant.py): orchestrator · Selects modes, interprets input, dispatches commands, and responds. · `src/voice_assistant.py`
- [Speech I/O](https://github.com/gurunesh30/voice-agent/blob/main/src/utils/speech.py): audio adapter · Microphone capture, speech recognition, and text-to-speech boundary. · `src/utils/speech.py`
- [Command Registry](https://github.com/gurunesh30/voice-agent/blob/main/src/commands/__init__.py): command package · `src/commands/__init__.py`
- [Basic Commands](https://github.com/gurunesh30/voice-agent/blob/main/src/commands/basic_commands.py): local intent handlers · Greetings, date/time, help, thanks, and exit. · `src/commands/basic_commands.py`
- [Advanced Commands](https://github.com/gurunesh30/voice-agent/blob/main/src/commands/advanced_commands.py): integration handlers · Extends basic behavior with queries and remote tasks. · `src/commands/advanced_commands.py`
- [Integration Helpers](https://github.com/gurunesh30/voice-agent/blob/main/src/utils/helpers.py): utility layer · `src/utils/helpers.py`
- [Settings](https://github.com/gurunesh30/voice-agent/blob/main/config/settings.json): configuration · API keys and user preferences. · `config/settings.json`
- [Runtime Logging](https://github.com/gurunesh30/voice-agent/blob/main/src/utils/logger.py): logging utility · Records interactions and operational failures. · `src/utils/logger.py`
- [Python Dependencies](https://github.com/gurunesh30/voice-agent/blob/main/requirements.txt): runtime manifest · `requirements.txt`

### External Integrations

Network and credential-backed operations.

- **Web, Weather, Joke & Gmail**: external services · Network APIs plus explicitly invoked SMTP email delivery.

### Optional Frontend

Standalone Vite/Bun-compatible UI with no shown backend bridge.

- [Assistant Console](https://github.com/gurunesh30/voice-agent/blob/main/frontend/src/App.jsx): React application · `frontend/src/App.jsx`
- [WebSocket Hook](https://github.com/gurunesh30/voice-agent/blob/main/frontend/src/hooks/useWebSocket.js): browser transport hook · No corresponding Python endpoint is evident. · `frontend/src/hooks/useWebSocket.js`
- [Assistant Context](https://github.com/gurunesh30/voice-agent/blob/main/frontend/src/components/AssistantContext.jsx): React context · Provides visual, audio, and transcript state to UI components. · `frontend/src/components/AssistantContext.jsx`
- [Browser Entry](https://github.com/gurunesh30/voice-agent/blob/main/frontend/src/main.jsx): frontend entry point · `frontend/src/main.jsx`

## Connections

- CLI Bootstrap → Assistant Core: starts
- Assistant Core → Speech I/O: listens / speaks
- Assistant Core → Command Registry: loads handlers
- Command Registry → Basic Commands: registers
- Command Registry → Advanced Commands: registers
- Assistant Core → Basic Commands: beginner dispatch
- Assistant Core → Advanced Commands: advanced dispatch
- Advanced Commands → Integration Helpers: uses
- Advanced Commands → Settings: reads credentials
- Integration Helpers → Web, Weather, Joke & Gmail: calls
- Assistant Core → Runtime Logging: logs lifecycle
- Python Dependencies → Assistant Core: provides runtime packages
- Browser Entry → Assistant Console: mounts
- Assistant Console → Assistant Context: consumes state
- Assistant Console → WebSocket Hook: uses transport
- WebSocket Hook → Assistant Core: no endpoint shown · A transport/API layer would be required for integration.
