An intelligent web application that helps you learn competitive programming by providing progressive hints, explanations, and guidance for Codeforces problems. The AI tutor guides you through problem-solving rather than just giving away solutions, with support for multiple conversations and advanced session management.
- Auto Problem Extraction: Automatically extracts problem data when you paste Codeforces URLs
- AI-Powered Tutoring: Uses Gemini AI to provide intelligent coaching and personalized guidance
- Multi-Conversation Support: Work on multiple problems simultaneously with independent conversation contexts
- Progressive Hints: Get increasingly specific hints based on your progress and conversation history
- Interactive Chat: Discuss your approach and get personalized feedback with full conversation context
- Code Analysis: Submit your code for detailed analysis and suggestions
- Session Persistence: Your conversations are saved and restored across browser sessions
- Modern UI: Clean, responsive ChatGPT-like interface with VS Code-style syntax highlighting
- Real-time Features: Auto-scrolling, copy buttons, smooth animations, and loading states
final code/
โโโ .env # Environment variables (API keys, config)
โโโ system_prompt.txt # AI tutor behavior and personality
โโโ final.py # Codeforces data extraction logic
โโโ requirements.txt # Python dependencies
โโโ Procfile # Cloud deployment process definition
โโโ runtime.txt # Python version for cloud deployment
โโโ DEPLOYMENT.md # Detailed cloud deployment guide
โโโ backend/ # Backend server code
โ โโโ app.py # Flask web server with conversation management
โ โโโ ai_service.py # Gemini AI integration service
โโโ frontend/ # Frontend web interface
โ โโโ index.html # Main web page with conversation sidebar
โ โโโ static/
โ โโโ css/
โ โ โโโ styles.css # Modern glassmorphism styling
โ โโโ js/
โ โโโ app.js # Advanced conversation management
โโโ scripts/ # Automation scripts (Linux/macOS only)
โโโ install.sh # Install dependencies without virtual env
โโโ start.sh # Start server and open browser
โโโ stop.sh # Stop running server
โโโ deploy.sh # Prepare for cloud deployment
โโโ quickstart.sh # Complete setup in one command
โโโ health_check.py # Health monitoring script
- Full automation: All shell scripts work out of the box
- One-command setup: Use
./quickstart.shfor instant setup - Auto browser opening: Server starts and browser opens automatically
- Process management: Graceful start/stop with PID tracking
- Manual commands: Use Python commands directly
- Same functionality: All features work, just different commands
- Manual browser: Open
http://localhost:5000manually after starting - Ctrl+C to stop: Use standard Windows process termination
| Task | Linux/macOS | Windows |
|---|---|---|
| Install | ./install.sh |
pip3 install -r requirements.txt |
| Start | ./start.sh |
python3 start_server.py |
| Stop | ./stop.sh |
Ctrl+C |
| Health Check | python3 health_check.py |
python health_check.py |
| Quick Start | ./quickstart.sh |
Manual steps below |
These work on all platforms:
# Install dependencies
pip3 install -r requirements.txt
# Start server
python3 start_server.py
# Health check
python3 health_check.py
# Check Python version
python3 --version./quickstart.shThis will:
- Install all requirements (no virtual environment)
- Guide you through API key setup
- Start the server
- Open your browser automatically
Linux/macOS:
./install.shWindows/Manual:
pip3 install -r requirements.txtEdit the .env file and add your Gemini API key:
# .env file
GEMINI_API_KEY=your_actual_api_key_here
GEMINI_MODEL=gemini-1.5-flash
FLASK_ENV=development
FLASK_DEBUG=True
FLASK_PORT=5000Linux/macOS:
./start.shWindows/Manual:
python3 start_server.pyThen manually open your browser to http://localhost:5000
Linux/macOS:
./stop.shWindows/Manual:
# Press Ctrl+C in the terminal where server is running- Click "New Chat" to create a fresh conversation
- Each conversation maintains independent context and history
- Paste URL: Simply paste a Codeforces URL (e.g.,
https://codeforces.com/contest/2135/problem/C) - Auto-Extraction: Problem data is extracted automatically when you paste
- Start Session: Click "Start Session" to begin working with the AI tutor
- Chat: Discuss your approach, ask questions, share ideas
- Progressive Hints: Request hints that build on your conversation history
- Code Analysis: Submit your solution attempts for detailed feedback
- Complete Solution: View solution with explanation (use wisely!)
- Switch Conversations: Click any conversation in the sidebar to switch contexts
- Independent Sessions: Each conversation tracks its own hints, progress, and context
- Persistent Storage: All conversations are saved and restored automatically
The AI tutor follows these principles:
- Contextual Guidance: Uses your full conversation history for personalized help
- Progressive Discovery: Helps you discover solutions through guided thinking
- Pattern Recognition: Teaches problem-solving patterns and algorithmic thinking
- Encouraging Exploration: Motivates trying different approaches safely
- Multiple Problems: Work on different problems simultaneously
- Context Isolation: Each conversation maintains separate context
- Session Persistence: Conversations survive browser restarts
- History Tracking: Full message history with timestamps
- Auto-Scrolling: Smooth scrolling to new messages
- Copy Buttons: One-click code copying with visual feedback
- Syntax Highlighting: VS Code-style code highlighting
- Responsive Design: Works perfectly on mobile, tablet, and desktop
- Loading States: Clear feedback during AI processing
- Auto-Extraction: No need to manually extract - just paste URLs
- Conversation Titles: Automatically named based on problem information
- Real-time Updates: Live conversation list with last activity times
- Error Handling: Graceful error recovery with user-friendly messages
Linux/macOS:
./deploy.shWindows/Manual: Create the following files manually:
Procfile:
web: python start_server.py
runtime.txt:
python-3.11.0
This creates all necessary files for cloud deployment.
- Railway (Recommended): Free tier with auto-deployment
- Render: Excellent free tier performance
- Heroku: Popular platform with easy setup
- DigitalOcean: VPS option for full control
- Connect your GitHub repository to Railway
- Set environment variables:
GEMINI_API_KEY=your_api_keyFLASK_ENV=productionFLASK_DEBUG=False
- Deploy automatically on git push
See DEPLOYMENT.md for detailed platform-specific instructions.
POST /api/extract-problem- Extract problem from Codeforces URLPOST /api/start-session- Start new tutoring session with conversation ID
POST /api/chat- Send message to AI tutor with conversation contextPOST /api/get-hint- Get progressive hint based on conversation historyPOST /api/get-solution- Get complete solution with full context
GET /api/conversation/{id}/history- Get conversation historyGET /api/session/{id}/history- Get session-specific historyGET /api/health- Server health check with conversation count
- Flask: RESTful API with conversation state management
- Conversation Isolation: Independent context tracking per conversation
- Session Persistence: Robust session and conversation storage
- Context-Aware AI: AI responses use full conversation history
- Comprehensive Logging: Detailed request/response logging for debugging
- Vanilla JavaScript: Zero dependencies, fast loading
- State Management: Advanced conversation and session state handling
- Local Storage: Persistent conversation storage across sessions
- Event-Driven: Responsive UI with real-time updates
- Error Recovery: Graceful handling of network issues and timeouts
- Environment Variables: Secure API key management
- CORS Protection: Configurable cross-origin policies
- Request Timeout: Protection against hanging requests
- Input Validation: Comprehensive input sanitization
- Error Handling: User-friendly error messages
Edit system_prompt.txt to customize:
- Tutoring style and personality
- Hint progression strategy
- Problem-solving methodology
- Response format and tone
Modify CSS variables in styles.css:
:root {
--bg: #0b0f1a; /* Background color */
--primary: #8b5cf6; /* Primary accent */
--text: #e5e7eb; /* Text color */
/* ... more variables */
}- Modify conversation storage duration
- Customize conversation title generation
- Add conversation export/import features
- Implement conversation sharing
Multiple conversations not working:
- Clear browser localStorage:
localStorage.clear() - Check console for JavaScript errors
- Ensure latest code is deployed
Conversations not persisting:
- Check browser localStorage quota
- Verify
saveToLocalStorage()is being called - Look for JavaScript errors during save/load
Auto-extraction not working:
- Verify URL format is correct
- Check network connectivity
- Ensure backend extraction endpoint is responding
Server issues:
- Use health check to verify server status
- Check
api.logfor detailed error information - Verify all environment variables are set
Enable comprehensive debugging:
Linux/macOS:
FLASK_DEBUG=True python3 start_server.pyWindows:
set FLASK_DEBUG=True && python start_server.pyLinux/macOS:
python3 health_check.pyWindows:
python health_check.pyLinux/macOS Users:
./install.sh- Install all requirements without virtual environment./start.sh- Start server and open browser automatically./stop.sh- Gracefully stop running server./deploy.sh- Prepare project for cloud deployment./quickstart.sh- Complete setup and start in one command./health_check.py- Monitor server health and availability
Windows Users:
pip3 install -r requirements.txt- Install requirementspython3 start_server.py- Start server (open browser manually)Ctrl+C- Stop server- Create deployment files manually (see Cloud Deployment section)
python health_check.py- Check server health
This project welcomes contributions for:
- New AI model integrations
- Enhanced conversation management features
- Additional problem source support
- UI/UX improvements
- Performance optimizations
- Mobile app development
This project is for educational purposes. Please respect Codeforces terms of service when using the platform.
- โ Multi-Conversation Support: Work on multiple problems simultaneously
- โ Auto-Extraction: No more manual extraction - just paste URLs
- โ Enhanced AI Context: AI uses full conversation history for better responses
- โ Session Persistence: Conversations survive browser restarts
- โ Modern UI: ChatGPT-like interface with smooth animations
- โ Cloud-Ready: One-command deployment preparation
- โ Cross-Platform: Works on Linux, macOS, and Windows
- โ Automation Scripts: Complete setup and management automation (Linux/macOS)
Happy learning! ๐
Remember: The goal is not just to solve problems, but to understand the thinking process behind competitive programming. Use this tool to build your problem-solving intuition and develop strong algorithmic thinking skills through guided practice.