WeatherBotApi is an educational project aimed at learning microservices development on the .NET platform and improving skills in ASP.NET, RabbitMQ, Entity Framework, PostgreSQL, Mapster, Redis, Docker, and xUnit.
WeatherBot is a Telegram bot designed to provide weather data to users. The project is implemented using a microservices architecture, consisting of three services:
- TelegramApi: A service responsible for handling user requests via the Telegram bot.
- DatabaseService: A service responsible for database operations, including storing and retrieving user data and their requests.
- WeatherService: A service responsible for fetching weather information from an external source.
The wttr.in is used to provide weather, which is a console-oriented weather forecast service that supports various information representation methods like terminal-oriented ANSI-sequences for console HTTP clients (curl, httpie, or wget), HTML for web browsers, or PNG for graphical viewers.
The following diagram illustrates the interaction between different services in the project:
flowchart TD;
A[Telegram API] -->|Sends requests| B((RabbitMQ));
B -->|Sends requests| D[Database Service];
D -->|Retrieves data| B;
B -->|Forwards requests| C[Weather Service];
C -->|Retrieves weather data| B;
- ASP.NET
- RabbitMQ (MassTransit can be used, but it provides a high-level API)
- Entity Framework
- PostgreSQL
- Mapster
- Docker
- Redis
- xUnit
- Clone the repository:
git clone https://github.com/shishnk/weather-bot-api.git
- Build Docker containers:
git cd weather-bot-api docker-compose build
- Run containers:
docker-compose up
Before running the project, ensure you have configured the necessary environment variables:
-
Telegram Bot Configuration:
- Create a new bot via BotFather on Telegram.
- Obtain the token for accessing the bot's API.
-
Update the existing .env file:
- Open file in the root directory of your project.
- Add or update the following line in the .env file with your Telegram bot token:
TELEGRAM_BOT_TOKEN=YOUR_TELEGRAM_BOT_TOKEN
- Replace
YOUR_TELEGRAM_BOT_TOKEN
with your actual Telegram bot token obtained from BotFather.
Once you have updated the existing .env file with your Telegram bot token, you are ready to run the project.
If you have suggestions for improving the project or found a bug, please open an issue or submit a pull request. We welcome your contributions!
The project is licensed under the MIT license. For more information, see the LICENSE.