Andrew K. Choi 23a9d975a9 feat: Complete API authentication system with email & Telegram support
- Add email/password registration endpoint (/api/v1/auth/register)
- Add JWT token endpoints for Telegram users (/api/v1/auth/token/get, /api/v1/auth/token/refresh-telegram)
- Enhance User model to support both email and Telegram authentication
- Fix JWT token handling: convert sub to string (RFC compliance with PyJWT 2.10.1+)
- Fix bot API calls: filter None values from query parameters
- Fix JWT extraction from Redis: handle both bytes and string returns
- Add public endpoints to JWT middleware: /api/v1/auth/register, /api/v1/auth/token/*
- Update bot commands: /register (one-tap), /link (account linking), /start (options)
- Create complete database schema migration with email auth support
- Remove deprecated version attribute from docker-compose.yml
- Add service dependency: bot waits for web service startup

Features:
- Dual authentication: email/password OR Telegram ID
- JWT tokens with 15-min access + 30-day refresh lifetime
- Redis-based token storage with TTL
- Comprehensive API documentation and integration guides
- Test scripts and Python examples
- Full deployment checklist

Database changes:
- User model: added email, password_hash, email_verified (nullable fields)
- telegram_id now nullable to support email-only users
- Complete schema with families, accounts, categories, transactions, budgets, goals

Status: Production-ready with all tests passing
2025-12-11 21:00:34 +09:00
2025-12-10 22:18:07 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00
2025-12-10 22:09:31 +09:00

Finance Bot

Telegram bot for family finance management built with Python 3.12, aiogram, FastAPI, and PostgreSQL.

Features

  • 👨‍👩‍👧‍👦 Family group management
  • 💰 Income/expense tracking
  • 💳 Multiple accounts (wallets)
  • 📊 Analytics and reports
  • 🎯 Savings goals
  • 💵 Budget management
  • 📱 Telegram bot interface
  • FastAPI REST API (optional)

Project Structure

finance_bot/
├── app/
│   ├── bot/                 # Telegram bot handlers
│   │   ├── handlers/        # Command handlers
│   │   ├── keyboards/       # Keyboard layouts
│   │   └── services/        # Bot services
│   ├── core/                # Core configuration
│   ├── db/                  # Database models & repositories
│   │   ├── models/          # SQLAlchemy models
│   │   └── repositories/    # Data access layer
│   ├── schemas/             # Pydantic schemas
│   ├── services/            # Business logic
│   │   ├── finance/         # Finance operations
│   │   ├── analytics/       # Analytics reports
│   │   └── notifications/   # Notifications
│   └── main.py              # Application entry point
├── migrations/              # Alembic migrations
├── requirements.txt         # Python dependencies
├── docker-compose.yml       # Docker services
├── Dockerfile              # Docker image
└── .env.example            # Environment template

Quick Start

1. Clone and Setup

git clone <repo>
cd finance_bot
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

2. Configure Environment

cp .env.example .env
# Edit .env with your bot token and database settings
docker-compose up -d

This will start:

  • PostgreSQL database
  • Redis cache
  • Telegram bot
  • FastAPI web server

4. Manual Setup (Without Docker)

# Install PostgreSQL and Redis locally

# Create database
createdb finance_db

# Run migrations
alembic upgrade head

# Run bot
python -m app.main

Configuration

Edit .env file:

BOT_TOKEN=your_bot_token_here
DATABASE_URL=postgresql+psycopg2://user:pass@localhost:5432/finance_db
REDIS_URL=redis://localhost:6379/0
APP_ENV=development

Development

Database Migrations

# Create new migration
alembic revision --autogenerate -m "description"

# Apply migrations
alembic upgrade head

# Rollback last migration
alembic downgrade -1

Code Style

# Format code
black app/

# Check linting
pylint app/

# Run tests
pytest tests/

Architecture

  • Clean Architecture: Separated domains, services, repositories
  • SQLAlchemy ORM: Database models and relationships
  • Pydantic Validation: Type-safe schemas
  • Repository Pattern: Data access abstraction
  • Service Layer: Business logic separation
  • aiogram 3.x: Modern async Telegram bot framework

Next Steps

  1. Initialize project structure
  2. Complete database models and repositories
  3. Implement transaction handlers
  4. Add budget and goal management
  5. Create analytics reports
  6. Build notification system
  7. Add FastAPI REST endpoints
  8. Deploy to production

Created: December 10, 2025

Description
No description provided
Readme 312 KiB
Languages
Python 97.1%
Shell 2.8%
Mako 0.1%