A lightweight Telegram bot and web interface for tracking personal finances with multi-currency support and timezone awareness.
/in <amount> [note]- Add income (supports shorthand like 10k, 1m)/out <amount> [note]- Add expense/balance- Check current balance/history- View transaction history with pagination/delete [id]- Delete transactions (interactive UI)/summary [period]- Get financial summaries (day/week/month/year/all)/export- Export your data as CSV/import- Import data from CSV/start- Welcome message with web app link
- Responsive design with dark/light theme support
- Real-time balance tracking with income/expense breakdown
- Transaction management - add, view, delete with confirmation
- Financial summaries with monthly/yearly breakdown charts
- User settings - customize currency and timezone
- Mobile-optimized interface perfect for Telegram WebApp
- Multi-currency support - MMK, USD, THB, etc.
- Timezone awareness - Automatic detection and IANA timezone support
- Shorthand amounts - Supports 10k, 1m notation
- Pagination - Navigate through large transaction histories
- Interactive UI - Delete with confirmation modals
- Data export/import - Backup and restore your financial data
- Python 3.8+
- Telegram Bot Token
- Allowed user IDs (for security)
-
Clone the repository
git clone https://github.com/Zenonia-9/MyBalancebot/new/v2.0 cd my-balance -
Install dependencies
pip install -r requirements.txt
-
Configure environment Create
.envfile:BOT_TOKEN=your_telegram_bot_token ALLOWED_USERS=123456789,987654321 DATABASE_URL=data/finance.db WEBHOOK_URL=https://your-domain.com PORT=8443
-
Run the application
python main.py
BOT_TOKEN- Your Telegram bot tokenALLOWED_USERS- Comma-separated list of allowed Telegram user IDsDATABASE_URL- SQLite database path (default:data/finance.db)WEBHOOK_URL- Your Railway/production URL for webhooksPORT- Port number (default: 8443)
Uses SQLite by default (perfect for small-scale usage). The database is automatically created with:
transactionstable for storing income/expense recordsuser_settingstable for currency and timezone preferences
-
Connect your Railway account
railway login railway init
-
Deploy
railway up
- Set up environment variables
- Use
gunicornfor production deployment:gunicorn -w 4 -b 0.0.0.0:8443 main:flask_app
/in 50k Salary
/in 100000 Annual bonus
/out 2k Coffee
/out 50000 Rent
/balance
/history
/summary month
/delete 123- Click "📱 Open App" in Telegram for mobile-friendly access
- Use settings button (⚙️) to customize currency and timezone
- Navigate between Add, History, and Summary tabs
├── main.py # Main Flask application
├── config.py # Configuration and environment variables
├── db.py # Database operations
├── handlers.py # Telegram bot handlers
├── demo.py # Demo data generator
├── requirements.txt # Python dependencies
├── templates/ # HTML templates
├── static/ # CSS/JS files
└── data/ # Database storage
- RAM: ~50-100MB
- Storage: < 10MB
- CPU: Minimal usage
- Bandwidth: < 1GB/month
python-telegram-bot[webhooks]- Telegram bot frameworkflask[async]- Web frameworkgunicorn- Production WSGI servernest_asyncio- Async loop handlingpython-dotenv- Environment variable management
- User whitelisting - Only allowed users can access the bot
- Input validation - Secure amount parsing and validation
- Transaction ownership - Users can only delete their own transactions
- Environment variables - Sensitive data stored securely
- Bot not responding: Check BOT_TOKEN and ALLOWED_USERS
- Database errors: Ensure data/ directory exists and is writable
- Webhook issues: Verify WEBHOOK_URL is accessible and correct
- Permission denied: Check file permissions for database
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is open source and available under the MIT License.
Built with ❤️ for personal finance tracking