User interface for the voice assistant system. React + TypeScript + Vite. Communicates with the backend via REST (/api/public/stt) and WebSocket (/ws/public).
- Node.js ≥ 18
- running Homemade Alexa Server
npm installnpm run devThe Vite dev server starts on http://localhost:5173 by default. Requests to /api/public/* and WebSocket /ws/public are proxied to the backend.
The default backend address is http://YOUR_SERVER_IP:8080. To override it without editing the file:
ALEXA_SERVER=http://other-host:8080 npm run devnpm run buildOutput goes to dist/. To serve the app under a path other than / (e.g. /alexa/), set the VITE_BASE variable:
VITE_BASE=/alexa/ npm run buildThe built dist/ should be copied as webapp_dist/ next to the server's src/ directory — FastAPI serves it statically under the path configured in config.toml ([webapp] base).
| Variable | Default | Description |
|---|---|---|
ALEXA_SERVER |
http://YOUR_SERVER_IP:8080 |
Backend address (dev proxy only) |
VITE_BASE |
/ |
Base URL of the app in the production build |
VITE_API_URL |
(none — uses location.origin) |
Overrides the base URL for API calls and WebSocket at runtime |
src/
├── main.tsx # entry point, mounts <App>
├── App.tsx # main component; auth state handling, login screen
├── useAuth.ts # JWT token in localStorage; login / logout
├── useAlexa.ts # recording logic, VAD, STT, WebSocket
└── LoginScreen.tsx # login screen
- On first open, the app checks
localStoragefor thealexa_tokenkey. No token → login screen. - Login:
POST /api/public/auth/loginwith password → JWT saved inlocalStorage. - After login, the webapp connects to
WebSocket /ws/public?token=<jwt>. - User clicks the button → browser records audio via Web Audio API with VAD detection (300 ms silence or 5 s timeout).
- 16-bit 16 kHz PCM sent to
POST /api/public/sttwith headerAuthorization: Bearer <token>. - Server returns
{command, next, audio_b64}— app plays TTS audio and optionally starts the next recording (next === "listen"). - On HTTP 401, the token is cleared and the app returns to the login screen.
| Method | Path | Auth | Description |
|---|---|---|---|
POST |
/api/public/auth/login |
no | {password} → {token} |
POST |
/api/public/stt |
Bearer | PCM audio → {command, next, audio_b64} |
WS |
/ws/public?token= |
token in URL | server-pushed commands |