More Premium Hugo Themes Premium React Themes

Mern Multitenancy

multi-tenant MERN architecture

Mern Multitenancy

multi-tenant MERN architecture

Author Avatar Theme by aliakseiherman
Github Stars Github Stars: 25
Last Commit Last Commit: Mar 21, 2021 -
First Commit Created: Jun 19, 2023 -
Mern Multitenancy screenshot

Overview

The MERN Multitenancy is a software framework that utilizes a multi-layered architecture for building scalable web applications. It is built on the MERN stack (MongoDB, Express, React, Node.js) and supports multitenancy, allowing multiple tenants (users or organizations) to use the application simultaneously with their own isolated data.

Features

  • Multi-layered architecture: The application follows a structured architecture with layers including app, router, controller, and service, making it easy to manage and develop.
  • TypeScript: The back-end of the application is written in TypeScript, providing type checking and enhancing code quality.
  • Subdomain-based tenant resolution: Tenants are resolved based on the subdomain of the requested URL, ensuring isolation and security.
  • MongoDB with per-tenant collections: Each tenant has its own collection in the MongoDB database, providing data segregation and efficiency.
  • JWT authentication: JSON Web Tokens (JWT) are used for authentication, ensuring secure communication between the client and server.
  • CORS and domain whitelisting: Cross-Origin Resource Sharing (CORS) is implemented with a whitelist of allowed domains, enhancing security.
  • Password hashing with salt and pepper: User passwords are securely hashed using a combination of salt and pepper techniques for added protection.
  • User and tenant data binding: User and tenant identifiers (userId and tenantId) are bound to the Request object, simplifying data retrieval and manipulation.

Installation

To install the MERN Multitenancy framework, follow these steps:

  1. Add the necessary entries to your hosts file to map subdomains to your local machine.
  2. Run the back-end and front-end applications using the npm start or yarn start command.
  3. Use the front-end interface to perform basic login and sign up functionality.
  4. The application will enforce tenant isolation, ensuring that the records created are only available for the current tenant (subdomain).

Summary

The MERN Multitenancy framework provides a robust solution for building scalable web applications with multitenancy support. With its multi-layered architecture, TypeScript-powered back-end, subdomain-based tenant resolution, and MongoDB’s per-tenant collections, it offers a secure and efficient way to handle multiple tenants. The use of JWT authentication, CORS with domain whitelisting, and password hashing with salt and pepper further enhance security. Overall, this framework simplifies the development and management of multitenant web applications.