Skip to content

This project is a Poc implementing the separate schema multitenancy with spring boot and postgres

Notifications You must be signed in to change notification settings

Cherni-Oussama/Spring-boot-multitenancy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Separate schema multi-tenancy using spring boot POC

Context

Multitenancy refers to the ability of a software application or system to host multiple independent tenants or organizations, with each tenant having the ability to customize or configure the application or system to meet their specific needs.

In a multitenant application or system, each tenant is typically isolated from the others, with their own separate data, configurations, and customizations. This allows different tenants to use the same application or system without interfering with each other.

Separate schema multi-tenancy is a technique for implementing multitenancy in a database or software application, in which each tenant has a separate schema (i.e. a set of tables and other objects) within the database.

This Poc consist of developing a ToDo App based on Separate Schema Tenancy.

How to start the application

The commands:

First you have to git clone the files by entering in your terminal:

$ git clone https://github.com/Cherni-Oussama/Separate-schema-multitenancy-with-spring-boot.git

Then start the application:

$ docker-compose up -d

Flow

  • On startup, the application will configure two EntityManager: one for the master and another for tenants.

  • The MasterEntityManager will create the Tenant table in the master schema to store each tenant and the corresponding schema.

  • When new tenant is created:

    • MasterEntityManager will store the X-TENANT-ID and its schema.
    • Create new schema for the new tenant.
    • The TenantEntityManager will populate the new schema with Table dedicated to the Tenant (ToDo table in our case)
  • When the application received a request:

    • the Interceptor will intercept this request and get the actual tenant X-TENANT-ID and ask the TenantContext to store it.
    • The ORM get the actual tenant from TenantContext and execute the request on the corresponding schema.

About

This project is a Poc implementing the separate schema multitenancy with spring boot and postgres

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published