Design problems
AI-era systemsHardSDE-3 40 min

Design an AI mock interviewer

The interviewer asks

“Design an AI mock interviewer: a candidate picks a role and level (say, SDE-2 backend), talks to an AI interviewer by voice or text for 30-45 minutes, gets adaptive follow-up questions, and receives a scored report afterwards. Plan for 50,000 interviews a day during campus placement season.”

What a strong answer looks like

A strong answer separates the real-time conversation from the evaluation. The live part is a low-latency voice loop: audio over WebRTC, streaming speech-to-text with end-of-turn detection, an LLM that streams its reply, streaming text-to-speech, with barge-in, targeting about one second from the candidate stopping to the interviewer speaking. The interview itself is driven by a server-side plan and state machine (sections, time budget, rubric topics, question bank), with the LLM generating the wording and follow-ups inside that structure, so interviews are consistent and stay on time. The report is produced asynchronously by a stronger model reading the full transcript and code against a rubric, citing evidence with timestamps, and calibrated against human graders. Senior candidates cover latency budgets per stage, accents and Indian English, fairness and score consistency, cost per interview, plan limits, privacy of recordings, and graceful degradation from voice to text.

Concepts to mention

WebRTC audio with a media server near usersstreaming STT, LLM and TTS with sentence-level pipeliningend-of-turn detection and barge-invoice-to-voice latency budgetserver-side interview state machine with time budgetsquestion bank with expected points and follow-up treespost-interview rubric grading with evidence and timestampsgrading consistency and calibration against humansfairness across accentssticky stateful sessions and graceful drainplan limits checked before startdegrade voice to text

1 Requirements

Functional

  • Candidate chooses interview type (DSA coding, system design, behavioural), role, level and duration
  • Voice conversation with the AI interviewer, with a text-chat fallback; code editor or whiteboard shared in coding and design rounds
  • Adaptive questioning: follow-ups based on the candidate's answers, hints when stuck, moving on when time is up
  • Interviewer can see the candidate's code and diagram as they change
  • Scored report within 5 minutes: rubric scores, strengths, gaps, evidence quotes with timestamps, recommended practice
  • Interview history and progress over time; replay of transcript
  • Plan limits on mock interviews per month, checked before an interview starts

Non-functional

  • Voice-to-voice response latency under 1.2 s p50 and 2 s p95 (candidate stops speaking → interviewer audio starts)
  • 50,000 interviews/day at peak season, ~7,000 concurrent sessions
  • An interview must survive a network drop or server restart and resume within 10 s
  • Score consistency: the same transcript graded twice differs by at most 0.5 on a 5-point scale
  • Recordings and transcripts private to the candidate; deletable on request
  • Cost per 45-minute interview under ₹40

Out of scope (say it out loud)

  • Proctoring and cheating detection for real hiring decisions
  • Video avatar of the interviewer
  • Running and judging code against hidden test cases (assume an existing code runner)

2 Estimates

Concurrent sessions~2,500 avg in active hours, ~7,000 peak50,000/day × 40 min = 2M session-minutes; over ~14 active hours (840 min) ≈ 2,400 concurrent; evening peaks ~3×
Turns~25 turns per interview, ~15/s avg, ~60/s peak40-minute interview, a turn every ~1.5 min of conversation → ~25-30 turns; 50,000 × 25 = 1.25M turns/day ÷ 86,400 ≈ 15/s average, ~60/s at peak hours
Audio bandwidth~200 Mbps in + out at peakOpus voice at ~16-32 kbps each way × 7,000 sessions ≈ 7,000 × 32 kbps ≈ 224 Mbps
STT minutes~1M minutes/dayOnly the candidate's speech is transcribed: ~50% of 40 min ≈ 20 min × 50,000
Cost per interview~₹25-35Very rough: STT 20 min × ~₹0.5/min ≈ ₹10; TTS ~15 min of speech ≈ ₹5-10; LLM 25 turns × ~6k input tokens (cached prefix) on a fast model ≈ ₹5; final report with a strong model on a 15k-token transcript ≈ ₹3-5
Storage~1 TB/day of audioRecording both sides at 32 kbps: 40 min × 60 × 4 KB/s ≈ 10 MB per interview × 50,000 = 500 GB-1 TB/day; keep 30 days unless the candidate saves it
Latency budget~1.1 s voice-to-voiceEnd-of-turn detection ~300-500 ms of silence + final STT ~100 ms + LLM time to first sentence ~400 ms + TTS first audio ~150 ms + network ~100 ms

