A powerful Telegram bot that solves mathematical problems, generates graphs, creates PDFs, and manages alarms with AI assistance. Now optimized for DigitalOcean App Platform deployment with improved architecture.
- Basic Arithmetic: Addition, subtraction, multiplication, division
- Advanced Math: Trigonometry, logarithms, exponentials
- Algebra: Equation solving, simplification
- Calculus: Derivatives, integrals, limits
- Statistics: Mean, median, mode, standard deviation
- Graph Generation: 2D function plotting with matplotlib
- PDF Reports: Comprehensive solution reports with graphs
- Step-by-step Solutions: Detailed mathematical explanations
- DeepSeek AI: Advanced problem-solving assistance
- Natural Language: Understands math problems in plain English
- Context Awareness: Remembers conversation history
- Smart Alarms: Set time-based reminders
- Timezone Support: Automatic timezone handling
- Interactive Responses: Snooze, dismiss, or respond to alarms
- Image Recognition: Extract math from photos using Google Cloud Vision
- Handwriting Support: Recognizes handwritten equations
- Automatic Solving: Solves extracted mathematical expressions
- User Statistics: Track solving history and streaks
- Performance Metrics: Monitor bot usage and efficiency
- Progress Tracking: Personal mathematical journey
MathBot_Python/
├── app/
│ ├── core/ # Core application logic
│ ├── handlers/ # Telegram bot handlers
│ ├── services/ # Business logic services
│ └── models/ # Data models and database
├── config/ # Configuration files
├── docs/ # Documentation
├── scripts/ # Utility scripts
├── tests/ # Test files
├── deployment/ # Deployment configurations
├── .github/workflows/ # GitHub Actions
├── Dockerfile # Docker configuration
├── main.py # Application entry point
└── requirements.txt # Python dependencies
- Python 3.11+
- Telegram Bot Token
- MongoDB Atlas account
- DeepSeek API key
- DigitalOcean account (for production)
- Clone the repository:
git clone https://github.com/YOUR_USERNAME/MathBot_Python.git
cd MathBot_Python
- Install dependencies:
pip install -r requirements.txt
- Environment Setup:
Create a
.env
file in the root directory:
# Development Configuration
ENVIRONMENT=development
TELEGRAM_BOT_TOKEN=your_bot_token_here
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/?retryWrites=true&w=majority
DEEPSEEK_API_KEY=your_deepseek_api_key_here
PORT=8000
LOG_LEVEL=INFO
# Optional: For OCR functionality
GOOGLE_CLOUD_CREDENTIALS_JSON=your_google_cloud_credentials_json_here
-
Create Telegram Bot:
- Message @BotFather on Telegram
- Create a new bot with
/newbot
- Copy the bot token to your
.env
file
-
Setup MongoDB:
- Create a MongoDB Atlas cluster
- Get the connection string
- Add it to your
.env
file
-
Run the bot:
python main.py
For detailed deployment instructions, see DigitalOcean Deployment Guide.
Quick Steps:
- Push code to GitHub
- Create DigitalOcean App
- Connect GitHub repository
- Set environment variables
- Deploy and set webhook
# Build the image
docker build -t mathbot .
# Run the container
docker run -d \
--name mathbot \
-p 8000:8000 \
--env-file .env \
mathbot
Run tests to ensure everything works:
# Run all tests
python -m pytest tests/ -v
# Test specific components
python tests/test_math.py
python tests/test_ai.py
Variable | Required | Description |
---|---|---|
TELEGRAM_BOT_TOKEN |
Yes | Your Telegram bot token |
MONGODB_URI |
Yes | MongoDB connection string |
DEEPSEEK_API_KEY |
Yes | DeepSeek AI API key |
WEBHOOK_URL |
Production | Your app's webhook URL |
WEBHOOK_SECRET |
Recommended | Webhook security token |
GOOGLE_CLOUD_CREDENTIALS_JSON |
Optional | For OCR functionality |
ENVIRONMENT |
No | development or production |
LOG_LEVEL |
No | DEBUG , INFO , WARNING , ERROR |
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Choeng Rayu
- 📧 Email: choengrayu307@gmail.com
- 📱 Telegram: @President_Alein
- 🌐 Website: https://rayuchoeng-profolio-website.netlify.app/
If you encounter any issues:
- Check the troubleshooting guide
- Review the logs in your deployment platform
- Open an issue on GitHub
- Contact the creator via Telegram
Made with ❤️ for the mathematical community