Skip to content

zy1h0s/mock

Repository files navigation

Mock Interview Training System

Real-time mock interview platform where trainers control AI interviewer avatars to conduct practice interviews with candidates, featuring automatic recording, transcription, and AI-powered feedback generation.

Features

  • Live video interviews with AI text-to-speech interviewer
  • Real-time transcription using browser Web Speech API
  • Question bank with customizable templates
  • AI-powered performance feedback using Groq
  • WebRTC peer-to-peer video connection
  • Recording and playback capabilities
  • 100% free for testing

Tech Stack

Frontend:

  • React with Vite
  • Tailwind CSS (black and white design)
  • WebRTC for peer-to-peer video
  • Zustand for state management
  • Axios for API communication

Backend:

  • Python FastAPI
  • WebSocket for real-time messaging
  • SQLite for database (testing), PostgreSQL (production)
  • SQLAlchemy ORM with async support

Key Services (All Free):

  • Text-to-Speech: Browser Web Speech API (built-in, zero cost)
  • Speech-to-Text: Browser Web Speech API (real-time, zero cost)
  • AI Feedback: Groq API (completely free, fast inference)
  • Video: WebRTC with Google STUN servers (free)

Quick Start

Prerequisites

  • Python 3.10+
  • Node.js 18+
  • Modern browser (Chrome recommended for best Web Speech API support)

Backend Setup

  1. Navigate to the project directory:
cd mock-interview-system
  1. Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install Python dependencies:
pip install -r requirements.txt
  1. Create a .env file in the root directory:
DATABASE_URL=sqlite+aiosqlite:///./interviews.db
JWT_SECRET=your-secret-key-change-in-production
GROQ_API_KEY=your-groq-api-key-here
ALLOWED_ORIGINS=http://localhost:5173
  1. Run the backend server:
python -m uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000

The API will be available at http://localhost:8000 with interactive docs at http://localhost:8000/docs

Frontend Setup

  1. Install Node.js dependencies:
npm install
  1. Create a .env file in the frontend directory:
VITE_API_URL=http://localhost:8000
VITE_WS_URL=ws://localhost:8000
  1. Start the development server:
npm run dev

The frontend will be available at http://localhost:5173

Get Groq API Key (Free)

  1. Visit https://console.groq.com
  2. Sign up for a free account
  3. Generate an API key
  4. Add it to your .env file

Usage

For Trainers/Admins:

  1. Register an account at the login page
  2. Log in to access the admin dashboard
  3. Click "Create New Interview"
  4. Select interview type (Technical, Behavioral, HR, System Design, Custom)
  5. Choose duration (30, 45, or 60 minutes)
  6. Share the generated room code with the candidate
  7. Wait for the candidate to join
  8. Click "Start Interview" when ready
  9. Type questions in the text field and click "Speak" to have the AI interviewer speak them
  10. Monitor the live transcript on the right side
  11. Take private notes as needed
  12. Use "Pause" to temporarily stop, "Resume" to continue
  13. Click "End Interview" when finished to generate AI feedback

For Candidates:

  1. Receive the room code from your interviewer
  2. Visit the application and click "Join with room code"
  3. Enter the room code (format: ABC-123)
  4. Enter your full name
  5. Allow camera and microphone access
  6. Wait in the waiting room for the interview to start
  7. Listen to the AI interviewer's questions (text-to-speech)
  8. Answer verbally (speech-to-text will capture your responses)
  9. Use the controls to mute/unmute or toggle camera if needed
  10. Receive feedback after the interview ends

System Architecture

Two-PC Setup

  • PC A (Admin/Trainer): Controls the interview, types questions, sees live transcript, takes notes
  • PC B (Candidate): Joins via room code, sees/hears AI interviewer, gets interviewed
  • AI Interviewer Avatar: Speaks whatever admin types using browser text-to-speech
  • Post-Interview: Auto-generates detailed feedback using Groq AI

WebRTC Connection

  • Peer-to-peer video and audio between admin and candidate
  • Uses free Google STUN servers for NAT traversal
  • WebSocket for signaling (ICE candidate exchange)
  • Echo cancellation and noise suppression enabled
  • Auto-reconnect on disconnect with exponential backoff

Real-time Communication

  • WebSocket maintains persistent connections for each session
  • Message types: admin_question, candidate_response, transcript_update, webrtc_signal, session_control
  • Admin types question → WebSocket → Candidate receives → TTS plays
  • Candidate speaks → Browser STT → WebSocket → Updates transcript → Shows to admin

API Endpoints

Authentication

  • POST /api/auth/register - Register new admin account
  • POST /api/auth/login - Admin login
  • POST /api/auth/verify - Verify JWT token

Interview Management

  • POST /api/interview/create - Create new session and generate room code
  • POST /api/interview/join - Candidate joins with room code
  • GET /api/interview/{session_id} - Get session details
  • POST /api/interview/start - Start interview
  • POST /api/interview/pause - Pause interview
  • POST /api/interview/resume - Resume interview
  • POST /api/interview/end - End interview and trigger feedback generation
  • WS /api/interview/ws/{session_id}/{role} - WebSocket connection

Question Bank

  • GET /api/questions - Get all questions (with optional filters)
  • POST /api/questions - Create new question
  • PUT /api/questions/{id} - Update question
  • DELETE /api/questions/{id} - Delete question
  • GET /api/questions/templates - Get pre-built question templates

Feedback

  • POST /api/feedback/generate - Generate AI feedback using Groq
  • GET /api/feedback/{session_id} - Get feedback report

Transcript

  • GET /api/transcript/{session_id} - Get full transcript
  • POST /api/transcript/entry - Add transcript entry

