https://github.com/amrmuhamedd/ordering-system
Explore a Nest.js microservices app with auth, billing, and orders. Utilizes RabbitMQ for async communication and Docker for easy deployment. Modular, scalable, and efficient.
https://github.com/amrmuhamedd/ordering-system
docker docker-compose docker-image microservices mongodb mongoose nestjs rabbitmq typescript
Last synced: 3 months ago
JSON representation
Explore a Nest.js microservices app with auth, billing, and orders. Utilizes RabbitMQ for async communication and Docker for easy deployment. Modular, scalable, and efficient.
- Host: GitHub
- URL: https://github.com/amrmuhamedd/ordering-system
- Owner: amrmuhamedd
- Created: 2022-10-21T00:11:28.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-04T22:32:08.000Z (almost 3 years ago)
- Last Synced: 2024-12-26T12:15:38.517Z (over 1 year ago)
- Topics: docker, docker-compose, docker-image, microservices, mongodb, mongoose, nestjs, rabbitmq, typescript
- Language: TypeScript
- Homepage:
- Size: 520 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
```markdown
# 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
```
## Running the Application
The application can be run using Docker with the following command:
```bash
# Development
$ docker-compose up --build -V
```
Alternatively, you can run each service individually:
```bash
# Development
$ npm run start:dev
```
## Project Structure
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.
## Design Patterns
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.
## Logic and Interaction
- **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.
## Optimization and Validation
- **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 and Microservices
Docker is utilized to containerize the microservices, ensuring consistent and isolated environments. The `docker-compose.yml` file defines service configurations and dependencies.
## Communication with RabbitMQ
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.
```