How mrdiz2112/gamebot works
Main Components
• Telegram Bot Interface: At the core is the Telegram bot built using the Grammy framework. This endpoint receives Telegram commands (/start, /help, /add, etc.) and channel inputs for notifications.
• Bot Handlers: Under src/bot/handlers you have different command and message handlers (e.g., BasicCommandHandler, GameCommandHandler, PartyCommandHandler, etc.) that process incoming messages and dispatch them to appropriate services.
• Services Layer: In src/services you have services like GameService, NotificationService along with parsers (e.g., SteamParser) to process game information.
• Database Integration: Prisma is used as the ORM to interact with a PostgreSQL database (see prisma/schema.prisma). The services will connect to the database via the Prisma client.
• Utility Modules & Logger: The project uses utilities such as the logger (src/utils/logger.ts) powered by Winston for logging and error tracking.
• Deployment/Containerization: Docker-related files (Dockerfile, docker-compose files) and environment scripts show that the application is containerized for both development and production.
• Configuration: Environment files (.env, .env.example) ensure proper configuration of sensitive keys (bot token and database URL).
Relationships/Interactions
• Telegram Bot Framework receives requests → dispatches the request to relevant bot handlers.
• Bot Handlers call the services (GameService, NotificationService) to execute business logic.
• Services interact with the database using Prisma to store and retrieve game data (prices, categories, tracking info).
• A specific parser (SteamParser) is used in the context of game addition and price scraping; it parses data from external sources (Steam) and feeds it into the services.
• Notification Service is responsible for compiling and sending notifications back to Telegram groups or topics.
• The utility Logger provides application-wide logging and can be depicted as an overlay used by all components.
• Deployment components (Dockerfile, docker-compose configurations) should be shown outside the core business logic to indicate deployment environments (development vs. production).
Architectural Patterns and Design Principles
• Modularization: The project has a clear separation between message handling, business logic (services), and persistence (database interactions via Prisma).
• Event-Driven/Command-Based Design: The bot responds to various Telegram commands that trigger corresponding event handlers and service calls.
• Containerization: Using Docker and multiple compose files to delineate development vs. production setup.