# alok-yadav25/voice-assistant architecture

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

- Interactive diagram: https://gitdiagram.com/alok-yadav25/voice-assistant
- Repository: https://github.com/alok-yadav25/voice-assistant

## Overview

This is a local web-based voice assistant: a user enters or speaks a command in the browser, the frontend sends it to Flask, and the backend dispatches supported requests and returns text for display while speaking responses locally. The README describes typed and optional spoken input, offline text-to-speech, and simple commands; the excerpts also show weather, search, volume, screenshot, news, and calculation features. Some backend branches are omitted, so uncertain integrations are shown only as unverified.

Main entry points: [`static/js/script.js`](https://github.com/alok-yadav25/voice-assistant/blob/main/static/js/script.js) (UI interactions), [`app.py`](https://github.com/alok-yadav25/voice-assistant/blob/main/app.py) (Command dispatch), [`templates/index.html`](https://github.com/alok-yadav25/voice-assistant/blob/main/templates/index.html) (Assistant page), [`static/css/style.css`](https://github.com/alok-yadav25/voice-assistant/blob/main/static/css/style.css) (Page styling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Browser interface"]
  node_page["Assistant page<br/>[index.html]"]
  node_frontend["UI interactions<br/>[script.js]"]
  node_history[("Command history<br/>[script.js]")]
  node_styling["Page styling<br/>[style.css]"]
end

subgraph group_backend["Assistant backend"]
  node_flask["Flask routes<br/>[app.py]"]
  node_dispatcher["Command dispatch<br/>[app.py]"]
  node_responses["Command responses<br/>[app.py]"]
  node_speech["Speech output<br/>[app.py]"]
end

subgraph group_integrations["Local and external capabilities"]
  node_weather["Weather lookup<br/>[app.py]"]
  node_web_search["Web search<br/>[app.py]"]
  node_system_actions["System actions<br/>[app.py]"]
  node_browser_speech["Browser speech recognition"]
end

node_user(("User"))
node_weather_service["Weather service"]
node_browser["Local browser and OS"]
node_tts_engine["pyttsx3 engine"]

node_user -->|"uses"| node_page
node_page -.->|"loads interactions"| node_frontend
node_frontend -->|"POSTs command"| node_flask
node_flask -->|"renders"| node_page
node_frontend -->|"stores history"| node_history
node_frontend -->|"starts recognition"| node_browser_speech
node_browser_speech -->|"supplies transcript"| node_frontend
node_frontend -.->|"uses styles"| node_styling
node_flask -->|"routes command"| node_dispatcher
node_dispatcher -->|"selects response"| node_responses
node_dispatcher -->|"calls weather lookup"| node_weather
node_weather -->|"requests weather"| node_weather_service
node_dispatcher -.->|"handles search"| node_web_search
node_dispatcher -->|"handles actions"| node_system_actions
node_dispatcher -->|"speaks responses"| node_speech
node_speech -->|"generates speech"| node_tts_engine
node_system_actions -->|"opens sites or adjusts system"| node_browser
node_responses -->|"returns JSON"| node_frontend

click node_page "https://github.com/alok-yadav25/voice-assistant/blob/main/templates/index.html"
click node_frontend "https://github.com/alok-yadav25/voice-assistant/blob/main/static/js/script.js"
click node_history "https://github.com/alok-yadav25/voice-assistant/blob/main/static/js/script.js"
click node_styling "https://github.com/alok-yadav25/voice-assistant/blob/main/static/css/style.css"
click node_flask "https://github.com/alok-yadav25/voice-assistant/blob/main/app.py"
click node_dispatcher "https://github.com/alok-yadav25/voice-assistant/blob/main/app.py"
click node_responses "https://github.com/alok-yadav25/voice-assistant/blob/main/app.py"
click node_speech "https://github.com/alok-yadav25/voice-assistant/blob/main/app.py"
click node_weather "https://github.com/alok-yadav25/voice-assistant/blob/main/app.py"
click node_web_search "https://github.com/alok-yadav25/voice-assistant/blob/main/app.py"
click node_system_actions "https://github.com/alok-yadav25/voice-assistant/blob/main/app.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_page,node_frontend,node_history,node_styling,node_user,node_browser toneBlue
class node_flask,node_dispatcher,node_responses,node_speech toneAmber
class node_weather,node_web_search,node_system_actions,node_browser_speech toneMint
class node_weather_service,node_tts_engine toneIndigo
```

## Components

### Browser interface

- [Assistant page](https://github.com/alok-yadav25/voice-assistant/blob/main/templates/index.html): `templates/index.html`
- [UI interactions](https://github.com/alok-yadav25/voice-assistant/blob/main/static/js/script.js): `static/js/script.js`
- [Command history](https://github.com/alok-yadav25/voice-assistant/blob/main/static/js/script.js): `static/js/script.js`
- [Page styling](https://github.com/alok-yadav25/voice-assistant/blob/main/static/css/style.css): `static/css/style.css`

### Assistant backend

- [Flask routes](https://github.com/alok-yadav25/voice-assistant/blob/main/app.py): `app.py`
- [Command dispatch](https://github.com/alok-yadav25/voice-assistant/blob/main/app.py): `app.py`
- [Command responses](https://github.com/alok-yadav25/voice-assistant/blob/main/app.py): `app.py`
- [Speech output](https://github.com/alok-yadav25/voice-assistant/blob/main/app.py): `app.py`

### Local and external capabilities

- [Weather lookup](https://github.com/alok-yadav25/voice-assistant/blob/main/app.py): `app.py`
- [Web search](https://github.com/alok-yadav25/voice-assistant/blob/main/app.py): `app.py`
- [System actions](https://github.com/alok-yadav25/voice-assistant/blob/main/app.py): `app.py`
- **Browser speech recognition**

### Other components

- **User**
- **Weather service**
- **Local browser and OS**
- **pyttsx3 engine**

## Connections

- User → Assistant page: uses (evidence: `README.md`)
- Assistant page → UI interactions: loads interactions
- UI interactions → Flask routes: POSTs command (evidence: `static/js/script.js`)
- Flask routes → Assistant page: renders (evidence: `app.py`)
- UI interactions → Command history: stores history (evidence: `static/js/script.js`)
- UI interactions → Browser speech recognition: starts recognition (evidence: `static/js/script.js`)
- Browser speech recognition → UI interactions: supplies transcript (evidence: `static/js/script.js`)
- UI interactions → Page styling: uses styles
- Flask routes → Command dispatch: routes command (evidence: `app.py`)
- Command dispatch → Command responses: selects response (evidence: `app.py`)
- Command dispatch → Weather lookup: calls weather lookup (evidence: `app.py`)
- Weather lookup → Weather service: requests weather (evidence: `app.py`)
- Command dispatch → Web search: handles search (evidence: `app.py`)
- Command dispatch → System actions: handles actions (evidence: `app.py`)
- Command dispatch → Speech output: speaks responses (evidence: `app.py`)
- Speech output → pyttsx3 engine: generates speech (evidence: `app.py`)
- System actions → Local browser and OS: opens sites or adjusts system (evidence: `app.py`)
- Command responses → UI interactions: returns JSON (evidence: `static/js/script.js`)
