This project uses Next.js App Router API routes to handle authentication, AI interview flow, quiz generation, prep-hub analysis, chatbot responses, and history retrieval.
| Method | Route | Purpose | Main Input | Main Output |
|---|---|---|---|---|
| POST | /api/chatbot | Sends user messages to the AI chatbot | { message, history } |
{ reply } or error |
| POST | /api/vapi/webhook | Receives voice interview webhook events from Vapi | webhook payload | confirmation and session updates |
| POST | /api/interview/start | Starts a new mock interview session | role, experience level, interview type, company, tech stack, resume text | { success, sessionId } |
| POST | /api/interview/feedback | Generates AI feedback for a completed interview | { sessionId, userId } |
{ feedback } |
| POST | /api/interview/end | Ends an interview session and stores transcript summary | { sessionId, transcript, durationSeconds } |
{ success: true } |
| GET | /api/interview/sessions | Fetches interview history for the signed-in user | query param id optional |
{ sessions } or { session } |
| POST | /api/quiz/generate | Generates AI quiz questions | { topic, level, count } |
{ questions } |
| POST | /api/quiz/save | Saves quiz results to Firestore | { topic, level, correct, total, durationSeconds } |
{ success, sessionId } |
| GET | /api/quiz/sessions | Fetches previous quiz sessions | none | { sessions, scoreHistory } |
| GET | /api/quiz/stats | Returns quiz performance analytics | none | stats object |
| POST | /api/prep-hub/analyze | Analyzes resume and job description to generate interview prep content | form data with resume and optional JD | AI-generated prep result |
| GET | /api/prep-hub/sessions | Fetches past prep-hub sessions | none | { sessions } |
| GET | /sign-out | Signs the user out by clearing the session cookie | none | redirect or success response |
- POST /api/chatbot
This API connects the frontend chatbot UI with the Groq AI model. It sends the user’s message and chat history to the AI and returns a helpful response related to interview preparation.
{
"message": "How should I prepare for a React interview?",
"history": []
}{
"reply": "Here are some useful tips..."
}- It uses a system prompt to keep the assistant focused on interview preparation topics.
- It is useful for resume advice, platform guidance, and technical interview help.
- POST /api/vapi/webhook
This endpoint receives events from the Vapi voice AI service during mock interviews. It updates the interview session status and saves the transcript once the call ends.
- detects interview status updates such as in-progress and ended,
- stores transcript content,
- marks the interview as completed,
- triggers feedback generation after the call finishes.
- It is mainly used by the voice interview system.
- It is not called directly by the user from the frontend.
- POST /api/interview/start
This API creates a new interview session when the user begins a mock interview.
- role
- experienceLevel
- interviewType or company
- techStack
- durationMinutes
- resumeText or uploaded resume
{
"success": true,
"sessionId": "uuid"
}- The session is saved in Firestore under the user’s interview_sessions subcollection.
- It also selects the appropriate Vapi assistant based on the interview mode.
- POST /api/interview/feedback
This API analyzes the interview transcript using AI and generates structured feedback.
{
"sessionId": "session-id",
"userId": "user-id"
}{
"feedback": {
"overallScore": 82,
"summary": "Good communication",
"strengths": ["Clear answers"],
"improvements": ["Be more specific"],
"questionBreakdown": []
}
}- It uses the stored transcript from the interview session.
- It updates the Firestore document with feedback.
- POST /api/interview/end
This API closes the interview session and updates its final status.
{
"sessionId": "session-id",
"transcript": [],
"durationSeconds": 180
}{
"success": true
}- It is used when the interview ends from the client flow.
- It can also trigger feedback generation as a fallback.
- GET /api/interview/sessions
This API retrieves interview history for the logged-in user.
id: optional, fetch a single interview session
{
"sessions": []
}- The result is usually ordered by newest first.
- It helps populate the profile or history screens.
- POST /api/quiz/generate
This API uses an AI model to generate multiple-choice questions for a selected topic and difficulty level.
{
"topic": "React",
"level": "intermediate",
"count": 5
}{
"questions": [
{
"id": "uuid",
"question": "What is useState?",
"options": ["A", "B", "C", "D"],
"correctIndex": 0,
"explanation": "..."
}
]
}- It is used by the quiz module.
- The response is designed to be directly shown in the quiz UI.
- POST /api/quiz/save
This API saves the quiz attempt result into Firestore.
{
"topic": "React",
"level": "Intermediate",
"correct": 8,
"total": 10,
"durationSeconds": 180
}{
"success": true,
"sessionId": "quiz-session-id"
}- It also generates a short AI-based feedback recommendation.
- The data is stored under the user’s quiz_sessions subcollection.
- GET /api/quiz/sessions
This API fetches all past quiz attempts for the logged-in user.
{
"sessions": [],
"scoreHistory": []
}- It is used to display quiz history and performance charts.
- GET /api/quiz/stats
This API calculates quiz analytics such as average score, best score, latest score, total sessions, and improvement trend.
{
"avgScore": 80,
"bestScore": 95,
"latestScore": 85,
"totalSessions": 6,
"improvement": 10
}- It is useful for the profile and analytics dashboard.
- POST /api/prep-hub/analyze
This API processes the uploaded resume and optional job description, then generates interview Q&A, prep topics, and resume improvement tips.
- form-data containing
resume - optional
jdorjdFile
A JSON object with:
- role
- qa
- topics
- tips
- It uses PDF or DOCX parsing when needed.
- It stores the generated result in Firestore for later viewing.
- GET /api/prep-hub/sessions
This API returns the user’s previous prep-hub sessions.
{
"sessions": []
}- It helps the user revisit prior interview prep results.
- GET /sign-out
This endpoint clears the user session cookie and logs the user out.
- It is a simple authentication-related route used by the sign-out flow.
The APIs are connected like this:
- The user starts an interview through the interview start API.
- The voice interview runs through Vapi and the webhook API updates the session.
- The feedback API generates evaluation after the interview ends.
- The quiz APIs generate and save quiz attempts.
- The prep-hub APIs analyze resumes and generate tailored preparation content.
- The chatbot API provides on-demand AI support.
This makes the project a full-stack AI interview preparation system with both user-facing and backend intelligence.