Project Structure

mock-interview-system/
├── README.md
├── requirements.txt
├── package.json
├── .env.example
├── .gitignore
├── backend/
│   ├── __init__.py
│   ├── main.py                 # FastAPI app entry point
│   ├── config.py               # Configuration settings
│   ├── database.py             # Database connection and session
│   ├── models.py               # SQLAlchemy models
│   ├── websocket_manager.py    # WebSocket connection manager
│   ├── routes/
│   │   ├── __init__.py
│   │   ├── auth.py             # Authentication endpoints
│   │   ├── interview.py        # Interview session endpoints
│   │   ├── feedback.py         # Feedback generation endpoints
│   │   ├── questions.py        # Question bank endpoints
│   │   └── transcript.py       # Transcript endpoints
│   └── services/
│       ├── __init__.py
│       └── ai_feedback.py      # Groq AI feedback service
├── frontend/
│   ├── index.html
│   ├── src/
│   │   ├── main.jsx            # React entry point
│   │   ├── App.jsx             # Main app with routing
│   │   ├── index.css           # Tailwind CSS imports
│   │   ├── pages/
│   │   │   ├── Login.jsx       # Admin login/register
│   │   │   ├── AdminDashboard.jsx   # Admin interview control
│   │   │   ├── CandidateRoom.jsx    # Candidate interview view
│   │   │   └── FeedbackReport.jsx   # Feedback display
│   │   ├── components/
│   │   │   ├── VideoCall.jsx        # Video display component
│   │   │   ├── AIAvatar.jsx         # AI interviewer avatar
│   │   │   ├── AdminControls.jsx    # Admin control panel
│   │   │   ├── TranscriptPanel.jsx  # Live transcript display
│   │   │   └── Timer.jsx            # Interview timer
│   │   ├── hooks/
│   │   │   ├── useWebRTC.js         # WebRTC connection hook
│   │   │   ├── useWebSocket.js      # WebSocket connection hook
│   │   │   └── useTTS.js            # Text-to-speech hook
│   │   └── services/
│   │       ├── api.js               # API client
│   │       └── webrtc.js            # WebRTC service
│   └── vite.config.js
├── tailwind.config.js
├── postcss.config.js
└── tests/

Database Schema

Tables

users: Admin accounts

  • id, email, password_hash, role, created_at

interview_sessions: Interview sessions

  • id, session_id, room_code, admin_id, candidate_name, status, interview_type, started_at, ended_at, duration, recording_url

questions: Question bank

  • id, category, difficulty, text, expected_points, time_allocation, tags, created_by

interview_questions: Questions asked in specific interviews

  • id, session_id, question_id, question_text, asked_at, response_text, response_duration, admin_rating, admin_notes

transcripts: Interview transcripts

  • id, session_id, speaker, text, timestamp

feedback_reports: AI-generated feedback

  • id, session_id, overall_score, dimension_scores, strengths, improvements, detailed_feedback, recommendations

Design Guidelines

The UI follows a strict black and white design:

  • Background: Pure white (#FFFFFF)
  • Text: Pure black (#000000)
  • Secondary text: Dark gray (#333333)
  • Borders: Medium gray (#CCCCCC)
  • Disabled: Light gray (#999999)
  • Hover: Light gray background (#F5F5F5)
  • No colors except black, white, and grays
  • No emojis in the interface

Deployment

Frontend (Vercel - Free)

  1. Push code to GitHub
  2. Connect Vercel to repository
  3. Set build command: npm run build
  4. Set output directory: dist
  5. Add environment variables: VITE_API_URL, VITE_WS_URL
  6. Deploy

Backend (Railway - Free 500 hours/month)

  1. Create Railway account
  2. Connect GitHub repository
  3. Set start command: uvicorn backend.main:app --host 0.0.0.0 --port $PORT
  4. Add environment variables: DATABASE_URL, JWT_SECRET, GROQ_API_KEY, ALLOWED_ORIGINS
  5. Deploy

Database

  • Testing: SQLite (included with Python)
  • Production: Neon PostgreSQL free tier (0.5GB storage)

Cost Analysis

Testing

  • Everything: $0

Production (up to 100 interviews/month)

  • Vercel hosting: $0
  • Railway hosting: $0 (500 free hours)
  • Neon PostgreSQL: $0 (free tier)
  • Groq AI: $0 (free)
  • WebRTC/STUN: $0 (free)
  • Web Speech API: $0 (browser built-in)

Total: $0-5/month for production use

Browser Compatibility

  • Best experience: Google Chrome (latest)
  • Supported: Edge, Safari, Firefox
  • Required features: WebRTC, Web Speech API (SpeechSynthesis, SpeechRecognition)

Troubleshooting

WebRTC connection fails

  • Ensure both parties allow camera/microphone access
  • Check firewall settings
  • Try using Chrome for better compatibility

Speech recognition not working

  • Use Chrome or Edge for best support
  • Ensure microphone permission granted
  • Check browser console for errors

Groq API errors

WebSocket disconnects

  • Auto-reconnect should handle temporary issues
  • Check network stability
  • Verify backend is running

Future Enhancements

  • Screen sharing for technical interviews
  • Code editor integration for live coding
  • Calendar scheduling and email notifications
  • Mobile app for iOS/Android
  • Premium AI avatars with realistic voices
  • Advanced analytics and performance tracking
  • Multi-language support
  • Recording playback with timestamp navigation

License

MIT License - Feel free to use this for your mock interview training needs.

Support

For issues, questions, or contributions, please open an issue on the GitHub repository.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •