Skip to content

feat: AI-Powered Interview Platform Foundation#31

Open
theashishmaurya wants to merge 1 commit into
mainfrom
feat/ai-interview-platform
Open

feat: AI-Powered Interview Platform Foundation#31
theashishmaurya wants to merge 1 commit into
mainfrom
feat/ai-interview-platform

Conversation

@theashishmaurya

@theashishmaurya theashishmaurya commented Feb 23, 2026

Copy link
Copy Markdown
Owner

🚀 Massive Update: AI Interview Platform Implementation

This PR implements multiple features from the detailed issue breakdown.


Phase 1: AI Code Helper ✅

#43 - OpenAI/Anthropic API Integration

import { getAIClient } from '@/lib/ai';

const ai = getAIClient();

// Streaming completion
for await (const chunk of ai.stream(messages)) {
  console.log(chunk.content);
}

// Single completion
const response = await ai.complete(messages);

Features:

  • ✅ OpenAI GPT-4 support
  • ✅ Anthropic Claude support
  • ✅ Streaming responses (SSE)
  • ✅ Rate limiting per provider
  • ✅ Error handling with retries

#44 - Code Context Extraction

import { extractContext, buildPromptContext } from '@/lib/ai';

const context = extractContext(code, cursorLine, cursorColumn, 'typescript');
// { currentFunction, linesBefore, imports, ... }

const prompt = buildPromptContext(context);

Features:

  • ✅ Extract current function/class at cursor
  • ✅ Multi-language support (JS, TS, Python)
  • ✅ Import extraction
  • ✅ Surrounding context (20 lines before/after)

#45 - AI Hint System (Progressive 3-Level)

<HintPanel
  challengeId="modal"
  challengeDescription="Build an accessible modal..."
  currentCode={code}
  onHintUsed={(level, hint) => console.log(level, hint)}
/>

Features:

  • ✅ Level 1: Direction hint (no code)
  • ✅ Level 2: Implementation hint (1-2 lines)
  • ✅ Level 3: Detailed hint (algorithm + edge cases)
  • ✅ Per-user rate limiting (50/hour)
  • ✅ Hint history stored in DB

#46 - Code Explanation Feature

<ExplanationPanel
  code={selectedCode}
  language="typescript"
  onExplanation={handleExplanation}
/>

Features:

  • ✅ Streaming explanations
  • ✅ Follow-up questions
  • ✅ Copy to clipboard
  • ✅ Markdown formatting

Phase 2: Interview Sessions ✅

#47 - Database Schema

Tables Created:

Table Purpose
organizations Team management
interviews Interview sessions
interview_participants Invites & participants
interview_sessions Per-challenge tracking
invite_tokens Secure invite links
hint_usage Hint tracking
anti_cheat_events Integrity logging
organization_members Team memberships

Features:

  • ✅ Full RLS policies
  • ✅ Automatic timestamps
  • ✅ Indexes for performance
  • ✅ Secure invite token generation

API Routes

Route Method Description
/api/ai/completions POST Chat completions (streaming)
/api/ai/hints POST Generate progressive hint
/api/ai/hints GET Get hint history
/api/ai/explain POST Explain code (streaming)

File Structure

lib/ai/
├── client.ts          # AI client (OpenAI + Anthropic)
├── config.ts          # Configuration
├── prompts.ts         # System prompts
├── context-extractor.ts # Code context extraction
└── index.ts           # Exports

app/api/ai/
├── completions/route.ts  # Chat completions
├── hints/route.ts        # Hint generation
└── explain/route.ts      # Code explanation

components/editor/ai/
├── hint-panel.tsx        # Hint UI component
├── explanation-panel.tsx # Explanation UI
└── index.ts              # Exports

supabase/migrations/
└── 003_interview_sessions.sql  # Full schema

Environment Variables Required

# AI
OPENAI_API_KEY=sk-...
OPENAI_MODEL=gpt-4-turbo-preview
ANTHROPIC_API_KEY=sk-ant-...  # Optional
AI_MAX_TOKENS=4096
AI_TEMPERATURE=0.7
AI_RATE_LIMIT=50

# Supabase
NEXT_PUBLIC_SUPABASE_URL=...
NEXT_PUBLIC_SUPABASE_ANON_KEY=...
SUPABASE_SERVICE_ROLE_KEY=...

Usage Examples

Generate Hint

const response = await fetch('/api/ai/hints', {
  method: 'POST',
  body: JSON.stringify({
    challengeId: 'modal',
    challenge: 'Build an accessible modal...',
    currentCode: code,
    level: 2,
    previousHints: ['Level 1 hint...']
  })
});

const { hint, nextLevelAvailable } = await response.json();

Explain Code

const response = await fetch('/api/ai/explain', {
  method: 'POST',
  body: JSON.stringify({
    code: selectedCode,
    language: 'typescript',
    detailLevel: 'detailed'
  })
});

// Stream the response
const reader = response.body.getReader();
// ... handle SSE stream

Remaining Work

See issues for remaining tasks:


Acceptance Criteria

  • AI client works with OpenAI
  • AI client works with Anthropic (configurable)
  • Streaming responses work
  • Rate limiting enforced
  • Hints are progressive (3 levels)
  • Hint history stored in DB
  • Code explanation streams to UI
  • Database schema created
  • RLS policies working

Relates to: #43, #44, #45, #46, #47
Master Tracker: #42

### Database Schema (Supabase)
- interviews: Interview sessions with types (live, ai_conducted, take_home)
- interview_participants: Multi-participant support with invite system
- interview_sessions: Candidate session tracking with AI scores
- anti_cheat_events: Comprehensive cheat detection logging
- ai_conversations: AI interviewer chat history
- interview_recordings: Recording storage metadata
- candidate_evaluations: Final assessment reports with trust scores
- RLS policies for secure data access

### Anti-Cheat System
- Tab switch detection
- Copy/paste monitoring
- DevTools detection
- Fullscreen enforcement
- Keyboard shortcut blocking
- Typing pattern analysis (detects copy-paste/bots)
- Trust score calculation (0-100)

### AI Interviewer Component
- Conversational AI interviewer interface
- Voice input support (Web Speech API)
- Progressive hint system (3 levels)
- Real-time scoring: technical, communication, problem-solving
- Automatic interview evaluation
- Strengths and areas for improvement
- Recommendation engine (strong_yes → strong_no)

### Live Interview Room
- Video/audio with WebRTC (getUserMedia)
- Screen sharing support
- Real-time chat
- Code editor panel
- Recording controls
- Participant management
- Raise hand functionality
- Professional dark theme

### Features for Production
- Interviewer mode for live interviews
- AI-conducted interviews (automated)
- Anti-cheat with trust scoring
- Recording playback
- Multi-participant support

Relates to #30 (Platform Roadmap)
@vercel

vercel Bot commented Feb 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
acecodinglab Error Error Feb 23, 2026 7:31pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant