# 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 ```bash git clone cd finance_bot python -m venv .venv source .venv/bin/activate pip install -r requirements.txt ``` ### 2. Configure Environment ```bash cp .env.example .env # Edit .env with your bot token and database settings ``` ### 3. Using Docker Compose (Recommended) ```bash docker-compose up -d ``` This will start: - PostgreSQL database - Redis cache - Telegram bot - FastAPI web server ### 4. Manual Setup (Without Docker) ```bash # 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 ```bash # Create new migration alembic revision --autogenerate -m "description" # Apply migrations alembic upgrade head # Rollback last migration alembic downgrade -1 ``` ### Code Style ```bash # 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