AI Career Quiz Use Case Example & Flow
Overview
This system provides an AI-powered career assessment quiz that generates personalized career suggestions based on user responses. Here's how your team can implement and use it:
base_url = http://localhost:5000/api
Note: You have to add GEMINI_API_KEY to your .env file, and you get api key by following below instructions.
Key Components
- Quiz Initiation: Starts a new assessment session
- Question Flow: Dynamically generates questions based on previous answers
- Result Generation: Provides career suggestions after 10 questions
- Progress Tracking: Allows users to resume incomplete quizzes
🔑 Setup Gemini API Key
Note: You need to add GEMINI_API_KEY to your .env file to use Gemini models.
🛠️ How to get your API key:
- Go to Google AI Studio.
- Sign in with your Google account.
- Click "Create API Key".
- Copy the key and add it to your
.envfile:
GEMINI_API_KEY=your_api_key_here
Typical User Flow
1. Starting the Quiz
Endpoint: POST /ai-quiz/start
Frontend Action:
- User clicks "Start Career Assessment" button
- System authenticates user and calls the start endpoint
Expected Response:
{
"success": true,
"message": "Quiz started successfully",
"data": {
"id": 1,
"question": "Which activities energize you most?",
"options": [
{"text": "Solving complex problems", "value": "opt1"},
{"text": "Creating artistic works", "value": "opt2"},
{"text": "Helping others directly", "value": "opt3"},
{"text": "Analyzing data/patterns", "value": "opt4"}
]
},
"metadata": {
"currentQuestion": 1,
"totalQuestions": 10,
"completionPercentage": 0,
"threadId": "thread_user123_1712345678901"
}
}
Frontend Display:
- Show the question and options
- Store the
threadIdfor future requests - Update progress indicators
2. Answering Questions
Endpoint: POST /ai-quiz/submit
Frontend Action: For each question:
- User selects an answer
- System submits answer with threadId
- Displays next question or final results
Sample Request:
{
"threadId": "thread_user123_1712345678901",
"answer": "opt2"
}
Intermediate Response (questions 2-9):
{
"success": true,
"message": "Answer submitted successfully",
"data": {
"id": 2,
"question": "What work environment do you prefer?",
"options": [
{"text": "Structured and predictable", "value": "opt1"},
{"text": "Flexible and creative", "value": "opt2"},
{"text": "Fast-paced and dynamic", "value": "opt3"}
]
},
"metadata": {
"currentQuestion": 2,
"totalQuestions": 10,
"completionPercentage": 10
}
}
Final Response (after 10th answer):
{
"success": true,
"message": "Quiz completed successfully!",
"data": {
"careerSuggestions": [
{
"title": "UX/UI Designer",
"description": "Design intuitive digital experiences...",
"pros": ["High creativity", "Growing demand", "Impact user satisfaction"],
"cons": ["Subjective feedback", "Balancing needs", "Evolving standards"],
"salaryRange": "$75,000 - $120,000",
"educationPath": "Bachelor's in design + portfolio",
"jobMarket": "high",
"fitScore": 82
},
{
"title": "Data Scientist",
"description": "Extract insights from complex datasets...",
"pros": ["High earning", "Diverse applications", "Challenging work"],
"cons": ["Technical skills", "Data cleaning", "Constant learning"],
"salaryRange": "$95,000 - $150,000",
"educationPath": "Advanced degree in statistics",
"jobMarket": "high",
"fitScore": 78
}
]
},
"metadata": {
"currentQuestion": 10,
"totalQuestions": 10,
"completionPercentage": 100
}
}
3. Viewing Detailed Suggestions
Endpoint: GET /ai-quiz/suggestion/:threadId/:index
Frontend Action:
- When user clicks "Learn More" on a specific career suggestion
- System requests details for that specific suggestion
Sample Response:
{
"success": true,
"data": {
"title": "UX/UI Designer",
"description": "Design intuitive digital experiences...",
"pros": ["High creativity", "Growing demand", "Impact user satisfaction"],
"cons": ["Subjective feedback", "Balancing needs", "Evolving standards"],
"salaryRange": "$75,000 - $120,000",
"educationPath": "Bachelor's in design + portfolio",
"jobMarket": "high",
"fitScore": 82
}
}
4. Resuming an Incomplete Quiz
Endpoint: GET /ai-quiz/progress/:threadId
Frontend Action:
- When returning user logs in, check for incomplete quizzes
- Call progress endpoint with stored threadId
Sample Response:
{
"success": true,
"data": {
"userId": "user123",
"threadId": "thread_user123_1712345678901",
"currentQuestion": 3,
"completed": false,
"questions": [
{/* question 1 */},
{/* question 2 */}
]
},
"metadata": {
"currentQuestion": 3,
"totalQuestions": 10,
"completionPercentage": 20,
"isCompleted": false
}
}
