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
SecretKeyfor JWT in theappsettings.Development.jsonfile for bothApiGatewayandUserService.Generate a
SecretKeyusing the following PowerShell command:[Convert]::ToBase64String((1..32 | ForEach-Object { (Get-Random -Maximum 256) }))Add the generated
SecretKeyto the following files:src/ApiGateway/appsettings.Development.jsonsrc/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
OrderandUserservices.- 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
notificationservicelogs 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
SecretKeyto multiple projects and installing the same JWT dependencies across multiple microservices.
