Skip to content

Evgen-dev1989/e-commerce-telegram_bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

57 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– E-Commerce Telegram Bot

Python aiogram Docker PostgreSQL

A comprehensive Telegram bot for tracking luxury watch prices from premium brands including Omega, Rolex, and Jaeger-LeCoultre. The bot provides real-time price monitoring, multilingual support, and personalized watch lists with automated notifications.

๐ŸŒŸ Features

Core Functionality

  • ๐Ÿ” Real-time Price Tracking - Monitor prices across multiple luxury watch brands
  • ๐ŸŒ Multilingual Support - Available in English, Russian, Ukrainian, and Polish
  • ๐Ÿ“ฑ Interactive Interface - Intuitive inline keyboards and user-friendly navigation
  • ๐Ÿ’พ Personal Watch Lists - Save favorite watches and track their price changes
  • ๐Ÿ”” Automated Notifications - Get notified when prices change or new models are available
  • ๐ŸŽฏ Advanced Filtering - Filter watches by price range, brand, and availability

Supported Brands

  • Omega - Complete collection with real-time pricing
  • Rolex - Premium watches with availability tracking
  • Jaeger-LeCoultre - Luxury timepieces with detailed specifications

๐Ÿ›  Technology Stack

Backend

  • Python 3.12 - Core programming language
  • aiogram 3.21.0 - Modern Telegram Bot API framework
  • asyncio - Asynchronous programming for high performance
  • asyncpg 0.30.0 - PostgreSQL async driver

Web Scraping

  • Selenium WebDriver 4.15.0 - Browser automation
  • undetected-chromedriver 3.5.0 - Anti-detection Chrome driver
  • lxml 5.3.0 - XML/HTML processing
  • requests 2.32.0 - HTTP library for API calls

Database

  • PostgreSQL 13 - Primary database
  • asyncpg - Async PostgreSQL adapter
  • psycopg2 2.9.9 - PostgreSQL adapter

DevOps & Deployment

  • Docker - Containerization
  • docker-compose - Multi-container orchestration
  • Chrome Headless - Browser automation in containers

Additional Libraries

  • python-dotenv 1.0.0 - Environment variable management

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.12+
  • Docker & Docker Compose
  • Telegram Bot Token (from @BotFather)
  • PostgreSQL (or use Docker Compose)

1. Clone Repository

git clone https://github.com/Evgen-dev1989/e-commerce-telegram_bot.git
cd e-commerce-telegram_bot

2. Environment Setup

Create a .env file in the project root:

# Telegram Bot Configuration
token=YOUR_TELEGRAM_BOT_TOKEN

# Database Configuration
user=postgres
password=your_secure_password
database=telegram_bot
host=localhost
port=5432

3. Docker Deployment (Recommended)

# Build and start all services
docker-compose up -d

# Check logs
docker-compose logs -f bot

4. Manual Installation

# Install dependencies
pip install -r requirements.txt

# Run database migrations (ensure PostgreSQL is running)
python main.py

๐Ÿ“‹ Installation Details

System Requirements

  • RAM: Minimum 2GB (4GB recommended)
  • Storage: 1GB free space
  • Network: Stable internet connection for web scraping

Docker Configuration

The application uses a multi-stage Docker setup:

  • Base Image: python:3.12-slim
  • Chrome Installation: Google Chrome Stable + ChromeDriver
  • Security: Non-root user execution
  • Health Checks: PostgreSQL connection validation

Database Schema

