A personal finance application that provides a CLI-like interface through Telegram for recording and managing expenses with automatic Google Sheets synchronization.
- 💬 Record expenses through Telegram commands
- 📊 Automatic synchronization to Google Sheets
- 🏷️ Custom category management with inline keyboard selection
- 💾 Local persistence with sync retry logic
- 🔒 Single-user authorization
- 📱 Quick expense entry without leaving Telegram
telegram-expense-tracker/
├── src/ # Source code
│ ├── models.py # Data models (Expense, Category, UserConfig)
│ ├── storage.py # Local storage implementation
│ ├── core.py # Business logic (ExpenseTrackerCore)
│ ├── sync.py # Google Sheets sync service
│ └── bot.py # Telegram bot handler
├── tests/
│ ├── unit/ # Unit tests
│ ├── property/ # Property-based tests
│ └── integration/ # Integration tests
├── requirements.txt # Python dependencies
├── .env.example # Environment variables template
└── main.py # Application entry point
# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activatepip install -r requirements.txt# Copy the example environment file
cp .env.example .env
# Edit .env and add your configuration:
# - TELEGRAM_BOT_TOKEN: Get from @BotFather on Telegram
# - GOOGLE_CREDENTIALS_PATH: Path to your Google service account JSON
# - AUTHORIZED_USER_ID: Your Telegram user ID- Go to Google Cloud Console
- Create a new project or select existing one
- Enable Google Sheets API
- Create a service account and download credentials JSON
- Save credentials as
credentials.jsonin project root - Share your Google Sheet with the service account email
python main.py/expense <amount> <description> [category]or/e- Add new expense/addcat <category_name>or/ac- Add new category/categoriesor/cats- List all categories/delcat <category_name>or/dc- Delete category/list- Show recent expenses (last 10)/list <YYYY-MM-DD>- Show expenses for specific date/delete <expense_id>or/del- Delete expense/config <sheet_link>- Configure Google Sheet/helpor/start- Show help message
/e 25.50 Lunch Food
/expense 100 Groceries
/ac Transportation
/list
/list 2024-01-15
/del expense-id-123
# Run all tests
pytest
# Run unit tests only
pytest tests/unit/
# Run property-based tests only
pytest tests/property/
# Run with coverage
pytest --cov=src --cov-report=htmlProperty-based tests use Hypothesis and run 100 iterations by default:
pytest tests/property/ -v- Python 3.8+
- Telegram Bot Token
- Google Sheets API credentials
- Active internet connection for sync
MIT License