How rutujakumbhar17/kai-the-companion works
KAI is a multimodal emotional companion. The main user-to-result flow is camera frames and chat input from the browser, through Flask/Socket.IO, to emotion analysis and mood-aware LLM responses, with optional speech output; diary entries and emotion/chat records provide persistent reflection and dashboard views. The README documents dashboard, diary, and Faceography capabilities beyond the sampled code. The React app appears to be a separate marketing landing page. Relationships for unsampled routes and UI modules are based on README documentation, not inspected source.
Main entry points: app.py Flask SocketIO hub · camera_utils.py Frame emotion analysis · client.js Camera client · chat.js Chat client
Components 19
Web experience
- Companion UI
templates - Camera client
static/js/client.js - Chat client
static/js/chat.js - Diary client
static/js/diary.js - Marketing landing
frontend/src/App.tsx
Application hub
- Flask SocketIO hub
app.py - Mood dashboard
app.py - Diary API
app.py
Emotion sensing
- Frame emotion analysis
camera_utils.py - Vision models
camera_utils.py - Face cascade
haarcascade_frontalface_default.xml
Companion services
- Groq LLM
- OpenRouter fallback
- Speech synthesis
app.py
Reflection and records
- Diary SQLite
app.py - Emotion CSV
camera_utils.py - Chat history JSON
app.py - Faceography captures
camera_utils.py
Other components
- User
Connections 21
- User → Companion UI: uses
README.md - User → Camera client: shares frames
README.md - User → Chat client: sends messages
README.md - User → Diary client: journals
README.md - Camera client → Flask SocketIO hub: streams frames
static/js/client.js - Chat client → Flask SocketIO hub: sends chat
README.md - Diary client → Diary API: calls diary API
static/js/diary.js - Flask SocketIO hub → Frame emotion analysis: analyzes frames
app.py - Frame emotion analysis → Vision models: classifies faces
camera_utils.py - Frame emotion analysis → Face cascade: detects faces
camera_utils.py - Frame emotion analysis → Emotion CSV: logs moods
camera_utils.py - Frame emotion analysis → Faceography captures: buffers captures
camera_utils.py - Flask SocketIO hub → Groq LLM: requests response
README.md - Flask SocketIO hub → OpenRouter fallback: falls back
app.py - Flask SocketIO hub → Speech synthesis: generates audio
README.md - Flask SocketIO hub → Chat history JSON: persists turns
README.md - Flask SocketIO hub → Diary SQLite: stores entries
README.md - Flask SocketIO hub → Mood dashboard: serves mood views
README.md - Mood dashboard → Emotion CSV: reads trends
app.py - Mood dashboard → Diary SQLite: reads reflections
app.py - Marketing landing → User: presents entry
frontend/src/App.tsx