GuardCall is designed to provide real-time scam protection during phone calls. This document explains the exact technical flow from the moment a user starts a call to the final generated police report.
GuardCall uses a client-server architecture with continuous real-time communication via WebSockets.
- Client (Frontend): Built with React, Vite, and Zustand. It handles user interactions, records audio from the microphone, and displays real-time warnings (Coaching Cards).
- Server (Backend): Built with Node.js and Express. It acts as the orchestrator, bridging the Client with external AI services (Deepgram and Groq) and the database (MongoDB).
- The user inputs the caller's number and starts the session.
- The Client requests microphone access and begins capturing audio.
- The Client emits a
session:startevent via Socket.IO to the Server. - The Server initializes a new session state, resetting risk scores and transcripts, and establishes a secure connection with Deepgram (Speech-to-Text).
- The Client fetches a temporary, short-lived Deepgram access token from the Server (
/api/deepgram/token). - As the user and the caller speak, the Client captures the audio in small chunks and streams them directly to Deepgram's edge servers via a native WebSocket connection.
- This zero-hop architecture bypasses the Node.js backend for raw audio entirely, drastically slashing latency and server bandwidth.
- Deepgram processes the audio instantly and streams text directly back to the Client.
- The Client maintains a
rollingTranscript(keeping a window of the last 400 words to maintain context without overloading the AI) and updates the UI instantly. - The Client emits a
transcript:updateevent to the Server, passing the latest text for AI analysis.
- Instead of relying on an arbitrary 10-second timer, the Server uses a completely event-driven architecture.
- The moment the Server receives a
transcript:updatefrom the Client, it immediately sends the text to the Groq API (powered by the Llama 3 model). - To prevent spamming the Groq API when a user speaks rapidly, the server uses a 2.5-second debounce lock.
- Groq analyzes the text for manipulation tactics (fake urgency, asking for money, threats) and returns:
- Risk Score: A number from 0 to 100.
- Signal: The threat level (e.g., Safe, Suspicious, Dangerous).
- Coaching: Exact phrases the user should say to counter the scammer.
- The Server sends this data back to the Client via a
risk:updateevent. - If the risk score is high, the Client uses Framer Motion to instantly slide the Coaching Card onto the screen.
- When the user hangs up, the Client emits a
session:endevent. - The Server halts the risk analysis interval and closes the Deepgram connection.
- If the Peak Risk Score throughout the call was less than 40:
- The call is deemed safe. The transcript is discarded, and the session is logged without details.
- If the Peak Risk Score was 40 or higher:
- The Server sends the full transcript to Groq for PII Scrubbing (Personally Identifiable Information). Names, account numbers, and sensitive details are replaced with placeholders (e.g.,
[AADHAAR]). - The scrubbed transcript is then passed to Groq again to Generate a Formal Report (FIR format).
- The report is saved to MongoDB.
- The Server emits a
report:readyevent, and the Client displays the formal report to the user, who can then export it as a PDF.
- The Server sends the full transcript to Groq for PII Scrubbing (Personally Identifiable Information). Names, account numbers, and sensitive details are replaced with placeholders (e.g.,
- No Raw Audio Storage: Audio bytes are only streamed and never written to a disk on the server.
- Data Minimization: The
rollingTranscriptis only kept in memory during the call. - AI-Powered Redaction: PII scrubbing ensures that even if the transcript is saved for a police report, the user's sensitive data is fully protected.