Google Gemini API Overview
The application integrates with Google’s Gemini AI using the@google/genai SDK. The AI service is configured in src/services/ai.service.js and uses the Gemini 3 Flash Preview model for fast, high-quality content generation.
AI Capabilities
The Gemini AI service provides:-
Interview Report Generation
- Analyzes job descriptions and resumes
- Calculates match scores (0-100)
- Generates personalized technical and behavioral questions
- Identifies skill gaps with severity levels
- Creates day-by-day preparation plans
-
Resume Generation
- Generates ATS-friendly HTML resumes
- Tailors content to specific job descriptions
- Converts HTML to PDF using Puppeteer
- Optimizes for 1-2 page length
- Maintains professional formatting
Getting Started
Create Google AI Studio Account
- Visit Google AI Studio
- Sign in with your Google account
- Accept the terms of service
Generate API Key
- In Google AI Studio, click Get API Key in the left sidebar
- Click Create API Key
- Select an existing Google Cloud project or create a new one
- Copy your API key (starts with
AIzaSy...)
AI Service Configuration
The AI service is initialized insrc/services/ai.service.js:6-8:
Model Selection
The application uses Gemini 3 Flash Preview (gemini-3-flash-preview) for optimal performance:
- Fast response times: Ideal for real-time applications
- Structured output: Supports JSON schema responses
- Multimodal input: Can process text and uploaded resume files
- Cost-effective: Lower cost than full Gemini Pro models
Interview Report Generation
ThegenerateInterviewReport function analyzes candidate profiles and generates comprehensive interview preparation reports.
Input Schema
Job title for the position
Resume text content (optional if resumeFile is provided)
Candidate’s self-description or cover letter
Complete job description including requirements and responsibilities
Uploaded resume file (PDF, DOC, etc.)
data: Base64 encoded file datamimeType: File MIME type (e.g., “application/pdf”)
Output Schema
The AI generates a structured JSON response with the following fields:Score between 0-100 indicating profile-job match quality
Array of technical interview questionsEach question includes:
question: The interview question textintention: Why the interviewer asks thisanswer: Recommended approach to answer
Array of behavioral interview questionsEach question includes:
question: The interview question textintention: Why the interviewer asks thisanswer: Recommended approach to answer
Identified skill gapsEach gap includes:
skill: The skill nameseverity: “low”, “medium”, or “high”
Day-by-day preparation roadmapEach day includes:
day: Day number (starting from 1)focus: Main focus areatasks: Array of specific tasks
Echo of the job title
Schema Definition
The response schema is defined using Zod and converted to JSON Schema for the Gemini API:API Call Configuration
The interview report generation uses these settings:Model identifier:
gemini-3-flash-previewInput prompt, optionally with file attachments for multimodal processing
Set to
"application/json" for structured outputJSON Schema defining the expected response structure
Resume Generation
ThegenerateResumePdf function creates professional, ATS-friendly resumes tailored to job descriptions.
Input Parameters
Candidate’s existing resume or career information
Candidate’s self-description highlighting key strengths
Target job description to tailor the resume for
Output
Returns a PDF buffer that can be downloaded or saved to disk.Resume Generation Process
AI generates HTML
The Gemini model creates well-formatted HTML optimized for the job:
- Highlights relevant experience
- Uses professional styling
- Maintains ATS compatibility
- Keeps length to 1-2 pages
Prompt Engineering
The resume generation prompt includes specific instructions for quality:- Make content sound natural, not AI-generated
- Highlight relevant strengths for the job
- Use colors and formatting professionally
- Ensure ATS compatibility
- Keep to 1-2 pages maximum
- Focus on quality over quantity
Rate Limits and Quotas
Google AI Studio has usage limits:Free Tier Limits
- Requests per minute: 15 RPM
- Requests per day: 1,500 RPD
- Tokens per minute: 1 million TPM
Monitor your usage in Google AI Studio under the Quota section.
Best Practices
- Implement request throttling in production
- Cache results when appropriate
- Handle rate limit errors gracefully
- Monitor quota usage regularly
- Consider upgrading to paid tier for production
Error Handling
The AI service may throw errors that need proper handling:API Key Invalid
API Key Invalid
Error: Invalid API keySolution:
- Verify your API key is correct in
.env - Check the key hasn’t expired
- Regenerate a new key if necessary
Rate Limit Exceeded
Rate Limit Exceeded
Error: 429 Too Many RequestsSolution:
- Implement exponential backoff retry logic
- Reduce request frequency
- Upgrade to paid tier for higher limits
Model Not Available
Model Not Available
Error: Model not found or unavailableSolution:
- Verify model name is
"gemini-3-flash-preview" - Check Google AI Studio for service status
- Try alternative models if available
Invalid Response Schema
Invalid Response Schema
Error: Response doesn’t match expected schemaSolution:
- Review your Zod schema definition
- Check AI prompt clarity
- Add more detailed field descriptions
- Validate the JSON Schema conversion
Testing AI Integration
Test your AI setup with a simple request:Optimizing AI Performance
Prompt Optimization
- Keep prompts clear and specific
- Include all necessary context
- Use examples when needed
- Specify desired output format
Schema Design
- Use descriptive field descriptions
- Leverage Zod’s validation features
- Keep schemas aligned with database models
- Document enum values clearly
Response Processing
- Parse JSON responses safely
- Validate against expected schema
- Handle missing or null fields
- Log unexpected responses for review
Monitoring and Debugging
Enable Detailed Logging
Track Metrics
- Request success/failure rates
- Average response times
- Token usage per request
- Error types and frequencies
Next Steps
Environment Variables
Review all configuration requirements
Database Setup
Set up MongoDB and understand data models