# bug-scorchers/grace_voice_agent architecture

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

- Interactive diagram: https://gitdiagram.com/bug-scorchers/grace_voice_agent
- Repository: https://github.com/bug-scorchers/grace_voice_agent

## Overview

GRACE is a Windows-oriented voice and gesture assistant that turns speech or hand poses into computer actions and spoken responses. The main voice workflow is microphone capture, wake-word/utterance handling, transcription, fixed-command parsing or LLM routing, then intent execution and feedback. Separate capabilities include screen reading and analysis, web search, image generation, dictation, and gesture control. The graph follows documented behavior and source-index references; several runtime and integration details are unsampled, so uncertain links are omitted.

Main entry points: [`grace/legacy_voice.py`](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/legacy_voice.py) (Voice agent), [`grace/__main__.py`](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/__main__.py) (Application runtime), [`grace/input/voice.py`](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/input/voice.py) (Voice capture), [`grace/actions/registry.py`](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/actions/registry.py) (Action registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Input and UI"]
  node_voice["Voice capture<br/>[voice.py]"]
  node_audio["Audio and VAD<br/>[audio.py]"]
  node_wake["Wake detection<br/>[wakeword.py]"]
  node_stt["Speech recognition<br/>[base.py]"]
  node_gestures["Gesture control<br/>[controller.py]"]
  node_hotkeys["Global hotkeys<br/>[hotkeys.py]"]
  node_overlay["Status overlay<br/>[overlay.py]"]
  node_tts["Speech output<br/>[tts.py]"]
end

subgraph group_understanding["Intent handling"]
  node_agent["Voice agent<br/>[legacy_voice.py]"]
  node_grammar["Command grammar<br/>[grammar.py]"]
  node_dialogue["Follow-up dialogue<br/>[dialogue.py]"]
  node_router["LLM router<br/>[router.py]"]
  node_providers["Chat providers<br/>[providers.py]"]
end

subgraph group_capabilities["Assistant capabilities"]
  node_tools["Tool definitions<br/>[tools.py]"]
  node_search["Web search<br/>[search.py]"]
  node_images["Image understanding<br/>[images.py]"]
  node_assistant["Code assistance<br/>[assistant.py]"]
  node_screen["Screen reading<br/>[screen_reader.py]"]
end

subgraph group_execution["Actions and control"]
  node_registry["Action registry<br/>[registry.py]"]
  node_app_actions["App and window actions<br/>[apps.py]"]
  node_input_actions["Input control<br/>[input_ctl.py]"]
  node_system_actions["System actions<br/>[system.py]"]
  node_executor["Action executor<br/>[executor.py]"]
end

subgraph group_foundation["Runtime services"]
  node_bus["Event bus<br/>[bus.py]"]
  node_quota[("Quota governor<br/>[quota.py]")]
  node_config["Configuration<br/>[config.py]"]
  node_runtime["Application runtime<br/>[__main__.py]"]
end

node_user(("User"))

node_user -->|"speaks to"| node_voice
node_voice -->|"captures audio"| node_audio
node_voice -->|"checks wake word"| node_wake
node_voice -->|"transcribes"| node_stt
node_voice -->|"sends transcript"| node_agent
node_agent -->|"parses commands"| node_grammar
node_agent -->|"resolves follow-ups"| node_dialogue
node_agent -->|"routes unmatched text"| node_router
node_router -->|"requests completion"| node_providers
node_router -->|"validates tool calls"| node_tools
node_tools -->|"uses action schema"| node_registry
node_agent -->|"dispatches intents"| node_executor
node_executor -->|"executes actions"| node_registry
node_registry -->|"registers handlers"| node_app_actions
node_registry -->|"registers handlers"| node_input_actions
node_registry -->|"registers handlers"| node_system_actions
node_agent -->|"speaks replies"| node_tts
node_agent -->|"reads screen"| node_screen
node_assistant -->|"uses image analysis"| node_images
node_assistant -->|"uses web search"| node_search
node_images -->|"reads screen content"| node_screen
node_images -->|"checks usage"| node_quota
node_search -->|"records search use"| node_quota
node_user -->|"poses to camera"| node_gestures
node_user -->|"presses shortcuts"| node_hotkeys
node_runtime -->|"starts voice input"| node_voice
node_runtime -->|"starts gesture control"| node_gestures
node_runtime -->|"starts overlay"| node_overlay
node_overlay -->|"subscribes to events"| node_bus
node_overlay -->|"reads runtime state"| node_runtime
node_runtime -->|"loads settings"| node_config
node_runtime -->|"starts event bus"| node_bus

click node_voice "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/input/voice.py"
click node_audio "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/input/audio.py"
click node_wake "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/input/wakeword.py"
click node_stt "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/input/stt/base.py"
click node_gestures "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/input/gestures/controller.py"
click node_hotkeys "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/input/hotkeys.py"
click node_overlay "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/ui/overlay.py"
click node_agent "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/legacy_voice.py"
click node_grammar "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/intent/grammar.py"
click node_dialogue "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/intent/dialogue.py"
click node_router "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/intent/router.py"
click node_providers "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/intent/providers.py"
click node_tools "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/intent/tools.py"
click node_search "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/intent/search.py"
click node_images "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/intent/images.py"
click node_assistant "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/intent/assistant.py"
click node_screen "https://github.com/bug-scorchers/grace_voice_agent/blob/main/screen_reader.py"
click node_registry "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/actions/registry.py"
click node_app_actions "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/actions/apps.py"
click node_input_actions "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/actions/input_ctl.py"
click node_system_actions "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/actions/system.py"
click node_executor "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/actions/executor.py"
click node_tts "https://github.com/bug-scorchers/grace_voice_agent/blob/main/tts.py"
click node_bus "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/core/bus.py"
click node_quota "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/core/quota.py"
click node_config "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/config.py"
click node_runtime "https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/__main__.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_voice,node_audio,node_wake,node_stt,node_gestures,node_hotkeys,node_overlay,node_tts,node_user toneBlue
class node_agent,node_grammar,node_dialogue,node_router,node_providers toneAmber
class node_tools,node_search,node_images,node_assistant,node_screen toneMint
class node_registry,node_app_actions,node_input_actions,node_system_actions,node_executor toneRose
class node_bus,node_quota,node_config,node_runtime toneIndigo
```

## Components

### Input and UI

- [Voice capture](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/input/voice.py): `grace/input/voice.py`
- [Audio and VAD](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/input/audio.py): `grace/input/audio.py`
- [Wake detection](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/input/wakeword.py): `grace/input/wakeword.py`
- [Speech recognition](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/input/stt/base.py): `grace/input/stt/base.py`
- [Gesture control](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/input/gestures/controller.py): `grace/input/gestures/controller.py`
- [Global hotkeys](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/input/hotkeys.py): `grace/input/hotkeys.py`
- [Status overlay](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/ui/overlay.py): `grace/ui/overlay.py`
- [Speech output](https://github.com/bug-scorchers/grace_voice_agent/blob/main/tts.py): `tts.py`

### Intent handling

- [Voice agent](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/legacy_voice.py): `grace/legacy_voice.py`
- [Command grammar](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/intent/grammar.py): `grace/intent/grammar.py`
- [Follow-up dialogue](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/intent/dialogue.py): `grace/intent/dialogue.py`
- [LLM router](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/intent/router.py): `grace/intent/router.py`
- [Chat providers](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/intent/providers.py): `grace/intent/providers.py`

### Assistant capabilities

- [Tool definitions](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/intent/tools.py): `grace/intent/tools.py`
- [Web search](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/intent/search.py): `grace/intent/search.py`
- [Image understanding](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/intent/images.py): `grace/intent/images.py`
- [Code assistance](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/intent/assistant.py): `grace/intent/assistant.py`
- [Screen reading](https://github.com/bug-scorchers/grace_voice_agent/blob/main/screen_reader.py): `screen_reader.py`

### Actions and control

- [Action registry](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/actions/registry.py): `grace/actions/registry.py`
- [App and window actions](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/actions/apps.py): `grace/actions/apps.py`
- [Input control](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/actions/input_ctl.py): `grace/actions/input_ctl.py`
- [System actions](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/actions/system.py): `grace/actions/system.py`
- [Action executor](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/actions/executor.py): `grace/actions/executor.py`

### Runtime services

- [Event bus](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/core/bus.py): `grace/core/bus.py`
- [Quota governor](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/core/quota.py): `grace/core/quota.py`
- [Configuration](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/config.py): `grace/config.py`
- [Application runtime](https://github.com/bug-scorchers/grace_voice_agent/blob/main/grace/__main__.py): `grace/__main__.py`

### Other components

- **User**

## Connections

- User → Voice capture: speaks to (evidence: `README.md`)
- Voice capture → Audio and VAD: captures audio (evidence: `grace/input/voice.py`)
- Voice capture → Wake detection: checks wake word (evidence: `grace/input/voice.py`)
- Voice capture → Speech recognition: transcribes (evidence: `grace/input/voice.py`)
- Voice capture → Voice agent: sends transcript (evidence: `grace/legacy_voice.py`)
- Voice agent → Command grammar: parses commands (evidence: `grace/legacy_voice.py`)
- Voice agent → Follow-up dialogue: resolves follow-ups (evidence: `grace/legacy_voice.py`)
- Voice agent → LLM router: routes unmatched text (evidence: `grace/legacy_voice.py`)
- LLM router → Chat providers: requests completion (evidence: `grace/intent/router.py`)
- LLM router → Tool definitions: validates tool calls (evidence: `grace/intent/router.py`)
- Tool definitions → Action registry: uses action schema (evidence: `grace/intent/tools.py`)
- Voice agent → Action executor: dispatches intents (evidence: `grace/legacy_voice.py`)
- Action executor → Action registry: executes actions (evidence: `grace/actions/executor.py`)
- Action registry → App and window actions: registers handlers (evidence: `grace/actions/__init__.py`)
- Action registry → Input control: registers handlers (evidence: `grace/actions/__init__.py`)
- Action registry → System actions: registers handlers (evidence: `grace/actions/__init__.py`)
- Voice agent → Speech output: speaks replies (evidence: `grace/legacy_voice.py`)
- Voice agent → Screen reading: reads screen (evidence: `grace/legacy_voice.py`)
- Code assistance → Image understanding: uses image analysis (evidence: `grace/intent/assistant.py`)
- Code assistance → Web search: uses web search (evidence: `grace/intent/assistant.py`)
- Image understanding → Screen reading: reads screen content (evidence: `grace/intent/images.py`)
- Image understanding → Quota governor: checks usage (evidence: `grace/intent/images.py`)
- Web search → Quota governor: records search use (evidence: `grace/intent/search.py`)
- User → Gesture control: poses to camera (evidence: `README.md`)
- User → Global hotkeys: presses shortcuts (evidence: `README.md`)
- Application runtime → Voice capture: starts voice input (evidence: `grace/__main__.py`)
- Application runtime → Gesture control: starts gesture control (evidence: `grace/__main__.py`)
- Application runtime → Status overlay: starts overlay (evidence: `grace/__main__.py`)
- Status overlay → Event bus: subscribes to events (evidence: `grace/ui/overlay.py`)
- Status overlay → Application runtime: reads runtime state (evidence: `grace/ui/overlay.py`)
- Application runtime → Configuration: loads settings (evidence: `grace/__main__.py`)
- Application runtime → Event bus: starts event bus (evidence: `grace/__main__.py`)