-- Users table
CREATE TABLE users (
    user_id BIGINT PRIMARY KEY,
    username VARCHAR(255),
    language VARCHAR(5) DEFAULT 'en',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- Watches table
CREATE TABLE watches (
    id SERIAL PRIMARY KEY,
    brand VARCHAR(100) NOT NULL,
    model VARCHAR(255) NOT NULL,
    price DECIMAL(10,2),
    url TEXT,
    user_id BIGINT REFERENCES users(user_id),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

๐ŸŽฎ Bot Commands

Basic Commands

  • /start - Initialize bot and select language
  • /help - Show available commands and features
  • /language - Change interface language

Watch Management

  • Browse Watches - View available watches by brand
  • Add to Favorites - Save watches to personal list
  • Price Alerts - Set up price change notifications
  • Search Filters - Filter by price range and availability

๐ŸŒ Multilingual Support

The bot supports 4 languages with complete localization:

Language Code Coverage
English en 100%
Russian ru 100%
Ukrainian uk 100%
Polish pl 100%

Language Features

  • Dynamic Switching - Change language anytime
  • Persistent Settings - Language preference saved per user
  • Complete Localization - All messages, buttons, and notifications
  • Cultural Adaptation - Currency and date formats

๐Ÿ”ง Configuration

Environment Variables

# Required
token=your_telegram_bot_token
user=database_username
password=database_password
database=database_name
host=database_host
port=database_port

# Optional
DEBUG=true
LOG_LEVEL=INFO
SCRAPING_INTERVAL=3600  # seconds

Scraping Configuration

  • Request Delay: 2-5 seconds between requests
  • Anti-Detection: Randomized user agents and headers
  • Error Handling: Automatic retry with exponential backoff
  • Rate Limiting: Respectful scraping practices

๐Ÿ“Š Architecture

Application Structure

โ”œโ”€โ”€ main.py              # Core bot application
โ”œโ”€โ”€ words.py             # Multilingual support
โ”œโ”€โ”€ config.py            # Configuration management
โ”œโ”€โ”€ requirements.txt     # Python dependencies
โ”œโ”€โ”€ Dockerfile          # Container configuration
โ”œโ”€โ”€ docker-compose.yml  # Multi-service setup
โ””โ”€โ”€ .env               # Environment variables

Design Patterns

  • FSM (Finite State Machine) - User interaction flow
  • MVC Pattern - Separation of concerns
  • Async/Await - Non-blocking operations
  • Factory Pattern - Dynamic scraper selection

Performance Features

  • Connection Pooling - Database connection optimization
  • Async Operations - Concurrent request handling
  • Caching - In-memory price data caching
  • Background Tasks - Scheduled price monitoring

๐Ÿ›ก Security Features

Data Protection

  • Environment Variables - Sensitive data protection
  • SQL Injection Prevention - Parameterized queries
  • Input Validation - User input sanitization
  • Secure Headers - HTTP security headers

Operational Security

  • Non-root Containers - Docker security best practices
  • Network Isolation - Container networking
  • Log Sanitization - No sensitive data in logs
  • Regular Updates - Dependency security updates

๐Ÿ“ˆ Monitoring & Logging

Logging Configuration

logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    handlers=[
        logging.FileHandler('bot.log'),
        logging.StreamHandler()
    ]
)

Health Checks

  • Database Connectivity - PostgreSQL health monitoring
  • Bot Status - Telegram API connection status
  • Scraping Health - Website availability checks
  • Container Health - Docker health checks

๐Ÿค Contributing

Development Setup

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Install development dependencies: pip install -r requirements-dev.txt
  4. Run tests: pytest tests/
  5. Submit a pull request

Code Standards

  • PEP 8 - Python style guide compliance
  • Type Hints - Full type annotation
  • Docstrings - Comprehensive documentation
  • Testing - Unit and integration tests

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • aiogram community - Excellent Telegram Bot framework
  • Selenium maintainers - Reliable web automation
  • PostgreSQL team - Robust database system
  • Docker community - Containerization platform

๐Ÿ“ž Support

๐Ÿ”„ Changelog

Version 1.0.0 (Current)

  • โœ… Initial release with full functionality
  • โœ… Multi-brand watch tracking
  • โœ… Multilingual support (4 languages)
  • โœ… Docker containerization
  • โœ… PostgreSQL integration
  • โœ… Automated price monitoring

Made with โค๏ธ by Evgen-dev1989

About

telegram bot for price tracking

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors