How devaprasath4/caretta works
Purpose and Entry Points
Caretta is a real-time sales-call intelligence system: it captures conversation audio/transcripts, detects technical questions or objections, generates AI coaching and answers, and preserves call history. The Node backend starts through server/src/server.js and configures the Express application in server/src/app.js. Static browser-facing entry pages include client/index.html, client/login.html, and client/pages/dashboard.html.
Browser Client
The frontend is plain HTML/CSS/JavaScript rather than a framework application. Dashboard and call-facing behavior is organized in client/js/dashboard.js, client/js/ai-coach.js, and client/js/transcript.js; session authentication is handled by client/js/login.js. client/js/socket.js is the client boundary for real-time server communication, allowing generated guidance and transcript events to reach an active sales screen.
HTTP, Authentication, and Session Boundary
Express exposes separate route domains for identity, calls, transcripts, AI, and knowledge-base operations: server/src/routes/authRoutes.js, server/src/routes/callRoutes.js, and server/src/routes/aiRoutes.js. Authentication controller logic resides in server/src/controllers/authController.js; protected requests pass through server/src/middleware/authMiddleware.js. JWT configuration is implied by the required JWT_SECRET, separating user/session access from call and AI workflows.
Real-Time Call and Transcript Flow
A call session is created and managed through server/src/controllers/callController.js and persisted as server/src/models/CallSession.js. Speech transcription enters through server/src/services/whisperService.js, with transcript request handling in server/src/controllers/transcriptController.js and durable transcript records in server/src/models/Transcript.js. Socket infrastructure in server/src/config/socket.js distributes live call/transcript and coaching updates to connected clients.
AI Coaching Pipeline
Transcript/question content is passed to the LLM boundary in server/src/services/llmService.js, intended for Google Gemini. server/src/services/coachingService.js turns model output into sales-oriented responses, objection guidance, and follow-up recommendations. Suggestions are represented by server/src/models/Suggestion.js; this provides a persistence boundary between ephemeral real-time advice and historical call insights. Voice output can be delegated to ElevenLabs through server/src/services/ttsService.js.
Retrieval-Augmented Knowledge Layer
The repository supports grounding AI responses in product knowledge. Knowledge content is modeled as chunks in server/src/models/KnowledgeChunk.js, with source data at server/src/data/knowledgeBase.js. Retrieval and response augmentation are implemented in server/src/services/ragService.js, while knowledge/AI-facing endpoints are defined in server/src/routes/kbRoutes.js, server/src/routes/ragService.js, and server/src/routes/aiRoutes.js. This is the boundary between internal sales/product knowledge and external LLM generation.
Data, Infrastructure, and External Services
MongoDB is the system of record, initialized via server/src/config/db.js, for users, calls, transcripts, knowledge chunks, and suggestions; user records are defined in server/src/models/User.js. Required runtime services are Node.js, MongoDB, Google Gemini, speech-to-text integration, ElevenLabs, and Socket.IO-style real-time transport. Environment-dependent credentials and connection settings are documented by server/.env.example; centralized error handling is at server/src/middleware/errorMiddleware.js.
Components 22
Browser Client
- Browser pages
client/pages/dashboard.html - Dashboard & call UI
client/js/dashboard.js - Session login
client/js/login.js - Realtime client
client/js/socket.js
Node API & Realtime
- Express application
server/src/app.js - Auth & JWT guard
server/src/controllers/authController.js - Call sessions
server/src/controllers/callController.js - Transcript intake
server/src/controllers/transcriptController.js - Realtime socket hub
server/src/config/socket.js
Speech & AI Pipeline
- Speech transcription
server/src/services/whisperService.js - Sales coaching
server/src/services/coachingService.js - Knowledge retrieval
server/src/services/ragService.js - Gemini generation
server/src/services/llmService.js - Voice output
server/src/services/ttsService.js
Data & External Services
- MongoDB · Stores users, calls, transcripts, knowledge chunks, and suggestions.
server/src/config/db.js - Users
server/src/models/User.js - Call records
server/src/models/CallSession.js - Transcript records
server/src/models/Transcript.js - Coaching history
server/src/models/Suggestion.js - Knowledge chunks
server/src/models/KnowledgeChunk.js - Knowledge source
server/src/data/knowledgeBase.js - AI providers
Connections 31
- Browser pages → Dashboard & call UI: loads
- Browser pages → Session login: loads
- Dashboard & call UI → Realtime client: subscribes
- Session login → Express application: auth requests
- Dashboard & call UI → Express application: call and AI requests
- Realtime client → Realtime socket hub: live events
- Express application → Auth & JWT guard: identity routes
- Express application → Call sessions: call routes
- Express application → Transcript intake: transcript requests
- Express application → Sales coaching: AI routes
- Express application → Knowledge retrieval: knowledge routes
- Auth & JWT guard → Users: user access
- Call sessions → Call records: persists
- Transcript intake → Speech transcription: submits audio
- Speech transcription → Transcript records: stores transcript
- Transcript intake → Realtime socket hub: publishes transcript
- Transcript records → Sales coaching: conversation context
- Sales coaching → Knowledge retrieval: grounds answers
- Knowledge retrieval → Knowledge chunks: retrieves chunks
- Knowledge source → Knowledge chunks: supplies content
- Sales coaching → Gemini generation: generates guidance
- Gemini generation → AI providers: Gemini
- Sales coaching → Coaching history: persists advice
- Sales coaching → Realtime socket hub: pushes coaching
- Sales coaching → Voice output: optional speech
- Voice output → AI providers: ElevenLabs
- Users → MongoDB: stored in
- Call records → MongoDB: stored in
- Transcript records → MongoDB: stored in
- Coaching history → MongoDB: stored in
- Knowledge chunks → MongoDB: stored in