This project consists of multiple microservices that communicate using RabbitMQ and are managed through Docker. Follow the steps below to set up and run the project.
- .NET SDK 8 installed.
- Docker installed and running.
- Visual Studio 2022 (optional for running with Visual Studio).
-
Set the JWT Secret Key
You need to set the
SecretKey
for JWT in theappsettings.Development.json
file for bothApiGateway
andUserService
.Generate a
SecretKey
using the following PowerShell command:[Convert]::ToBase64String((1..32 | ForEach-Object { (Get-Random -Maximum 256) }))
Add the generated
SecretKey
to the following files:src/ApiGateway/appsettings.Development.json
src/UserService/UserService.API/appsettings.Development.json
-
Running the Project
You have two options to run the project:
- Open the solution in Visual Studio 2022.
- In the Startup Project dropdown, select
docker-compose
. - Click the play button to start the project.
This will automatically open the Swagger page with the
Order
andUser
services.- Open PowerShell.
- Navigate to the root directory of the project.
- Run the following command:
docker compose -f docker-compose.local.yml up --build -d
- Wait for all the services to stabilize.
Access the Swagger page at: http://localhost:8080/swagger
- ApiGateway: Manages routing and authentication for other services.
- OrderService: Manages orders.
- UserService: Manages user registration and authentication.
- NotificationService: Listens to events from RabbitMQ and processes notifications.
- RabbitMQ: Message broker for event-driven communication between services.
To see the notification service in action, messages are logged to the console with information about the order ID and the user ID when a new order is created. You can view these messages by:
- Opening Docker Desktop.
- Navigating to the
notificationservice
logs to see the messages.
- Validations: Add necessary validations to ensure data integrity.
- Centralized Authentication Service: Configure an independent service for authentication to avoid adding the
SecretKey
to multiple projects and installing the same JWT dependencies across multiple microservices.