Project Description:
It is necessary to develop a Telegram bot for generating SEO texts for the Trast.ua website. The bot should accept a category or product URL, generate SEO text using the OpenAI API, and save the result in the database.
Main Requirements:
1. **Technology Stack**:
- Python 3.10
- Aiogram for Telegram bot
- Quart for the web server
- SQLite for the database
- Aiohttp for asynchronous HTTP requests
- BeautifulSoup4 for HTML parsing
- Pytest for writing tests
2. **Functional Requirements**:
- **Command /start**: Sending a welcome message with the "START" button.
- **Button "START"**: When pressed, the bot should request a category or product URL.
- **URL Processing**: The bot should accept the URL, check its validity, and generate SEO text using the OpenAI API.
- **Saving SEO Text**: The bot should save the generated SEO text in the database.
- **Sending SEO Text**: The bot should send the generated SEO text to the user.
3. **Non-functional Requirements**:
- **Performance**: The bot should process requests and generate SEO texts within 5 seconds.
- **Testing**: All core functions must be covered by tests using Pytest.
- **Documentation**: All code must be well-documented and accompanied by instructions for setup and configuration.
#### Task Details:
1. **Telegram Bot Development**:
- Setting up Aiogram.
- Implementing the `/start` command.
- Handling the "START" button press.
- Handling messages with URLs.
- Generating SEO text using the OpenAI API.
- Sending the generated text to the user.
2. **Web Server Development**:
- Setting up Quart.
- Implementing the `/generate` route for generating SEO text based on URL.
3. **Database Management**:
- Setting up SQLite.
- Creating tables to store categories and products.
- Functions for saving and retrieving data from the database.
4. **Testing**:
- Writing tests for core bot functions.
- Testing SEO text generation.
- Testing database operations.
5. **Documentation**:
- Installation and setup instructions.
- Instructions for running the bot and web server.
- Description of the database structure.
#### Project Structure Example:
```
project/
│
├── app.py # Quart application file
├── bot.py # Telegram bot file
├── db_manager.py # Database management
├── seo_generator.py # SEO text generation
├── config.py # Configuration parameters
├── gunicorn_conf.py # Gunicorn configuration
│
├── tests/ # Test folder
│ ├── test_app.py
│ ├── test_bot.py
│ ├── test_db_manager.py
│ └── test_seo_generator.py
│
├── requirements.txt # Project dependencies
├── wsgi.py # File for running the application
└── pytest.ini # Pytest configuration
```
#### Expected Results:
- Functional Telegram bot meeting the requirements.
- Quart web server handling requests for generating SEO texts.
- Properly functioning database.
- Comprehensive test coverage of core functions.
- Detailed project documentation.
If you have any questions or need clarification, please contact