How anoldyouth/java-telegram-notifications works
Main Components
• Bot Application:
• Located under the “bot” module.
• Contains Spring Boot configuration (ApplicationConfig, BotConfiguration, ScenariosConfiguration).
• Implements various command actions (StartAction, HelpAction, etc.), a dispatcher for scenarios, and response classes that produce Telegram messages.
• Contains unit and integration tests, ensuring proper behavior.
• Scrapper Application:
• Located under the “scrapper” module.
• Contains application configuration classes and client integrations for external APIs (GitHubClient for GitHub and StackOverflowClient for StackOverflow).
• Implements a scheduler service (LinkUpdaterScheduler) to periodically fetch and update link data.
• Uses DTOs for requests and responses that map to external API data.
• Database (PostgreSQL):
• The README mentions a required PostgreSQL database which acts as a storage layer for link tracking data or for caching events.
• Optional Kafka:
• There is a dependency note on Kafka. If enabled, Kafka can serve as a messaging bus, for instance, between the scrapper and bot components, to relay update events asynchronously.
• External Systems:
• Telegram: for sending notifications from the Bot application.
• GitHub and StackOverflow APIs: called by the Scrapper application to monitor link events.
Relationships and Interactions
• The Scrapper periodically calls external APIs (GitHub and StackOverflow) to fetch updates based on the configured links.
• Upon detecting a new event/update, the Scrapper may update the PostgreSQL database and, optionally, publish events on Kafka.
• The Bot application, which likely monitors updates (either directly by polling the database or by consuming Kafka messages), processes incoming commands (via the various Action classes) and sends notification responses to Telegram.
• There is an integration between the two applications either through shared database state or messaging, enabling coordinated operations in tracking and alerting.
Architectural Patterns and Design Principles
• Modular Architecture:
• Both subsystems (Bot and Scrapper) are built as independent Spring Boot modules, each with well-defined responsibilities.
• Separation of Concerns:
• Configuration, service, client integration, and utility logic are neatly separated.
• Use of Scheduler (in Scrapper) for periodic tasks.
• Strong emphasis on event-based operation (using Kafka optionally) for decoupled communication if needed.
• MVC-like structure inside each module (with controllers/services, even if not strictly MVC in the code structure).
• Extensive unit testing supports reliability and maintainability.