How fawwazs17/makanapa works
Main Components
• Telegram Bot Interface:
• Represented by bot.py, which handles incoming messages/commands from users on Telegram.
• It communicates with the Telegram Bot API (an external service) to both receive customer commands (like /start) and send notifications (especially to the runners' Telegram group using RUNNER_GROUP_ID).
• Database Component:
• Represented by database.py which sets up an SQLite database, and the “data” directory that holds the database file (and possibly other JSON files for order or counter tracking).
• This component is responsible for persistent storage and order management.
• Configuration and Environment:
• An important aspect is the management of environment variables (BOT_TOKEN, RUNNER_GROUP_ID) used to authenticate and configure the Telegram bot.
• The .env.example file (to be copied over to .env) acts as a guideline for required configuration.
• Data/Order Management:
• Files such as data/devlist.json and potentially other JSON files (as mentioned in README like order_counter.json) are used to track orders, counters, or additional runtime data.
Relationships and Interactions between Components
• The Telegram bot (bot.py) is the central point that interacts directly with the Telegram API.
• When a user sends a command, bot.py:
• Validates and processes the command,
• Interacts with the database (SQLite via database.py) to store or retrieve order details,
• And sends notifications to the appropriate Telegram group (using the RUNNER_GROUP_ID).
• Database interactions are primarily CRUD operations for order management.
• The external dependency on Telegram’s API means network requests both ways (incoming messages and outgoing notifications).
Architectural Patterns and Design Principles
• Separation of Concerns:
• The bot’s logic (in bot.py) is separated from the database initialization (in database.py) and persistent data storage (in the “data” directory).
• Configuration Management:
• Environment variables (managed via .env file based on .env.example) clearly decouple sensitive information from the code.
• Data Flow:
• Incoming user interactions via Telegram flow into bot.py,
• Which then interacts with the database layer for storing order data
• And sends notifications back through the Telegram API.
Relevant Technologies, Frameworks, or Libraries
• Python is the core programming language.
• Telegram Bot API is used to integrate with Telegram.
• SQLite serves as the database backend.
• JSON is utilized for order tracking and other data storage in files within the “data” directory.
• The flow starting from a user interacting on Telegram,
• Proceeding to bot.py that processes the request,
• Followed by interactions with SQLite (database.py and “data” folder),
• And finally, showing the response back to Telegram users and the runners’ group.
• This helps in visualizing how the Telegram bot orchestrates all tasks while ensuring each component’s role is clearly defined.