A powerful web-based Python debugger with AI-powered error explanations and fix suggestions using Google's Gemini AI. Execute Python code safely in a sandboxed environment and get intelligent debugging assistance.
- 🔒 Safe Code Execution: Sandboxed Python code execution with timeout protection
- 🤖 AI-Powered Analysis: Intelligent error explanations using Google Gemini AI
- 🔍 Syntax Validation: Real-time syntax error detection before execution
- ⚡ Runtime Debugging: Comprehensive runtime error analysis and handling
- 🌐 Modern Web Interface: Beautiful, responsive UI with syntax highlighting
- 📊 Real-time Results: Instant feedback with AI-powered suggestions
- 💡 Educational Focus: Student-friendly explanations and learning approach
- Python 3.8 or higher
- Google Gemini API key (for AI features)
-
Clone and setup
git clone <repository-url> cd IntelliDebug
-
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Configure environment Create a
.envfile:GEMINI_API_KEY=your_google_gemini_api_key_here -
Run the application
python app.py
Visit http://127.0.0.1:5000 to start debugging!
- Navigate to the web interface in your browser
- Enter Python code in the editor
- Click "Run Code" to execute and get AI analysis
- View detailed explanations and suggested fixes
Debug Endpoint (POST /debug)
curl -X POST http://localhost:5000/debug \
-H "Content-Type: application/json" \
-d '{"code": "print(\"Hello, World!\")"}'Response:
{
"success": true,
"output": "Hello, World!",
"error": null,
"ai_explanation": "Code executed successfully! 🎉"
}Health Check (GET /health)
curl http://localhost:5000/health- Sandboxed Execution: Code runs in isolated subprocesses
- Timeout Protection: 5-second execution limit prevents hanging
- Output Limits: Prevents memory exhaustion from large outputs
- Input Validation: Comprehensive request validation
- Error Sanitization: Safe error message handling
GEMINI_API_KEY: Your Google Gemini API key (required for AI features)HOST: Server host (default: 127.0.0.1)PORT: Server port (default: 5000)FLASK_DEBUG: Enable debug mode (default: True)
MAX_EXECUTION_TIME: Code execution timeout in seconds (default: 5)MAX_OUTPUT_LENGTH: Maximum output length (default: 2000)
IntelliDebug/
├── app.py # Main Flask application
├── requirements.txt # Python dependencies
├── README.md # Project documentation
├── .env # Environment variables
├── .gitignore # Git ignore rules
└── templates/
└── index.html # Web interface
# Enable debug mode
export FLASK_DEBUG=True
python app.py
# Use custom port
export PORT=8000
python app.pyAI features not working
- Verify
GEMINI_API_KEYis set correctly - Check API key permissions in Google AI Studio
- Ensure stable internet connection
Code execution timeout
- Code execution limited to 5 seconds by default
- Check for infinite loops in your code
- Consider optimizing long-running algorithms
Port already in use
# Use different port
export PORT=8000
python app.py
# Or kill existing process
lsof -ti:5000 | xargs kill -9Check debugger.log for detailed error information and troubleshooting data.
| Method | Endpoint | Description |
|---|---|---|
POST |
/debug |
Execute Python code and get analysis |
GET |
/health |
Health check and service status |
GET |
/ |
Web interface |
{
"code": "your_python_code_here"
}{
"success": boolean,
"output": string,
"error": string|null,
"error_type": "syntax"|"runtime"|null,
"ai_explanation": string,
"suggested_fix": string|null,
"fix_explanation": string|null
}
Made with ❤️ by Tuhin for Python learners
For more information, visit our GitHub repository.