How riteshydv777/smm_telegram_bot works
1. This repository is the Spring Boot backend for an SMM automation platform. It acts as the central orchestration layer between a React frontend, a Telegram bot, Razorpay, a MySQL database, and one or more third-party SMM panel APIs.
2. The backend is organized around three main entry surfaces:
- Public/webhook controllers for home and payment callbacks
- Telegram bot runtime for chat-driven order workflows
- Admin REST APIs for dashboards, users, services, orders, and payment reporting
3. The core business data lives in the domain model under model: User, Order, Payment, SmmService, and PendingOrder, plus status enums for orders and payments. These entities represent the main workflow state that moves from user intent, to payment, to fulfillment, to completion.
4. Persistence is handled through Spring Data JPA repositories for users, orders, and services. Architecturally, this is the system-of-record boundary: everything important in the workflow is persisted in MySQL and read back by the admin UI, sync jobs, and bot/payment services.
5. The order/payment flow is anchored by PaymentService, RazorpayWebhookController, PaymentSuccessEvent, and PaymentTelegramNotifier. A payment callback is verified, state is updated, then a domain event is published so downstream handlers can notify Telegram and continue order processing without hard-coupling the webhook to the rest of the workflow.
6. The Telegram bot subsystem is separate from the admin APIs and webhooks. SmmTelegramBot, TelegramBotService, TelegramBotConfig, TelegramBotInitializer, and StartupSync suggest the bot is started and synchronized during application startup, with HelpMessage providing user-facing bot text. This subsystem is responsible for conversational order placement and status interaction.
7. The SMM service fulfillment layer is abstracted behind SmmPanelService and implemented by ElectroSmmService. The service-specific packages for Instagram, YouTube, Telegram, Facebook, and Snapchat indicate the platform routes different service categories through specialized adapters while keeping the order model unified.
8. There is a background synchronization concern as well: OrderStatusSyncService and SmmServiceSyncService imply periodic or on-demand reconciliation between the local database and external panel/provider state. This is important for keeping order and catalog data consistent after payment or external fulfillment changes.
9. The admin subsystem is a separate bounded context under admin/. It exposes controllers for dashboard, orders, payments, services, and users, backed by corresponding services and DTOs. This layer is clearly read/write management UI support rather than user-facing commerce logic.
10. Admin access is protected by a custom security mechanism: AdminSecurityConfig, AdminKeyFilter, and AdminKeyProperties. That indicates the admin API is not using a full session-based admin portal inside this repo, but rather a lightweight key-based gate on top of Spring Security, with CORS configured for a separate frontend origin.
11. Cross-cutting utilities are small but important: PriceCalculator centralizes pricing logic, and ServiceErrorMessages standardizes service validation/feedback. These help keep pricing and user-facing error behavior consistent across bot, admin, and payment paths.
12. From an architecture diagram perspective, the key external boundaries are: Telegram Bot API, Razorpay, MySQL, and external SMM panel/provider APIs. The frontend is separate from this repository and likely consumes the admin REST APIs, while the backend owns orchestration, persistence, payment verification, and fulfillment coordination.
Main entry points: Order.java Domain model · SmmTelegramBotApplication.java Spring Boot app · PaymentService.java Payment service · AdminDashboardController.java Admin API
Components 22
Entry points
External-facing controllers and runtime startup surfaces.
- Spring Boot app · Main application bootstrap for the backend.
src/main/java/com/ritz/smm_telegram_bot/SmmTelegramBotApplication.java - Home API · Basic public/web entry surface.
src/main/java/com/ritz/smm_telegram_bot/controller/HomeController.java - Razorpay webhook · Verifies payment callbacks and triggers workflow updates.
src/main/java/com/ritz/smm_telegram_bot/controller/RazorpayWebhookController.java - Telegram bot · Telegram bot entry for chat-driven order flows.
src/main/java/com/ritz/smm_telegram_bot/bot/SmmTelegramBot.java - Bot startup · Initializes bot runtime and startup sync.
src/main/java/com/ritz/smm_telegram_bot/config/TelegramBotInitializer.java - Telegram config · Bot wiring and runtime configuration.
src/main/java/com/ritz/smm_telegram_bot/config/TelegramBotConfig.java
Core workflow
Shared order, payment, and fulfillment orchestration.
- Payment service · Coordinates payment creation, verification, and order handoff.
src/main/java/com/ritz/smm_telegram_bot/service/PaymentService.java - Payment event · Published after successful payment processing.
src/main/java/com/ritz/smm_telegram_bot/event/PaymentSuccessEvent.java - Telegram notifier · Handles payment success events and notifies Telegram.
src/main/java/com/ritz/smm_telegram_bot/listener/PaymentTelegramNotifier.java - Telegram service · Implements conversational order and status interactions.
src/main/java/com/ritz/smm_telegram_bot/service/TelegramBotService.java - Order sync · Reconciles order status with external fulfillment state.
src/main/java/com/ritz/smm_telegram_bot/service/OrderStatusSyncService.java - Catalog sync · Refreshes SMM service catalog and availability.
src/main/java/com/ritz/smm_telegram_bot/service/SmmServiceSyncService.java - User service · User-oriented application service boundary.
src/main/java/com/ritz/smm_telegram_bot/service/UserService.java
Admin backend
Management APIs, DTOs, and access control for the admin frontend.
- Admin API · Management endpoints for dashboard, users, orders, payments, and services.
src/main/java/com/ritz/smm_telegram_bot/admin/controller/AdminDashboardController.java - Admin security · Key-based admin access gate and CORS configuration.
src/main/java/com/ritz/smm_telegram_bot/admin/security/AdminSecurityConfig.java - Admin services · Admin-side orchestration and DTO-backed management logic.
src/main/java/com/ritz/smm_telegram_bot/admin/service/AdminDashboardService.java
Data model
Persistent domain entities and repository boundary.
- Domain model · Core workflow state for users, orders, payments, and services.
src/main/java/com/ritz/smm_telegram_bot/model/Order.java - Repositories · Spring Data JPA boundary for persisted workflow state.
src/main/java/com/ritz/smm_telegram_bot/repository/OrderRepository.java
External adapters
Provider-specific service adapters and cross-cutting utilities.
- SMM panel · Abstraction for external SMM provider APIs.
src/main/java/com/ritz/smm_telegram_bot/service/SmmPanelService.java - Electro adapter · Concrete SMM panel integration implementation.
src/main/java/com/ritz/smm_telegram_bot/service/ElectroSmmService.java - Provider packs · Platform-specific fulfillment adapters for social networks.
src/main/java/com/ritz/smm_telegram_bot/service/instagram/InstagramService.java - Pricing utils · Central pricing and service error messaging helpers.
src/main/java/com/ritz/smm_telegram_bot/util/PriceCalculator.java
Connections 24
- Spring Boot app → Home API: hosts · Bootstraps the public controller surface.
- Spring Boot app → Razorpay webhook: hosts · Registers payment callback handling.
- Spring Boot app → Telegram bot: starts · Launches the Telegram bot runtime.
- Spring Boot app → Admin API: exposes · Provides admin REST APIs.
- Bot startup → Telegram bot: initializes · Creates and synchronizes the bot during startup.
- Telegram config → Telegram bot: configures · Wires bot runtime dependencies.
- Razorpay webhook → Payment service: delegates · Webhook callback processing is handled by payment workflow logic.
- Payment service → Payment event: publishes · Emits a domain event after successful payment.
- Payment event → Telegram notifier: notifies · Event listener delivers Telegram notification side effects.
- Payment service → Domain model: updates · Payment processing mutates order and payment state.
- Telegram service → Domain model: reads/writes · Bot conversation operates on persisted workflow state.
- Telegram service → User service: uses · Bot workflows depend on user service logic.
- Order sync → Domain model: reconciles · Keeps local order status aligned with fulfillment state.
- Catalog sync → SMM panel: syncs · Catalog synchronization uses the provider abstraction.
- SMM panel → Electro adapter: implemented by · Concrete provider integration backs the abstraction.
- Electro adapter → Provider packs: routes · Provider-specific fulfillment adapters support multiple social platforms.
- Provider packs → Domain model: fulfills · External fulfillment ultimately updates the shared order model.
- Admin API → Admin security: protected by · Admin endpoints are gated by key-based security.
- Admin API → Admin services: uses · Controllers delegate to admin application services.
- Admin services → Repositories: reads · Admin reporting and management query persisted state.
- Repositories → Domain model: persists · Repositories store the core domain entities.
- User service → Repositories: uses · User service relies on repository access.
- Payment service → Pricing utils: uses · Payment and order flows share pricing logic.
- Admin API → Pricing utils: uses · Admin views reuse centralized pricing and validation helpers.