How jolymmiels/remnawave-telegram-shop works
Project type and purpose
• This is a Go-based backend service implementing a Telegram bot (“Remnawave Telegram Shop”) for selling and managing VPN subscriptions via Remnawave.
• It integrates with multiple payment providers (Remnawave API, CryptoPay, YooKassa, Telegram Stars) and PostgreSQL for data persistence.
• It supports scheduled tasks: user-subscription synchronization (/sync admin command) and daily notification dispatch.
File structure
• Top-level:
• cmd/app/main.go — bot entry point
• internal/… — business logic packages (config, handler, database, payment, notification, sync, translation, external clients)
• db/migrations — SQL migrations for PostgreSQL schema
• translations/en.json, ru.json — UI text resources
• Dockerfile & docker-compose.yaml — containerization
• Pattern: single, modular monolith with clear package boundaries.
• Configured via environment variables (.env.sample).
Extract architecture details from README
• Uses pgx driver for PostgreSQL.
• Polls and synchronizes users from Remnawave.
• Sends notifications at 16:00 UTC daily.
• Multi-language support (i18n).
• UI delivered as Telegram inline keyboards.
a. Main components
• Telegram Bot Service (Go monolith)
– Config loader
– Handler layer (Telegram command and callback processing)
– Business modules: payment orchestration, subscription management, translation, notification scheduler, sync service
– Database access (repository layer)
• PostgreSQL Database
• External APIs
– Telegram Bot API
– Remnawave API
– CryptoPay API
– YooKassa API
– (Optional) Telegram Stars payment gateway
b. Relationships and interactions
1. Telegram user ↔ Telegram Bot API ↔ Bot Service
2. Bot Service ↔ PostgreSQL for CRUD on customers, purchases, referrals
3. Bot Service ↔ Remnawave API for plan retrieval & user synchronization
4. Bot Service ↔ CryptoPay / YooKassa for payment initiation & callbacks
5. Cron/ Scheduler inside Bot Service triggers:
– Daily notification module → fetch expiring subs → send messages via Telegram Bot API
– /sync admin command or scheduled sync → fetch users from Remnawave → update DB
c. Architectural patterns & principles
• Modular monolith: internal packages separate concerns
• Repository pattern for database access (internal/database)
• Adapter pattern for each external service client (internal/cryptopay, internal/yookasa, internal/remnawave)
• Scheduler for recurring tasks (internal/notification & internal/sync)
• Configuration via environment variables (12-factor app)
• Internationalization via JSON resource files and translation layer
d. Key technologies & libraries
• Go (modules)
• go-telegram-bot library
• pgx PostgreSQL driver
• Docker & Docker Compose
• External REST APIs (Remnawave, CryptoPay, YooKassa)
• JSON for translation resources
Final recommendations
• Data flows for both user-driven (commands, payments) and system-driven (sync, notifications) paths.
• Decision logic (e.g., language selection, inbound UUID filtering).