This project is a simple example of a microservice architecture using NodeJS and MongoDB. It consists of three services namely:
users
,books
andorders
. Theusers
service is responsible for managing users, thebooks
service is responsible for managing books and theorders
service is responsible for managing orders. The services communicate with each other using HTTP requests.
- 3 different services:
users
,books
andorders
- Each service has its own server and a shared database
- The services communicate with each other using HTTP requests
- Client will interact with the services through the API Gateway
- Users Service:
http://localhost:3001
- Books Service:
http://localhost:3002
- Orders Service:
http://localhost:3003
- API Gateway:
http://localhost:8080
- If client wants to interact with
User Service
, then it has to send request to this endpointhttp://localhost:8080/user/api/{user-service-endpoint-name}
- If client wants to interact with
Book Service
, then it has to send request to this endpointhttp://localhost:8080/book/api/{book-service-endpoint-name}
- If client wants to interact with
Order Service
, then it has to send request to this endpointhttp://localhost:8080/order/api/{order-service-endpoint-name}
- Clone the repository
- Go to respective services and run
npm install
- Run
node start
in each directory to start the services - Go to the
api-gateway
directory and runnpm install
- Run
node start
to start the API Gateway - You can now interact with the services through the API Gateway
- Make sure all your services are up and running