Klaus is a Vite + React SPA paired with an Express API. The UI combines a 3D character scene, chat interface, and audio playback, while the API provides chat completions and TTS audio streaming
Klaus is a TypeScript web app with a Vite + React frontend and an Express API backend. The frontend renders a 3D scene with a chat UI and audio-driven lip sync. The backend exposes two HTTP endpoints: chat completions and TTS audio streaming.
- 3D character scene with postprocessing and particle VFX
- Chat UI with message history and status-driven states
- LLM completion proxy endpoint with in-memory conversation history
- TTS proxy endpoint that streams
audio/mpeg - Client-side audio playback with lip sync driven by viseme detection
- React 19 + Vite
- TypeScript
- Tailwind CSS (via
@tailwindcss/vite) three,@react-three/fiber,@react-three/drei,@react-three/postprocessingwawa-vfx,wawa-lipsyncmotionfor UI animation- Zustand for client state
- Node.js + Express 5
- TypeScript
axiosfor HTTPcorsanddotenvgoogle-tts-apifor TTS URL generation
- Vite (frontend)
- TypeScript compiler (
tsc) tsxfor server development- npm (package-lock files present)
- ESLint (client)
- Prettier (client and server)
- TypeScript strict mode
The repository is split into a client Vite SPA and a server Express API. The browser client calls the API for chat responses and TTS audio. The API forwards chat prompts to a completion endpoint configured via environment variables and proxies Google TTS audio as a stream.
graph TD
Browser[Browser]
Browser --> Frontend[React/Vite SPA]
Frontend -->|GET /api/ai?message=...| API[Express API]
API -->|POST completion| LLM["LLM completion endpoint"]
Frontend -->|GET /api/tts?text=...| API
API -->|Stream audio/mpeg| TTS["Google TTS"]
client/— Vite + React frontendclient/src/components/— 3D scene, camera controls, UIclient/src/hooks/— Zustand chatbot state and audio/lipsync logicclient/src/assets/— models, textures, audioclient/src/utils/— helper utilitiesserver/— Express API serverserver/src/— server bootstrap and configurationserver/src/routes/— HTTP routes for AI and TTSserver/src/controller/— AI and TTS controller logic
UI input → sendMessage → GET /api/ai?message=... → completion response → GET /api/tts?text=... → audio stream → WebAudio playback → lip sync and UI update
The server keeps a small in-memory chat history (up to 6 entries) per process.
HTTP endpoints use query parameters. /api/ai returns JSON; /api/tts returns audio/mpeg streaming responses.
GET /api/ai?message=...→{ response: string }GET /api/tts?text=...→audio/mpegstream
- Node.js
- npm
cd server
npm installcd client
npm installcd server
npm run devcd client
npm run devcd server
npm run buildcd client
npm run buildcd client
npm run lintPrettier config exists in client/.prettierrc and server/.prettierrc.
The project uses .env.local files in both client/ and server/.
Client (client/.env.local) variables:
VITE_CHAT_API_URL— chat endpoint base URLVITE_TTS_API_URL— TTS endpoint base URL
Server (server/.env.local and server/src/env.d.ts) variables:
LLAMA_API_URL— completion endpoint URLLLAMA_API_KEY— API key for the completion endpointCLIENT_URL— CORS origin for the clientPORT— server port (default 8000 if not set)NODE_ENV—developmentorproduction
- The AI controller builds a prompt with a short, fixed chat history and sanitizes replies to remove stage directions and non-ASCII characters.
- The TTS controller streams Google TTS audio directly to the client instead of redirecting.
- The client routes audio through WebAudio into a
MediaStreamto avoid double playback and drive viseme-based lip sync. - 3D rendering uses
react-three-fiberwith postprocessing and custom VFX emitters.
This project is licensed under the MIT License. See the for details.
