How boriskartofel/caloriesbot works
Calorizator is a Telegram calorie-tracking bot: Telegram updates enter through its webhook, are dispatched to message, command, or callback handlers, and then reach managers that implement the product, calorie, statistics, and timer interactions. Managers persist user and domain state and return Telegram responses. The README establishes the bot’s main capabilities; sampled source shows the webhook, dispatch, handler, manager, and persistence paths. Kafka components are present in the tree, but their full runtime wiring is not shown.
Main entry points: UpdateDispatcher.java Update dispatcher · NotificationManager.java Timer notifications · MainManager.java Main menu · ProductManager.java Product tracking
Components 22
Webhook and dispatch
- Webhook bot
src/main/java/telegram/Calories_Bot/bot/Bot.java - Webhook controller
src/main/java/telegram/Calories_Bot/controller/MainController.java - Update dispatcher
src/main/java/telegram/Calories_Bot/service/UpdateDispatcher.java - Update producer
src/main/java/telegram/Calories_Bot/service/kafka/TelegramBotUpdatesKafkaProducer.java - Kafka updates
- Update consumer
src/main/java/telegram/Calories_Bot/service/kafka/TelegramBotUpdatesKafkaConsumer.java
Bot interactions
- Command handler
src/main/java/telegram/Calories_Bot/service/handler/CommandHandler.java - Message handler
src/main/java/telegram/Calories_Bot/service/handler/MessageHandler.java - Callback handler
src/main/java/telegram/Calories_Bot/service/handler/CallbackQueryHandler.java - Keyboard builder
src/main/java/telegram/Calories_Bot/service/factory/KeyboardFactory.java
Calorie and timer features
- Main menu
src/main/java/telegram/Calories_Bot/service/manager/MainManager.java - Product tracking
src/main/java/telegram/Calories_Bot/service/manager/ProductManager.java - Timer notifications
src/main/java/telegram/Calories_Bot/service/manager/NotificationManager.java - Timer task
src/main/java/telegram/Calories_Bot/service/manager/notification/NotificationRunnableTask.java - Product parser
src/main/java/telegram/Calories_Bot/util/ProductParser.java
Domain persistence
- User repository
src/main/java/telegram/Calories_Bot/repository/UserRepo.java - Product and timer repositories
src/main/java/telegram/Calories_Bot/repository - User state
src/main/java/telegram/Calories_Bot/entity/User.java - Food products
src/main/java/telegram/Calories_Bot/entity/Product.java - Notification state
src/main/java/telegram/Calories_Bot/entity/Notification.java
Other components
- Telegram user
- Telegram API
Connections 32
- Telegram user → Telegram API: sends updates
README.md - Telegram API → Webhook controller: posts webhook
README.md - Webhook controller → Update producer: publishes updates
src/main/java/telegram/Calories_Bot/controller/MainController.java - Update producer → Kafka updates: publishes updates
- Kafka updates → Update consumer: delivers updates
- Update consumer → Update dispatcher: dispatches updates
src/main/java/telegram/Calories_Bot/service/kafka/TelegramBotUpdatesKafkaConsumer.java - Webhook bot → Update dispatcher: dispatches updates
src/main/java/telegram/Calories_Bot/bot/Bot.java - Update dispatcher → User repository: checks and registers
src/main/java/telegram/Calories_Bot/service/UpdateDispatcher.java - Update dispatcher → Command handler: routes commands
src/main/java/telegram/Calories_Bot/service/UpdateDispatcher.java - Update dispatcher → Message handler: routes messages
src/main/java/telegram/Calories_Bot/service/UpdateDispatcher.java - Update dispatcher → Callback handler: routes callbacks
src/main/java/telegram/Calories_Bot/service/UpdateDispatcher.java - Command handler → Main menu: handles commands
src/main/java/telegram/Calories_Bot/service/handler/CommandHandler.java - Message handler → Main menu: delegates messages
src/main/java/telegram/Calories_Bot/service/handler/MessageHandler.java - Message handler → Product tracking: delegates messages
src/main/java/telegram/Calories_Bot/service/handler/MessageHandler.java - Message handler → Timer notifications: delegates messages
src/main/java/telegram/Calories_Bot/service/handler/MessageHandler.java - Callback handler → Main menu: routes callbacks
src/main/java/telegram/Calories_Bot/service/handler/CallbackQueryHandler.java - Callback handler → Product tracking: routes callbacks
src/main/java/telegram/Calories_Bot/service/handler/CallbackQueryHandler.java - Callback handler → Timer notifications: routes callbacks
src/main/java/telegram/Calories_Bot/service/handler/CallbackQueryHandler.java - Main menu → User repository: reads user state
src/main/java/telegram/Calories_Bot/service/manager/MainManager.java - Main menu → Product and timer repositories: cleans draft records
src/main/java/telegram/Calories_Bot/service/manager/MainManager.java - Product tracking → Product and timer repositories: reads and saves
src/main/java/telegram/Calories_Bot/service/manager/ProductManager.java - Timer notifications → Product and timer repositories: reads and saves
src/main/java/telegram/Calories_Bot/service/manager/NotificationManager.java - Timer notifications → Timer task: starts timer
src/main/java/telegram/Calories_Bot/service/manager/NotificationManager.java - Timer notifications → User repository: updates user state
src/main/java/telegram/Calories_Bot/service/manager/NotificationManager.java - Main menu → Keyboard builder: builds menus
src/main/java/telegram/Calories_Bot/service/manager/MainManager.java - Product tracking → Keyboard builder: builds menus
src/main/java/telegram/Calories_Bot/service/manager/ProductManager.java - Timer notifications → Keyboard builder: builds menus
src/main/java/telegram/Calories_Bot/service/manager/NotificationManager.java - User repository → User state: persists
src/main/java/telegram/Calories_Bot/repository/UserRepo.java - Product and timer repositories → Food products: persists products
src/main/java/telegram/Calories_Bot/repository/ProductRepo.java - Product and timer repositories → Notification state: persists timers
src/main/java/telegram/Calories_Bot/repository/NotificationRepo.java - Product tracking → Product parser: parses product data
- Webhook bot → Telegram API: sends responses