An intelligent backend service that executes Python code, detects errors, and explains them in plain English using AI. This project goes beyond basic error handling by providing root cause analysis, fixes, and improved code suggestions.
- ⚡ Execute Python code safely
- ❌ Detect runtime & syntax errors
- 🤖 AI-powered explanation of errors
- 🛠 Suggested fixes with corrected code
- 📊 Structured debugging output
- 🌐 REST API using FastAPI
User Code
↓
Executor (subprocess sandbox)
↓
Error Capture
↓
AI Explanation Engine
↓
Structured Response
- Backend: FastAPI
- Execution Engine: Python subprocess
- AI Integration: OpenAI API
- Language: Python 3.12
ai-debugger/
├── main.py # FastAPI entry point
├── executor.py # Code execution logic
├── ai_explainer.py # AI integration
├── requirements.txt # Dependencies
git clone <your-repo-url>
cd ai-debugger
python -m venv venv
Windows:
venv\Scripts\activate
Mac/Linux:
source venv/bin/activate
pip install fastapi uvicorn openai
export OPENAI_API_KEY="your_api_key_here"
python -m uvicorn main:app --reload
POST /debug
{
"code": "print(10/0)"
}{
"success": false,
"error": "ZeroDivisionError: division by zero",
"ai_explanation": "..."
}{
"success": true,
"output": "10"
}print(10/0)- Error detected
- AI explains the issue
- Suggested fix provided
- Uses subprocess with timeout to prevent infinite loops
- Avoids direct
exec()usage - Recommended: Add Docker sandbox for production
- 🧩 AST-based static analysis
- 🧪 Auto test case generation
- 🖥️ Frontend UI (React)
- 🐳 Docker-based sandbox execution
- 📈 Logging & monitoring
- ⚡ Multi-language support
This project demonstrates:
- Real-world problem solving
- Backend system design
- AI integration in developer tools
- Error handling & observability
Perfect for:
- SDE roles
- Backend engineering
- Freelancing projects
Feel free to fork and improve the project.
MIT License