# amitabhchondar-ux/asva architecture

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

- Interactive diagram: https://gitdiagram.com/amitabhchondar-ux/asva
- Repository: https://github.com/amitabhchondar-ux/asva

## Overview

ASVA is a private, offline voice-control system: an ESP32-S3 recognizes a wake word and fixed commands locally, controls an actuator, and reports event metadata to a local hub. The hub manages MQTT devices, persists telemetry and events, exposes authenticated REST and WebSocket interfaces, and serves a browser dashboard for live monitoring, history, commands, and evaluation. A simulator supports trying the platform without hardware; ML scripts prepare data, train, and evaluate models. The README documents these product flows; some route and page implementations were not sampled, so their internal links are not inferred.

Main entry points: [`hub/web/src/lib/api.ts`](https://github.com/amitabhchondar-ux/asva/blob/main/hub/web/src/lib/api.ts) (Browser API client), [`hub/server/src/server.ts`](https://github.com/amitabhchondar-ux/asva/blob/main/hub/server/src/server.ts) (Hub server), [`hub/server/src/routes`](https://github.com/amitabhchondar-ux/asva/tree/main/hub/server/src/routes) (REST routes), [`firmware/main/voice_engine.cpp`](https://github.com/amitabhchondar-ux/asva/blob/main/firmware/main/voice_engine.cpp) (Voice recognition)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["On-device voice control"]
  node_esp["ESP32-S3<br/>[app_main.cpp]"]
  node_audio["Audio capture<br/>[audio_i2s.cpp]"]
  node_voice["Voice recognition<br/>[voice_engine.cpp]"]
  node_actuator["Local actuator<br/>[actuator.cpp]"]
  node_wifi["Wi-Fi link<br/>[wifi_manager.cpp]"]
  node_device_mqtt["Device MQTT link<br/>[mqtt_link.cpp]"]
end

subgraph group_hub["Hub services"]
  node_server["Hub server<br/>[server.ts]"]
  node_broker["Embedded MQTT broker<br/>[broker.ts]"]
  node_mqtt_client["Hub MQTT client<br/>[client.ts]"]
  node_routes["REST routes"]
  node_auth["Authentication and roles<br/>[guard.ts]"]
  node_ws["Live WebSocket feed<br/>[wsHandler.ts]"]
  node_database[("SQLite records<br/>[db.ts]")]
end

subgraph group_web["Dashboard tools"]
  node_shelf["3D bookshelf<br/>[LandingPages.tsx]"]
  node_api["Browser API client<br/>[api.ts]"]
  node_dashboard["Live device view<br/>[Dashboard.tsx]"]
  node_history["Event ledger<br/>[History.tsx]"]
  node_commands["Command controls<br/>[Commands.tsx]"]
  node_evaluation["Evaluation lab<br/>[Evaluation.tsx]"]
end

subgraph group_model["Model workflow"]
  node_prepare["Data preparation<br/>[prepare_data.py]"]
  node_train["Model training<br/>[train.py]"]
  node_evaluate["Model evaluation<br/>[evaluate.py]"]
end

subgraph group_virtual["Hardware simulation"]
  node_simulator["Virtual ESP32<br/>[simulator.ts]"]
end

node_maker(("User"))
node_browser(("Browser"))
node_mic(("I²S microphone"))

node_maker -->|"speaks commands"| node_mic
node_mic -->|"provides audio"| node_audio
node_audio -->|"feeds audio"| node_voice
node_voice -->|"triggers locally"| node_actuator
node_voice -->|"reports events"| node_device_mqtt
node_wifi -->|"enables network"| node_device_mqtt
node_device_mqtt -->|"publishes metadata"| node_broker
node_server -->|"starts broker"| node_broker
node_server -->|"initializes client"| node_mqtt_client
node_mqtt_client -->|"stores device data"| node_database
node_mqtt_client -->|"broadcasts updates"| node_ws
node_server -->|"registers clients"| node_ws
node_server -->|"registers routes"| node_routes
node_routes -->|"reads and writes"| node_database
node_routes -->|"checks roles"| node_auth
node_auth -->|"checks accounts"| node_database
node_maker -->|"uses dashboard"| node_browser
node_browser -->|"opens interface"| node_shelf
node_dashboard -.->|"requests device data"| node_api
node_history -->|"requests event history"| node_api
node_evaluation -->|"requests session metrics"| node_api
node_commands -.->|"sends commands"| node_api
node_api -->|"calls REST API"| node_routes
node_ws -.->|"streams live updates"| node_dashboard
node_maker -->|"tries without hardware"| node_simulator
node_simulator -.->|"simulates device link"| node_broker
node_prepare -.->|"prepares training data"| node_train
node_train -.->|"evaluates trained model"| node_evaluate

click node_esp "https://github.com/amitabhchondar-ux/asva/blob/main/firmware/main/app_main.cpp"
click node_audio "https://github.com/amitabhchondar-ux/asva/blob/main/firmware/main/audio_i2s.cpp"
click node_voice "https://github.com/amitabhchondar-ux/asva/blob/main/firmware/main/voice_engine.cpp"
click node_actuator "https://github.com/amitabhchondar-ux/asva/blob/main/firmware/main/actuator.cpp"
click node_wifi "https://github.com/amitabhchondar-ux/asva/blob/main/firmware/main/wifi_manager.cpp"
click node_device_mqtt "https://github.com/amitabhchondar-ux/asva/blob/main/firmware/main/mqtt_link.cpp"
click node_server "https://github.com/amitabhchondar-ux/asva/blob/main/hub/server/src/server.ts"
click node_broker "https://github.com/amitabhchondar-ux/asva/blob/main/hub/server/src/mqtt/broker.ts"
click node_mqtt_client "https://github.com/amitabhchondar-ux/asva/blob/main/hub/server/src/mqtt/client.ts"
click node_routes "https://github.com/amitabhchondar-ux/asva/tree/main/hub/server/src/routes"
click node_auth "https://github.com/amitabhchondar-ux/asva/blob/main/hub/server/src/auth/guard.ts"
click node_ws "https://github.com/amitabhchondar-ux/asva/blob/main/hub/server/src/ws/wsHandler.ts"
click node_database "https://github.com/amitabhchondar-ux/asva/blob/main/hub/server/src/db/db.ts"
click node_shelf "https://github.com/amitabhchondar-ux/asva/blob/main/hub/web/src/shaders/landing-pages/LandingPages.tsx"
click node_api "https://github.com/amitabhchondar-ux/asva/blob/main/hub/web/src/lib/api.ts"
click node_dashboard "https://github.com/amitabhchondar-ux/asva/blob/main/hub/web/src/pages/Dashboard.tsx"
click node_history "https://github.com/amitabhchondar-ux/asva/blob/main/hub/web/src/pages/History.tsx"
click node_commands "https://github.com/amitabhchondar-ux/asva/blob/main/hub/web/src/pages/Commands.tsx"
click node_evaluation "https://github.com/amitabhchondar-ux/asva/blob/main/hub/web/src/pages/Evaluation.tsx"
click node_prepare "https://github.com/amitabhchondar-ux/asva/blob/main/ml/prepare_data.py"
click node_train "https://github.com/amitabhchondar-ux/asva/blob/main/ml/train.py"
click node_evaluate "https://github.com/amitabhchondar-ux/asva/blob/main/ml/evaluate.py"
click node_simulator "https://github.com/amitabhchondar-ux/asva/blob/main/hub/simulator/src/simulator.ts"

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_esp,node_audio,node_voice,node_actuator,node_wifi,node_device_mqtt,node_maker,node_browser toneBlue
class node_server,node_broker,node_mqtt_client,node_routes,node_auth,node_ws,node_database toneAmber
class node_shelf,node_api,node_dashboard,node_history,node_commands,node_evaluation toneMint
class node_prepare,node_train,node_evaluate toneRose
class node_simulator,node_mic toneIndigo
```

## Components

### On-device voice control

- [ESP32-S3](https://github.com/amitabhchondar-ux/asva/blob/main/firmware/main/app_main.cpp): `firmware/main/app_main.cpp`
- [Audio capture](https://github.com/amitabhchondar-ux/asva/blob/main/firmware/main/audio_i2s.cpp): `firmware/main/audio_i2s.cpp`
- [Voice recognition](https://github.com/amitabhchondar-ux/asva/blob/main/firmware/main/voice_engine.cpp): `firmware/main/voice_engine.cpp`
- [Local actuator](https://github.com/amitabhchondar-ux/asva/blob/main/firmware/main/actuator.cpp): `firmware/main/actuator.cpp`
- [Wi-Fi link](https://github.com/amitabhchondar-ux/asva/blob/main/firmware/main/wifi_manager.cpp): `firmware/main/wifi_manager.cpp`
- [Device MQTT link](https://github.com/amitabhchondar-ux/asva/blob/main/firmware/main/mqtt_link.cpp): `firmware/main/mqtt_link.cpp`

### Hub services

- [Hub server](https://github.com/amitabhchondar-ux/asva/blob/main/hub/server/src/server.ts): `hub/server/src/server.ts`
- [Embedded MQTT broker](https://github.com/amitabhchondar-ux/asva/blob/main/hub/server/src/mqtt/broker.ts): `hub/server/src/mqtt/broker.ts`
- [Hub MQTT client](https://github.com/amitabhchondar-ux/asva/blob/main/hub/server/src/mqtt/client.ts): `hub/server/src/mqtt/client.ts`
- [REST routes](https://github.com/amitabhchondar-ux/asva/tree/main/hub/server/src/routes): `hub/server/src/routes`
- [Authentication and roles](https://github.com/amitabhchondar-ux/asva/blob/main/hub/server/src/auth/guard.ts): `hub/server/src/auth/guard.ts`
- [Live WebSocket feed](https://github.com/amitabhchondar-ux/asva/blob/main/hub/server/src/ws/wsHandler.ts): `hub/server/src/ws/wsHandler.ts`
- [SQLite records](https://github.com/amitabhchondar-ux/asva/blob/main/hub/server/src/db/db.ts): `hub/server/src/db/db.ts`

### Dashboard tools

- [3D bookshelf](https://github.com/amitabhchondar-ux/asva/blob/main/hub/web/src/shaders/landing-pages/LandingPages.tsx): `hub/web/src/shaders/landing-pages/LandingPages.tsx`
- [Browser API client](https://github.com/amitabhchondar-ux/asva/blob/main/hub/web/src/lib/api.ts): `hub/web/src/lib/api.ts`
- [Live device view](https://github.com/amitabhchondar-ux/asva/blob/main/hub/web/src/pages/Dashboard.tsx): `hub/web/src/pages/Dashboard.tsx`
- [Event ledger](https://github.com/amitabhchondar-ux/asva/blob/main/hub/web/src/pages/History.tsx): `hub/web/src/pages/History.tsx`
- [Command controls](https://github.com/amitabhchondar-ux/asva/blob/main/hub/web/src/pages/Commands.tsx): `hub/web/src/pages/Commands.tsx`
- [Evaluation lab](https://github.com/amitabhchondar-ux/asva/blob/main/hub/web/src/pages/Evaluation.tsx): `hub/web/src/pages/Evaluation.tsx`

### Model workflow

- [Data preparation](https://github.com/amitabhchondar-ux/asva/blob/main/ml/prepare_data.py): `ml/prepare_data.py`
- [Model training](https://github.com/amitabhchondar-ux/asva/blob/main/ml/train.py): `ml/train.py`
- [Model evaluation](https://github.com/amitabhchondar-ux/asva/blob/main/ml/evaluate.py): `ml/evaluate.py`

### Hardware simulation

- [Virtual ESP32](https://github.com/amitabhchondar-ux/asva/blob/main/hub/simulator/src/simulator.ts): `hub/simulator/src/simulator.ts`

### Other components

- **User**
- **Browser**
- **I²S microphone**

## Connections

- User → I²S microphone: speaks commands (evidence: `README.md`)
- I²S microphone → Audio capture: provides audio (evidence: `README.md`)
- Audio capture → Voice recognition: feeds audio (evidence: `firmware/main/voice_engine.cpp`)
- Voice recognition → Local actuator: triggers locally (evidence: `README.md`)
- Voice recognition → Device MQTT link: reports events (evidence: `README.md`)
- Wi-Fi link → Device MQTT link: enables network (evidence: `README.md`)
- Device MQTT link → Embedded MQTT broker: publishes metadata (evidence: `README.md`)
- Hub server → Embedded MQTT broker: starts broker (evidence: `hub/server/src/server.ts`)
- Hub server → Hub MQTT client: initializes client (evidence: `hub/server/src/server.ts`)
- Hub MQTT client → SQLite records: stores device data (evidence: `hub/server/src/mqtt/client.ts`)
- Hub MQTT client → Live WebSocket feed: broadcasts updates (evidence: `hub/server/src/mqtt/client.ts`)
- Hub server → Live WebSocket feed: registers clients (evidence: `hub/server/src/server.ts`)
- Hub server → REST routes: registers routes (evidence: `hub/server/src/server.ts`)
- REST routes → SQLite records: reads and writes (evidence: `hub/server/src/routes/sessions.ts`)
- REST routes → Authentication and roles: checks roles (evidence: `hub/server/src/routes/sessions.ts`)
- Authentication and roles → SQLite records: checks accounts (evidence: `hub/server/src/auth/guard.ts`)
- User → Browser: uses dashboard (evidence: `README.md`)
- Browser → 3D bookshelf: opens interface
- Live device view → Browser API client: requests device data
- Event ledger → Browser API client: requests event history (evidence: `hub/web/src/pages/History.tsx`)
- Evaluation lab → Browser API client: requests session metrics (evidence: `hub/web/src/pages/Evaluation.tsx`)
- Command controls → Browser API client: sends commands
- Browser API client → REST routes: calls REST API (evidence: `README.md`)
- Live WebSocket feed → Live device view: streams live updates
- User → Virtual ESP32: tries without hardware (evidence: `README.md`)
- Virtual ESP32 → Embedded MQTT broker: simulates device link
- Data preparation → Model training: prepares training data
- Model training → Model evaluation: evaluates trained model
