Skip to content

Nest.js microservices (users, orders, payments, notifications) with RabbitMQ and Apollo Federation GraphQL API Gateway.

Notifications You must be signed in to change notification settings

BekYahia/nestjs-microservices-app

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

Nestjs Microservices APP

Nest.js microservices application (users, orders, payments, notifications) with RabbitMQ and Apollo Federation GraphQL API Gateway

Table of Contents

Installation

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

Running the app

  1. 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.
  2. Start MongoDB and RabbitMQ in detached mode:

    docker compose up -d mongo rabbitmq
  3. start the API Gateway which will run the depends services also.

    docker compose up gateway

Overview

Users

  • 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

API Gateway

  • Access the API Gateway via localhost:3050/graphql
    • You must provide the auth header with the access_token you get from login
      • Header: Authentication: Bearer ${access_token}

Orders

  • Orders first send a request to payments, and after a valid payment, and new order will be created.

Payments

  • The application uses Stripe as payments infrastructure
  • After the payment is completed, the notifications service is used to notify the user

Notifications

The Notifications service handles email notifications.

Monitoring

Using Grafana and Prometheus for monitoring the microservices.

Accessing Metrics

  1. Start Grafana with
    docker compose up grafana
  2. 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.

Grafana Dashboard

Explore the dedicated Grafana dashboard to monitor the performance and health of the microservices.

Project Progress

  • API Gateway (Completed)
  • Users Service (Completed)
  • Orders Service (In Progress)
  • Payments Service (In Progress)
  • Notifications Service (In Progress)

About

Nest.js microservices (users, orders, payments, notifications) with RabbitMQ and Apollo Federation GraphQL API Gateway.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published