A progressive Node.js framework for building efficient and scalable server-side applications.
Nest.js microservices application (users, orders, payments, notifications) with RabbitMQ and Apollo Federation GraphQL API Gateway
I am using pnpm for package management. If you don't have it installed, you can do so with npm:
npm install -g pnpm
Then, install the project's dependencies:
pnpm install
-
Rename
.env.sample
to.env
in each microservice.- If you changed the port in one service, make sure to reflect these changes in other dependent services.
-
Start MongoDB and RabbitMQ in detached mode:
docker compose up -d mongo rabbitmq
-
start the API Gateway which will run the depends services also.
docker compose up gateway
- The
Users
microservice has a hybrid connections - Default URL:
localhost:3040
- Create an account via
POST localhost:3040
- Login via
POST: localhost:3040/login
- Use the
access_token
from login as header in the Gateway - Usages: CURD Actions
- Access the
API Gateway
vialocalhost:3050/graphql
- You must provide the auth header with the
access_token
you get from login- Header:
Authentication: Bearer ${access_token}
- Header:
- You must provide the auth header with the
- Orders first send a request to payments, and after a valid payment, and new order will be created.
- The application uses Stripe as payments infrastructure
- After the payment is completed, the
notifications
service is used to notify the user
The Notifications
service handles email notifications.
Using Grafana and Prometheus for monitoring the microservices.
- Start Grafana with
docker compose up grafana
- Access the Grafana dashboard at
http://localhost:5050
enter admin for username and password.
-
You can modify Prometheus settings such as scraping intervals and targets in the
prometheus.yml
configuration file. -
Grafana configuration, including setting up Prometheus as a datasource and default dashboards, can be found in the
/grafana
directory.
Explore the dedicated Grafana dashboard to monitor the performance and health of the microservices.
- API Gateway (Completed)
- Users Service (Completed)
- Orders Service (In Progress)
- Payments Service (In Progress)
- Notifications Service (In Progress)