
WeatherBotApi
Overview
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.
Description
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.
Weather API
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.
Architecture
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;
Technology Stack
- ASP.NET
- RabbitMQ (MassTransit can be used, but it provides a high-level API)
- Entity Framework
- PostgreSQL
- Mapster
- Docker
- Redis
- xUnit
Installation and Running
- 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
Configuration
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:
Once you have updated the existing .env file with your Telegram bot token, you are ready to run the project.
Contribution and Feedback
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!
License
The project is licensed under the MIT license. For more information, see the LICENSE.
评论