This is an example of a very simplified ordering system made in a microservice architecture using .NET 5
This project consists of following partitions
- AppGateway
- CustomerService.Api
- CustomerService.Application
- CustomerService.Test
- OrderService.Api
- OrderService.Application
- OrderService.Test
AppGateway is a microservice that responsible for communication with other services.
This service includes:
- Ocelot is used for Gateway implementation
- Containerization
Endpoint | Allowed Methods | Description |
---|---|---|
/customers | Post, Put, Get, Delete | Customer microservice |
/orders | Post, Put, Get, Delete | Order microservice |
Customer microservice that responsible for basic CRUD implementations over Customer Entity.
This service includes:
- .NET 5 Web Api implementation
- REST API Principles, CRUD operations
- PostgreSQL as Database Provider
- Repository Pattern implementation
- Containerization
Endpoint | Method | Description |
---|---|---|
/api/Customer | Get | List all customers |
/api/Customer/{id} | Get | Get customer |
/api/Customer | Post | Insert customer |
/api/Customer/{id} | Put | Update customer |
/api/Customer/{id} | Delete | Delete customer |
Order microservice that responsible for basic CRUD implementations over Order Entity.
This service includes:
- .NET 5 Web Api implementation
- REST API Principles, CRUD operations
- PostgreSQL as Database Provider
- Repository Pattern implementation
- Containerization
Endpoint | Method | Description |
---|---|---|
/api/Order | Get | List all orders |
/api/Order/{id} | Get | Get order |
/api/Order | Post | Insert order |
/api/Order/{id} | Put | Update order |
/api/Order/{id} | Delete | Delete order |
/api/Order/{id}/change-status | Put | Update order status |
You will need the following tools:
Follow these steps to get your development environment set up: (Before Run Start the Docker Desktop)
- Clone the repository
- (Optional) If you want, you can limit the Wsl2's memory and cpu usage. (see also)
- Go to User's Document Folder ( Press "WinKey + R" and run "%UserProfile%" )
- Create a file named .wslconfig
- Write its content as follows (Windows restart may be required)
[wsl2]
memory=8GB
processors=2
swap=0
localhostForwarding=true
- At the root directory which include docker-compose.yml and docker-compose.override.yml files, run below command:
docker-compose -f docker-compose.yml -f docker-compose.override.yml up
-
Wait for docker compose all microservices.
-
You can launch microservices as below urls:
- Gateway -> http://localhost:5000
- Customer Microservice -> http://localhost:5002
- Order Microservice -> http://localhost:5004
- pgAdmin PostgreSQL -> http://localhost:5050 -- admin@admin.com / admin
If you want to use the API with Postman, click below link.
To run unit tests, you have to run microservices with test environment. We will also use Docker for unit tests.
- At the root directory which include docker-compose-tests.yml and docker-compose-tests.override.yml files, run below command:
docker-compose -f docker-compose-tests.yml -f docker-compose-tests.override.yml up
- Wait for docker compose all microservices.
- From the Test menu item, run the all tests.
- Open the Test Explorer window, and notice the results of the tests.