3 API

EndpointWhat it does
POST/v1/interviewsCreate an interview (type, role, level, duration). Checks the plan's monthly mock-interview limit; returns interview_id and a session token.
WebRTC/v1/interviews/{id}/mediaBidirectional audio between the browser/app and the media server; signalling over HTTPS.
WS/v1/interviews/{id}/eventsControl and data channel: transcript updates, code editor diffs, timer, section changes, text-mode messages.
POST/v1/interviews/{id}/endEnd early or on time; triggers report generation.
GET/v1/interviews/{id}/reportScored report with rubric, evidence and recommendations; status while generating.
DELETE/v1/interviews/{id}Delete recording, transcript and report.

4 Data model

interviewsPostgres
interview_id (PK)user_idtyperolelevelplan_idstatus (scheduled|live|ended|graded)started_atended_atrubric_versionprompt_version

Versions recorded so reports are reproducible and comparable over time.

interview_plan_stateRedis (live) + Postgres snapshot every turn
interview_idcurrent_sectionquestion_idtopics_covered[]time_used_per_sectionhints_givennotes_for_grader

The state machine that keeps the interview on track; snapshot lets any server resume after a crash.

transcript_eventsDynamoDB / Cassandra
interview_id (partition)ts_ms (sort)speakertexttype (speech|code_diff|hint|section_change)

Append-only timeline used by the live LLM context, the report and the replay view.

question_bankPostgres
question_idtypeleveltopics[]promptexpected_points[]follow_up_treerubric_hints

Curated questions with what a good answer covers; the LLM adapts wording and follow-ups but not the core content.

reportsPostgres (jsonb)
interview_idscores per rubric dimensionoverallevidence[] (quote, timestamp, dimension)recommendations[]grader_modelconsistency_check

Evidence links let the candidate jump to the moment in the replay.

recordingsS3 (encrypted, lifecycle 30 days)
s3://recordings/{user}/{interview}/{track}.opus

Stored in an India region; deleted on request or after retention.

5 Architecture

CLIENTSEDGESERVICESASYNCDATAEXTERNALaudio (Opus)code diffs, controlaudio framesstream audiofinal user turncode, text turnsplan statenext utterancesentencesaudio outtranscriptrecordinginterview endedrubric gradingreportCandidate (web / app)API + WS gatewayMedia server (WebRTC)Interview conductorStreaming STTVoice pipeline (VAD,turn)Streaming TTSQueue: end ofinterviewReport grader workersRedis: live stateTranscript storePostgres: plans,reportsS3: recordingsLLM gateway
ClientEdge / gatewayService / workerQueue / streamCacheDatabase / storageAI / modelThird partyrequestasync (event / queue)

Hover a box to highlight its connections.

6 Request flows

One spoken turn

  1. 1The candidate explains their approach to a design question. Audio flows over WebRTC to the media server, which forwards frames to the voice pipeline pinned to this session.
  2. 2The pipeline streams audio to STT and receives partial transcripts every ~200 ms, which are also shown on screen.
  3. 3Voice activity detection plus a small end-of-turn model decide the candidate has finished (silence ~500 ms and the sentence sounds complete); a thinking pause mid-sentence does not end the turn.
  4. 4The conductor receives the final text, appends it to the transcript and updates plan state: current section 'high-level design', 18 of 45 minutes used, topics covered so far.
  5. 5It builds the prompt: fixed interviewer persona and rules first (cached prefix), the question's expected points and follow-up tree, a summary of earlier sections, the recent turns, the current code or diagram, and an instruction such as 'ask one follow-up about data partitioning; keep it under 2 sentences'.
  6. 6The LLM streams text; the conductor cuts it into sentences and sends the first sentence to TTS as soon as it is complete.
  7. 7TTS streams audio back through the media server; the candidate hears the first words about 1.1 s after they stopped speaking.
  8. 8If the candidate starts talking while the AI speaks (barge-in), the pipeline stops TTS playback within ~200 ms, discards the unspoken text and treats the new speech as the next turn.

