How mrandrew30/linksgenerator works
Project type and purpose
• This is a lightweight, full-stack “microservice” style application—a Telegram bot (“LinksGenerator”) written in Python.
• Purpose: accept commands from Telegram users, generate and track short links via external services (Google Sheets as a storage layer, VK API for link generation), and return results to the user.
File structure
• Top-level:
• Dockerfile, docker-compose.yml, .env_example − containerization and env-config
• data/ − local data or persistent volume (currently empty)
• links_generator/ − Python package containing business logic
• docs/ − Sphinx documentation
• requirements.txt, setup.py − packaging & dependencies
• Inside links_generator/:
• main.py − entrypoint (initializes bot, dispatches commands)
• handler_commands.py − maps Telegram commands to business actions
• databases/databases.py − abstraction for storage (currently Google Sheets)
• googletables/worktables.py − wrapper around Google Sheets API
• vk_api/vk_api.py − wrapper around VK short-link API
README for additional insights
• Lists tech integrations: Telegram Bot API, Google Sheets API, optional Google Drive API, VK API.
• Describes process to obtain credentials.json (Google service account) and VK service access key.
• Shows how to build & run via Docker Compose.
Main components & interactions
a. Components
1. “Telegram Bot” container (Docker service)
2. Telegram Bot API (external service/“cloud”)
3. Business Logic Layer
• HandlerCommands
• LinkGenerator core modules
4. Storage Layer
• Google Sheets (via Google Sheets API)
• Optional fallback: local data volume (data/)
5. External Link Service
• VK API (via vk_api module)
6. Environment & Config
• .env (Telegram token, spreadsheet ID, VK key, etc.)
b. Data flows & relationships
• Telegram client → Telegram Bot container (receives updates)
• Bot container → HandlerCommands → Business Logic
• Logic → Storage Layer (read/write via Google Sheets API)
• Logic → VK API (request short-link)
• VK API & Storage responses → Handler → Bot container → Telegram API (respond to user)
c. Architectural patterns & design principles
• Separation of concerns: command handling, business logic, external API wrappers
• Adapter/Wrappers: modules abstract over Google Sheets & VK API
• Configuration via environment variables for portability
• Container-based deployment (Docker + Docker Compose)
d. Technologies & frameworks
• Python 3.x
• python-telegram-bot (or built-in Telegram Bot API)
• google-api-python-client (Google Sheets/Drive)
• vk-api or custom VK API wrapper
• Docker, Docker Compose