Skip to content

ivan-hilckov/hello-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

78 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Hello Bot Template πŸš€

Production-ready GitHub template for rapid Telegram bot development with AI-assisted evolution.

A complete, working Telegram bot optimized for AI collaboration with Claude, Cursor, and other coding assistants. Deploy your first bot in minutes, then evolve it into anything you need.

🎯 Why This Template?

  • βœ… AI-Optimized: Designed for collaboration with Claude, Cursor, and ChatGPT
  • βœ… Production Ready: Deploy to VPS with single git push
  • βœ… Simple Architecture: ~320 lines, easy to understand and modify
  • βœ… Resource Efficient: Shared PostgreSQL, optimized for 2GB VPS
  • βœ… Template System: Built-in prompts for systematic bot evolution

πŸš€ Quick Start

1. Use This Template

  • Click "Use this template" β†’ "Create a new repository"
  • Clone your new repository locally

2. Setup Development Environment

Prerequisites: uv (Python package manager)

# Clone your new repository
git clone https://github.com/your-username/your-bot-name
cd your-bot-name

# Setup Python environment
uv sync

# Configure environment
cp .env.example .env
# Edit .env with your bot token from @BotFather

3. Get Bot Token

  • Message @BotFather β†’ /newbot β†’ copy token
  • Add to .env: BOT_TOKEN=your_token_here

4. Start Development

# Start development environment
docker compose -f docker-compose.dev.yml up -d

# View logs  
docker compose -f docker-compose.dev.yml logs -f bot-dev

5. Verify Setup

  • Send /start to your bot β†’ should respond with personalized greeting
  • User record automatically created in PostgreSQL database

πŸ€– AI-Assisted Development

Ready for AI Collaboration

This template is optimized for working with AI coding assistants:

Step 1: Read prompts/START.md - main template for creating new bots
Step 2: Use .cursorrules - Cursor AI context file
Step 3: Reference CLAUDE.md - Claude collaboration guide

AI Collaboration Prompts

Example AI Workflow

1. Use template β†’ customize with prompts/START.md
2. Add features β†’ follow prompts/add_feature.md  
3. Code review β†’ use prompts/analyze_file.md
4. Optimize β†’ apply prompts/simplify_code.md
5. Deploy β†’ git push origin main

Bot Evolution System

  • HB-001: Your first bot from this template
  • HB-002: Evolved version with new features
  • HB-003: Advanced bot with specialized functionality
  • Track genealogy in README for systematic development

Features

  • Simple & Fast: Responds to /start command with user database integration
  • Clean Architecture: Straightforward code structure (~320 lines total)
  • Production Ready: Docker containerization + shared PostgreSQL + automated deployment
  • Resource Optimized: Shared PostgreSQL reduces database memory by 33-60%
  • Auto Deploy: Push to main β†’ automatically deploys to VPS via GitHub Actions

Architecture

Development Mode          Production Mode (Shared PostgreSQL)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Bot polls       β”‚      β”‚ Telegram β†’ Simple   β”‚
β”‚ Telegram API    β”‚      β”‚ Webhook Endpoint    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚                          β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚ aiogram     β”‚
            β”‚ Router      β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚ Simple      β”‚
            β”‚ Handlers    β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚              β”‚              β”‚
β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”      β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”      β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”
β”‚Bot1_DBβ”‚      β”‚Bot2_DBβ”‚      β”‚Bot3_DBβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”˜
    β”‚              β”‚              β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚ Shared PostgreSQL β”‚
         β”‚    (512MB)        β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Technology Stack

Core Dependencies

  • aiogram - Modern async Telegram Bot API framework
  • SQLAlchemy - Async PostgreSQL ORM with type safety
  • FastAPI - High-performance webhook server
  • Pydantic - Data validation and settings management
  • uvicorn - Lightning-fast ASGI server

Development Tools

  • uv - Ultra-fast Python package manager
  • ruff - Extremely fast Python linter and formatter
  • pytest - Testing framework with async support

Infrastructure

Performance Optimizations

  • uvloop - Ultra-fast asyncio event loop
  • asyncpg - High-performance PostgreSQL driver

Full technology reference: docs/TECHNOLOGIES.md

Commands

Command Description
/start Get personalized greeting + save user to database

Documentation

Performance

  • Memory Usage: 128-200MB per bot (shared PostgreSQL optimization)
  • Database Memory: 512MB shared across all bots (33-60% savings)
  • Startup Time: <10 seconds (shared database already running)
  • Response Time: <300ms
  • Deployment Time: ~1-2 minutes (shared infrastructure)

Environment Variables

BOT_TOKEN=your_telegram_bot_token    # Required
DB_PASSWORD=secure_password_123      # Required for production
POSTGRES_ADMIN_PASSWORD=admin_pass   # Required for shared PostgreSQL
ENVIRONMENT=development              # development/production
DEBUG=true                          # true/false
WEBHOOK_URL=https://domain.com/webhook  # Optional for production

πŸ”§ Development Setup

VS Code + Cursor Setup

This template includes optimized settings for AI-assisted development:

Recommended Extensions:

charliermarsh.ruff                    # Python linting/formatting
ms-python.python                     # Python support
anthropic.claude-code                 # Claude AI integration  
anysphere.cursorpyright              # Enhanced Python typing
ms-azuretools.vscode-docker          # Docker support
github.vscode-github-actions         # GitHub Actions support
mikestead.dotenv                     # .env file support
yzhang.markdown-all-in-one           # Markdown editing

Auto-configuration included:

  • .vscode/settings.json - Optimized editor settings
  • .vscode/tasks.json - Pre-configured development tasks
  • .cursorrules - Cursor AI context and instructions

Development Commands

# Environment setup
uv sync                               # Install dependencies

# Development
docker compose -f docker-compose.dev.yml up -d    # Start with hot reload
docker compose -f docker-compose.dev.yml logs -f bot-dev  # View logs

# Code quality  
uv run ruff format .                  # Format code
uv run ruff check . --fix             # Lint and fix issues
uv run pytest tests/ -v               # Run tests

# VS Code tasks (Ctrl+Shift+P β†’ "Tasks: Run Task")
πŸš€ Start Dev Environment             # Clean development startup
πŸ§ͺ Run Tests                         # Execute test suite  
πŸ”§ Format & Lint Code                # Code quality check
βœ… Full Quality Check                 # Complete CI/CD simulation

Local Development Workflow

  1. Setup: uv sync β†’ cp .env.example .env β†’ add bot token
  2. Start: Use VS Code task "πŸš€ Start Dev Environment" or docker compose -f docker-compose.dev.yml up -d
  3. Code: Edit files β†’ auto-reload β†’ test changes immediately
  4. Quality: Use "πŸ”§ Format & Lint Code" task before commits
  5. Deploy: git push origin main β†’ auto-deploy to VPS

License

MIT License

About

Production-ready Telegram bot with PostgreSQL integration and automated CI/CD deployment.

Topics

Resources

Stars

Watchers

Forks

Packages