How rahulsamant37/ai-voice-coach works
Project Type and Purpose
• This is a full-stack, real-time web application (“AI Voice Coach”) built on Next.js with server-rendered React, a Convex-powered backend for real-time data and authentication, plus external AI/voice services (AssemblyAI for speech-to-text, OpenRouter/OpenAI for feedback generation, and AWS Polly for text-to-speech).
File Structure Analysis
• app/: Next.js App Router directory
• app/(main)/… contains page-level JSX components for dashboard, discussion rooms, and summary views.
• app/api/getToken/route.jsx: an internal API route to issue Convex/AWS tokens.
• app/handler/[...stack]/page.js: catch-all route, likely for dynamic client-side routing or fallback.
• Context, AuthProvider.jsx, _context/UserContext.jsx: user/session management.
• components/: shared UI components (shadcn/ui, magicui) and dialogs.
• convex/: Convex schema (schema.js, users.js) and generated client/server code for functions and data models.
• services/ & lib/utils.js: wrappers around external APIs and app-wide helper functions.
• stack.js: orchestration of real-time pipeline or middleware.
• Configuration: next.config.mjs, postcss.config.mjs, jsconfig.json.
Key README Insights
• Frontend uses Next.js + Tailwind + Radix UI/shadcn for a responsive UI.
• Backend: Convex for real-time data, AssemblyAI for transcription, AWS Polly for voice synthesis, OpenRouter/OpenAI for feedback, RecordRTC for capturing audio.
• Deployment paths: Vercel, Docker, traditional hosting, plus Convex function deployment.
Main Components
a. Client Browser (React/Next.js UI)
b. Next.js Server (SSR, API routes, page rendering)
c. Convex Backend (database, real-time functions, auth)
d. External AI/Voice Services
• AssemblyAI (speech-to-text)
• OpenRouter/OpenAI (feedback generation)
• AWS Polly (text-to-speech)
e. Supporting Services
• RecordRTC (in-browser audio capture)
• Token issuance (app/api/getToken)
Relationships & Data Flows
1. User speaks → RecordRTC captures audio
2. Audio blob → Next.js API or directly to AssemblyAI (via services/GlobalServices)
3. AssemblyAI → real-time transcript streamed back to Next.js UI
4. Transcript → Convex function (stores message, triggers real-time update)
5. Transcript → OpenRouter/OpenAI via a Convex or Next.js serverless call → AI feedback text
6. Feedback text → AWS Polly via Next.js API → audio response
7. Both transcript and feedback persisted in Convex DB and pushed to all connected clients (discussion room)
Architectural Patterns & Principles
• Container/Component separation: UI, API, real-time backend, external services
• Event-driven flows: on new transcript/message, trigger AI feedback and DB update
• Serverless/API routes for token management and third-party integration
• Real-time synchronization via Convex subscriptions
Essential Elements
• Clear component labels (e.g., “DiscussionRoom.page.jsx”, “Convex Function: onNewTranscript”)
• Notes on security (JWT in headers), caching (if used), and deployment targets (Vercel, Docker).