Your AI-powered Python coding companion - Learn, code, and debug with instant help!
PythonBuddy is a beginner-friendly Python learning assistant that combines rule-based keyword matching for instant responses with DeepSeek AI for complex questions. Perfect for Python learners of all levels!
- Rule-based responses for 17+ Python topics (instant, no API cost)
- DeepSeek AI integration for complex questions, debugging, and custom requests
- Smart context-aware responses with chat history
- Multiple chat sessions - Organize your learning by topic
- Rename chats - Customize names for different subjects (✏️ pencil icon)
- Persistent storage - All chats saved in localStorage (no login required)
- Share conversations - Generate shareable links for your chats
- Export to .txt - Download chat conversations as formatted text files
- Theme switcher - Light/Dark/System modes with auto-detection
- Responsive design - Mobile-first, optimized for all devices
- Clean interface - ChatGPT-style chat experience
- Quick-start buttons - 6 example topics to get started instantly
- XSS protection - escapeHtml() sanitization on all user inputs
- Input validation - Character limits and message caps
- localStorage quota management - Auto-cleanup to keep 5 most recent chats
- No-cache headers - Always serves latest updates
- Debug mode OFF - Production-ready deployment
- Print statements & output
- Variables & data types
- User input
- Error handling (try/except)
- Classes & OOP
- Imports & modules
- List operations (reverse, sort)
- File I/O (read/write)
- Loops (for, while)
- Functions
- Lists & dictionaries
- Strings & conditionals (if/else)
- ...and more with AI assistance!
- Python 3.11+
- Flask
- OpenAI-compatible API (DeepSeek)
- Clone the repository:
git clone https://github.com/thuglifeai/pythonbuddy.git
cd pythonbuddy- Install dependencies:
pip install flask gunicorn openai- Set up environment variables:
export DEEPSEEK_API_KEY="your-api-key-here"
export SESSION_SECRET="your-secret-key"- Run the application:
python app.py- Open your browser and navigate to:
http://localhost:5000
pythonbuddy/
├── app.py # Flask web server with share endpoints
├── main.py # PythonBuddy class with keyword detection
├── templates/
│ ├── index.html # Main chat interface
│ └── shared.html # Public shared chat view
├── replit.md # Project documentation & architecture
└── README.md # This file
- Backend: Flask (Python 3.11)
- AI: DeepSeek API (OpenAI-compatible)
- Frontend: Vanilla JavaScript, CSS3
- Storage: localStorage (client-side)
- Deployment: Gunicorn (autoscale)
- Keyword Detection: User questions are scanned for Python-related keywords
- Rule-based Response: If matched, instant code examples are provided
- AI Fallback: Complex questions route to DeepSeek AI with chat context
- Smart Context: Chat history maintains conversation flow
- Auto-naming: First question becomes chat title automatically
| Variable | Description | Required |
|---|---|---|
DEEPSEEK_API_KEY |
DeepSeek API key for AI responses | Yes |
SESSION_SECRET |
Flask session secret key | Yes |
Basic Questions (Rule-based - Instant):
- "How do I print Hello World?"
- "How do I create a variable?"
- "How do I reverse a list?"
Complex Questions (AI-powered):
- "Debug this code: [paste your code]"
- "Explain decorators with examples"
- "How do I build a REST API in Python?"
gunicorn --bind 0.0.0.0:5000 --reuse-port app:app- Import this repository to Replit
- Add secrets:
DEEPSEEK_API_KEY,SESSION_SECRET - Click "Run" - it's configured for autoscale deployment!
Contributions are welcome! Feel free to:
- Report bugs
- Suggest new Python topics
- Improve the AI prompts
- Enhance the UI/UX
This project is licensed under the MIT License - see the LICENSE file for details.
- Python community for inspiration
- DeepSeek for AI capabilities
- Flask framework for simplicity
- Replit for hosting platform
ThugLife.AI - Building AI-powered learning tools
- GitHub: @thuglifeai
- Project: PythonBuddy
Made with ❤️ for Python learners worldwide 🐍✨