Generate the report

  1. 1Time runs out; the conductor closes the last section, says goodbye, and publishes interview.ended with versions of prompt and rubric.
  2. 2A grader worker loads the full transcript, final code and plan-state notes (what was asked, hints given).
  3. 3For each rubric dimension (problem understanding, design trade-offs, communication, coding correctness), a strong model scores 1-5 with required evidence quotes and timestamps, at temperature 0.
  4. 4A consistency check grades the dimensions twice or with a second model; large disagreements are re-graded or flagged as low-confidence in the report.
  5. 5Code correctness uses the code runner's test results as facts rather than the model's opinion.
  6. 6The report is stored and the candidate is notified; typically 1-3 minutes after the interview.

7 Deep dives

The voice loop and its latency budget

People expect a reply within about a second in conversation; at two seconds the AI feels slow, and if it interrupts the candidate it feels rude. Every stage must stream. Audio travels over WebRTC (UDP, jitter buffers, echo cancellation in the browser) to a media server in an Indian region, because a round trip to a US region alone adds ~250 ms. Streaming STT returns partials continuously, so final text is ready ~100 ms after speech ends. The hardest part is end-of-turn detection: fixed silence thresholds either cut candidates off mid-thought or add a long pause. Combine voice activity detection with a small model that judges whether the utterance is complete, use a longer threshold during problem solving ('hmm, so...') and allow the candidate to press a 'done' key in coding rounds. The LLM must start fast: use a fast model for live turns, keep the prompt prefix cacheable, ask for short answers, and send text to TTS sentence by sentence. Support barge-in: stop playback immediately when the candidate speaks and tell the conductor what was actually spoken, so the transcript matches what the candidate heard. Measure the full voice-to-voice latency per turn, not per component.

A state machine drives the interview, the LLM speaks

If you give an LLM 'you are an interviewer, run a 45-minute system design interview' it will drift: spend 30 minutes on requirements, forget to ask about scaling, give away answers, or end early. So the server owns the structure. The interview plan comes from the question bank and the level: sections with time budgets (requirements 5 min, high-level design 15, deep dive 15, wrap-up 5), the topics each section must cover, and a follow-up tree of probes. The conductor tracks time used, topics covered and hints given in a state object, and each turn tells the LLM what to do next ('candidate has not mentioned caching; ask about read latency'; 'time for this section is up; transition to deep dive'). A cheap classifier call can update 'topics covered' from each answer. The LLM's job is wording, natural follow-ups and judging whether an answer needs a probe. This gives consistency between candidates, keeps interviews on time, and produces grader notes (which hints were given) that make scores fairer. State is snapshotted after every turn, so if a server dies another instance reloads it and continues, telling the candidate 'sorry, I lost you for a moment'.

Grading that candidates can trust

The report is the product's credibility. Grade after the interview, not live, with a stronger model that sees the whole transcript, final code and plan notes. Use an explicit rubric per interview type and level, with descriptions of what a 2, 3 and 4 look like for each dimension, and require evidence: every score must cite quotes with timestamps, which the UI links to the replay. This makes scores explainable and reduces made-up praise. Run at temperature 0, and check consistency: grade twice (or with two models) and if dimension scores differ by more than one point, re-grade or show lower confidence. Use facts where possible: code test results from the runner, time taken, hints used. Calibrate against humans: a panel of experienced interviewers grades a few hundred interviews; track agreement (for example the correlation or the share within one point) and tune rubric wording until the model agrees with humans about as well as humans agree with each other. Check fairness: compare score distributions across accents and languages for transcripts of similar quality, because STT errors on Indian English accents can make an answer look worse than it was. Version the rubric and prompt, and never compare scores across versions without saying so.

Scaling sessions, cost and graceful degradation

