This project demonstrates a microservice architecture with two services: product-service
and order-service
. Each service is built using NestJS and communicates with a PostgreSQL database. The services are containerized using Docker and orchestrated with Docker Compose.
- GET /products/all: Retrieve all products.
- GET /products/:id: Retrieve a single product by ID.
- POST /products/new: Create a new product.
- PUT /products/:id: Update an existing product.
- DELETE /products/:id: Delete a product.
- POST /products/decrease-quantity: Decrease the quantity of a product.
- GET /orders/all: Retrieve all orders.
- GET /orders/:id: Retrieve a single order by ID.
- POST /orders/new: Place a new order.
-
Clone the repository:
git clone https://github.com/yourusername/microservice-demo.git cd microservice-demo
-
Build the Docker images:
docker-compose up -d
-
Check that the databases created on pgadmin:
- Open your browser and go to
http://localhost:8080
- Login with the following credentials:
- Email:
[email protected]
- Password:
admin
- Email:
- Add a new server with the following details:
- Name:
products
ororders
- Host name/address:
product-db
ororder-db
- Port:
5432
- Maintainance database:
productdb
ororderdb
- Username:
postgres
- Password:
1
- Name:
- Click
Save
- Open your browser and go to
-
Setting up Postman for API invocations:
- Import the Postman collection from
postman
folder. - Update the environment variables with the correct values:
base_url
:http://localhost:8081
(for api-gateway)token
:leave empty
(for now)
- In the Authentication Folder invoke the Generate Token request to update the token value automatically.
- Import the Postman collection from
-
Happy Coding!