hienngm / nestjs-scalable-chat-app

This repository serves as an illustrative example for developing a scalable chat application using NestJS. The architecture of this application is specifically designed to efficiently handle a high volume of users while ensuring high performance for real-time messaging.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nest Logo

Scalable Chat Application in NestJS 🐈

Description

This repository serves as an illustrative example for developing a scalable chat application using NestJS. The architecture of this application is specifically designed to efficiently handle a high volume of users while ensuring high performance for real-time messaging.

Check out my article "Designing a Highly Scalable Chat Application for Handling High User Loads in NestJS" for a detailed explanation.

Tech Stack:

nestjs       graphql       socket.io       mongodb       redis       nginx       docker

What enables scalability in my design?

  • The application maintains correct functionality even when horizontally scaling out multiple instances.
  • The application efficiently delivers messages or events only to the relevant instances, avoiding unnecessary invocations and optimizing resource usage and performance.
  • The application architecture is designed with loose coupling between services, leveraging the Dependency Inversion Principle in NestJS. This allows for easy decomposition into microservices with minimal effort.
  • Additionally, by implementing the "Clean architecture", the application becomes framework-independent. For example, it allows for effortless transition between databases, such as migrating from MongoDB to PostgreSQL, without requiring modifications to the core entity and business logic.

All of these aspects are discussed in detail in my article available here.

Installation

Follow the steps below to install and set up the project:

  1. Clone the repository:

    git clone https://github.com/hienngm/nestjs-scalable-chat-app
    
  2. Copy the environment file:

    cp sample.env .env
    
  3. Start the containers:

    npm run dc up
    
  4. Initialize the database (only needed once):

    npm run dc-create-testing-data
    

If you want to clean the project, run the following command:

npm run dc-clean

Contributing

Feel free to reach out if you have any ideas, comments, or questions.

Best regards,

Hien Nguyen Minh

Contact

License

This project is licensed under the MIT License.

About

This repository serves as an illustrative example for developing a scalable chat application using NestJS. The architecture of this application is specifically designed to efficiently handle a high volume of users while ensuring high performance for real-time messaging.


Languages

Language:TypeScript 98.5%Language:JavaScript 1.2%Language:Dockerfile 0.3%