AI Interviewer is a Next.js (App Router) + TypeScript application that simulates a technical interview end-to-end. You browse LeetCode-style problems, launch an interview session with Monaco code editor + sandboxed runner, and collaborate with an AI interviewer that adapts to your behavior.
- Adaptive interview flows - Session state machine tracks phases (intro/clarify/approach/coding/testing/optimize/wrapup), rubrics, and checkpoints.
- AI interviewer widget - Floating chat widget with streaming OpenAI responses, Markdown rendering, and configurable tone/hint levels.
- Sandbox runner -
/api/run(sample tests) &/api/submit(full tests) execute user code in temporary files (Node/Python) and return structured results. - Code + Chat UX - Monaco editor, console output, autosave snapshots, three-column layout with quick navigation back to problems.
- Mock problem provider - Bundled problems (Two Sum, Valid Parentheses, Merge Two Lists, Binary Tree Level Order, Longest Substring) served via
/lib/providers. - Unit tests - Coverage for provider, rubric heuristics, and state-machine transitions via Vitest/JSDOM.
- Node.js 18+ (matching Next.js 14 requirements).
- npm 9+ (or compatible package manager).
- Optional: OpenAI API key if you want cloud-based interviewer replies (otherwise, built-in fallback logic will handle responses).
- Install dependencies
npm install
- Configure environment
Create
.env.localwith:Without a key, the interviewer will fall back to scripted prompts.OPENAI_API_KEY=sk-... # Optional (defaults to gpt-4o-mini if omitted) OPENAI_MODEL=gpt-4o-mini
- Run dev server
Visit
npm run dev
http://localhost:3000. - Production build
npm run build npm start
- Tests
npm test
app/– Next.js routes (home, problems, interview, APIs).components/– UI building blocks (ProblemPanel, CodeWorkspace, Interviewer widget, chat list, etc.).lib/providers/– Mock problem provider abstraction.lib/interview/– Session machine, rubric heuristics, interviewer prompt, client hooks.lib/runner/– Problem harness builders, sandbox executor, schemas.__tests__/– Vitest tests.public/– Static assets (currently empty).
| Problem detail | Interview chat | Chat controls |
|---|---|---|
![]() |
![]() |
![]() |
- Client hook
useInterviewSessionmanages session state, autosaves, and triggers interviewer responses when the user sends chat messages. /api/interviewerposts full context to OpenAI using streaming responses (SSE). On failure, it falls back to deterministic heuristics.- Chat widget displays streaming Markdown responses and includes controls for hint levels, tone, and question-only toggles.
- Each problem defines JavaScript & Python harnesses in
lib/runner/problemTestPlans.ts. lib/runner/sandboxRunner.tswrites user code + harness to a temp file and executes Node.js or Python with timeouts.- API routes
/api/run&/api/submitvalidate payloads with Zod and returnRunResultobjects (pass/fail counts, stderr, per-test details).
- Sandbox runner is for local/dev use; replace with a hardened sandbox (Docker, Firecracker, etc.) before production.
- AI interviewer respects hint controls and never dumps final solutions unless the user escalates the hint level.
- LocalStorage autosaves interview progress, so you can resume where you left off.
npm run dev– Start Next.js dev server.npm run build– Production build.npm run start– Serve production build.npm run lint– ESLint (Next config).npm test– Vitest unit tests.


