# Nest.js Microservices Application with RabbitMQ and Docker
## Description
This project showcases a microservices architecture implemented using Nest.js, with three services: authentication (auth), billing, and orders. The application employs RabbitMQ for asynchronous communication and is containerized using Docker for easy deployment.
## Installation
To set up the application, run the following command:
```bash
$ npm install
The application can be run using Docker with the following command:
# Development
$ docker-compose up --build -V
Alternatively, you can run each service individually:
# Development
$ npm run start:dev
The project follows a modular structure:
src/auth
: Contains controllers, services, DTOs, and other related modules for authentication and authorization.src/billing
: Holds controllers, services, DTOs, etc., for the billing service.src/orders
: Contains modules for handling orders, including controllers, services, DTOs, etc.src/main.ts
: The entry point for the application.
The application employs a microservices architecture, promoting loose coupling and independent development of services. Each service has its own set of controllers, services, and DTOs for handling specific tasks.
-
Authentication Service (auth): Manages user authentication and authorization using JWT tokens.
-
Billing Service: Logs order creation events using asynchronous communication with the Orders Service through RabbitMQ.
-
Orders Service: Allows creating and listing orders. Publishes order creation events to RabbitMQ for the Billing Service.
-
Validation: Data validation is performed using Nest.js's built-in validation features and Data Transfer Objects (DTOs) for input validation and transformation.
-
Optimization: The application employs caching, indexing, and asynchronous processing using RabbitMQ for enhanced performance and responsiveness.
Docker is utilized to containerize the microservices, ensuring consistent and isolated environments. The docker-compose.yml
file defines service configurations and dependencies.
RabbitMQ is employed for asynchronous communication between services. The Orders Service publishes order creation events to a RabbitMQ queue, which the Billing Service consumes, achieving decoupled communication.
This microservices application, built using Nest.js, RabbitMQ, and Docker, demonstrates a modular, scalable, and maintainable architecture that promotes efficient communication and independent development of services.