A voice session is stateful and long, unlike a web request. Media servers and voice pipeline workers are assigned per session (sticky), scaled on concurrent sessions rather than CPU, and drained gracefully on deploy: a server stops taking new sessions and waits for live ones to finish (up to an hour), so deploys need long drain windows or connection migration. Placement season gives sharp evening peaks; scale ahead by schedule, and offer booking slots when capacity is short instead of failing mid-interview. Plan limits are checked when an interview is created, and the counter is consumed only when the interview actually starts, so a failed connection does not cost the user a credit. Cost per interview is dominated by STT and TTS minutes, not the LLM: transcribe only the candidate's audio, pause STT when muted, and use a cheaper TTS voice for free tiers. Degrade in steps: if TTS fails, show the interviewer's text; if STT fails or the network is weak (common on Tier-2/3 mobile data), switch to text mode with the same conductor and state; if the LLM provider fails, the gateway fails over to a second fast model. The interview continues in every case.

8 Trade-offs

Cascaded STT → LLM → TTS vs speech-to-speech models

Real-time speech-to-speech models give lower latency and more natural turn-taking. The cascaded pipeline gives a text transcript at every step, control over each component (choose STT that handles Indian accents, any LLM, any voice), easier grading and logging, and cheaper fallbacks to text. For an assessment product where the transcript is the evidence, the cascade is the safer default; a speech-to-speech model can be tried later for the live part only.

Live grading vs post-interview grading

Grading during the interview could adapt difficulty and give instant results but adds latency and cost to every turn and grades without full context. Lightweight live signals (topics covered) plus full grading afterwards gives better scores at lower live latency.

WebRTC vs WebSocket audio

WebSocket audio is simpler to build but runs over TCP, so packet loss on mobile networks causes stalls. WebRTC handles loss, jitter and echo cancellation and is the standard for voice. Use WebRTC for audio and a WebSocket for control and code sync.

9 Bottlenecks

STT/TTS provider concurrency limits

Providers limit concurrent streams. At 7,000 sessions you may need several accounts or providers, routed by a voice gateway with failover, or a self-hosted STT model on GPUs for the bulk of traffic.

Long transcripts in every prompt

Late in an interview the full transcript is long, making each turn slower and costlier. Keep recent turns verbatim, replace earlier sections with summaries generated at section ends, and rely on prompt caching for the stable prefix.

10 Failure handling

Voice worker crashes mid-interview

The client's WebRTC connection drops; it reconnects through signalling to a new worker, which loads plan state and transcript from Redis/Postgres. The interviewer says it lost the connection briefly and repeats the last question. Time lost is credited back.

Candidate's network is poor

Packet loss and high jitter are detected from WebRTC stats; the app suggests switching to text mode, keeping the same session and state.

Grader produces an inconsistent report

The consistency check catches large disagreements and re-grades; if still inconsistent, the report shows 'low confidence' for that dimension and the case goes into a human review sample used for calibration.

11 What impresses

  • Breaks down the ~1 s voice latency budget stage by stage
  • Explains why end-of-turn detection is harder than STT accuracy
  • Keeps the interview structure in code and uses the LLM for language
  • Requires evidence quotes for every score and calibrates against human graders
  • Notes STT and TTS minutes dominate cost, not LLM tokens
  • Considers Indian English accents and Tier-2/3 networks

12 Mistakes

  • Waiting for the full LLM answer before starting TTS
  • Letting the LLM run the whole interview from one prompt with no structure
  • Grading live turn by turn with no full-transcript pass
  • Scores with no evidence, so candidates cannot trust or learn from them
  • Treating voice sessions like stateless HTTP requests for scaling and deploys
  • No fallback when voice fails

13 Follow-ups

Q1How would you add a system design whiteboard the AI can read?
Q2How do you stop the AI interviewer from giving away the answer?
Q3How would you support Hindi or Tamil interviews?
Q4How do you know your scores predict real interview outcomes?
Q5How would you make the AI interviewer more or less strict by company style?
Q6What changes if companies use this to screen real candidates?

Saved on this device. Create a free account to keep it on every device.

Practise this with Sam

A real mock interview, out loud, with an honest scorecard. Free to start.

Start free