How shubham-pande-ai/focusai works
FocusAI captures webcam-derived facial features in the browser, streams telemetry to a FastAPI backend for attention and emotion analysis, and persists results for live dashboards and an agentic analytics assistant. The README documents the browser-to-backend flow and major capabilities; sampled backend code confirms stream processing, storage, authentication, session management, and agent tooling. Frontend network wiring and several API implementations were not sampled, so those links are documented rather than asserted from source.
Main entry points: main.py FastAPI app · stream.py Telemetry WebSocket · page.tsx FocusAI portal · WebcamTracker.tsx Webcam tracker
Components 26
Browser experience
- FocusAI portal
frontend/src/app/page.tsx - User dashboard
frontend/src/app/user/page.tsx - Admin dashboard
frontend/src/app/admin/page.tsx - Webcam tracker
frontend/src/components/WebcamTracker.tsx - Face landmark model
frontend/public/models/face_landmarker.task - Vision WASM
frontend/public/wasm/vision_wasm_internal.js
Backend services
- FastAPI app
backend/main.py - Authentication API
backend/api/auth.py - User management API
backend/api/users.py - Session API
backend/api/sessions.py - Workspace taxonomy API
backend/api/taxonomy.py - Telemetry and chat API
backend/api/routes.py - Analytics API
backend/api/analytics.py
Telemetry analysis
- Telemetry WebSocket
backend/websocket/stream.py - Geometry helpers
backend/utils/math.py - Expression analysis
backend/services/emotion/analyzer.py - Attention scoring
backend/services/attention/scorer.py
Data and AI
- Accounts and sessions
backend/models/relational.py - Telemetry models
backend/models/timescale.py - Database connection
backend/database/connection.py - ReAct analysis agent
backend/services/agents/master_agent.py - TimescaleDB
- PostgreSQL
Other components
- Participant
- Admin or host
- Groq LLM
Connections 35
- Participant → FocusAI portal: opens
README.md - Admin or host → FocusAI portal: opens
README.md - FocusAI portal → Authentication API: authenticates
README.md - FocusAI portal → User dashboard: routes to
- FocusAI portal → Admin dashboard: routes to
- Participant → Webcam tracker: provides video
README.md - Webcam tracker → Face landmark model: loads
README.md - Webcam tracker → Vision WASM: processes locally
README.md - Webcam tracker → Telemetry WebSocket: sends feature vectors
README.md - User dashboard → FastAPI app: polls metrics
README.md - Admin dashboard → FastAPI app: requests insights
README.md - FastAPI app → Authentication API: registers router
backend/main.py - FastAPI app → User management API: registers router
backend/main.py - FastAPI app → Session API: registers router
backend/main.py - FastAPI app → Workspace taxonomy API: registers router
backend/main.py - FastAPI app → Telemetry and chat API: registers router
backend/main.py - FastAPI app → Analytics API: registers router
backend/main.py - FastAPI app → Telemetry WebSocket: registers router
backend/main.py - Authentication API → Accounts and sessions: queries
backend/api/auth.py - Session API → Accounts and sessions: manages sessions
backend/api/sessions.py - Authentication API → PostgreSQL: validates credentials
README.md - Telemetry WebSocket → Geometry helpers: uses
backend/websocket/stream.py - Telemetry WebSocket → Expression analysis: detects expressions
backend/websocket/stream.py - Telemetry WebSocket → Attention scoring: scores focus
backend/websocket/stream.py - Expression analysis → Geometry helpers: uses
backend/services/emotion/analyzer.py - Telemetry WebSocket → Telemetry models: writes telemetry
backend/websocket/stream.py - Telemetry WebSocket → Database connection: opens sessions
backend/websocket/stream.py - Telemetry models → TimescaleDB: stores time series
README.md - Accounts and sessions → PostgreSQL: stores accounts
README.md - Telemetry and chat API → ReAct analysis agent: gets agent
backend/api/routes.py - ReAct analysis agent → Database connection: queries telemetry
backend/services/agents/master_agent.py - ReAct analysis agent → Groq LLM: uses model
backend/services/agents/master_agent.py - Analytics API → Database connection: queries data
backend/api/analytics.py - Telemetry and chat API → TimescaleDB: reads metrics
README.md - Admin dashboard → Telemetry and chat API: chats with agent
README.md