Create a .env file in the project root or set these environment variables:
# Set your preferred AI provider: gemini, openai, claude, or mock
export AI_PROVIDER=gemini
# API Keys (only set the one you're using)
export GEMINI_API_KEY=your_gemini_api_key_here
export OPENAI_API_KEY=your_openai_api_key_here
export CLAUDE_API_KEY=your_claude_api_key_here
# Optional: Override default models
export AI_MODEL=gemini-pro- Go to Google AI Studio
- Create a new API key
- Set
AI_PROVIDER=geminiandGEMINI_API_KEY=your_key
- Go to OpenAI API Keys
- Create a new API key
- Set
AI_PROVIDER=openaiandOPENAI_API_KEY=your_key
- Go to Anthropic Console
- Create a new API key
- Set
AI_PROVIDER=claudeandCLAUDE_API_KEY=your_key
For testing without API keys, use mock AI:
export AI_PROVIDER=mockThis provides realistic-looking responses without making external API calls.
cd web-ui
go run main.goThe AI features will be available at:
POST /api/ai/code-review- Real-time code analysisPOST /api/ai/interviewer-questions- Generate follow-up questionsPOST /api/ai/code-hint- Context-aware hints
- Overall Score: 0-100 rating of code quality
- Issues Detection: Bugs, performance, style, logic issues
- Suggestions: Optimization and best practice recommendations
- Complexity Analysis: Time/space complexity evaluation
- Interviewer Feedback: What a real interviewer would say
- Security: All content is HTML-escaped for safety
- Context-aware questions based on the user's solution
- Progressive difficulty based on user performance
- Go-specific technical probing
- Edge case exploration
- Array of 5 relevant questions per request
- 4 levels of hints (subtle nudge → detailed explanation)
- Context-aware based on current code
- Educational approach that teaches concepts
- Progressive hint buttons (Lv1 → Lv2 → Lv3 → Lv4)
POST /api/ai/code-review
{
"challengeId": 1,
"code": "func Sum(a, b int) int { return a + b }",
"context": "Interview started 5 minutes ago"
}POST /api/ai/interviewer-questions
{
"challengeId": 1,
"code": "func Sum(a, b int) int { return a + b }",
"userProgress": "Completed basic solution"
}POST /api/ai/code-hint
{
"challengeId": 1,
"code": "func Sum(a, b int) int { // stuck here }",
"hintLevel": 2
}