AnishLushte07 / multi-tenant-application

Multi tenant application using NodeJs, express and mysql
Apache License 2.0
7 stars 6 forks source link

Multi Tenancy for existing nodejs applications #3

Open manjeshpv opened 5 years ago

manjeshpv commented 5 years ago

mailtrain version 1 focussed on building email campaign manager

v2(https://github.com/Mailtrain-org/mailtrain/tree/development) focussed on making multi tenancy,

Is there any way without changing the code of existing nodejs app, we can add multi tenancy to a nodejs/express app already built

Benefits

Current Challenges while setup

  1. DB Creation - we do in manually phpmyadmin, can be easily automated as we using common db to keep track of tenants https://github.com/AnishLushte07/multi-tenant-application/blob/master/sample.env#L7
  2. Migration - we do manually via ssh - need feature https://github.com/AnishLushte07/multi-tenant-application/issues/2
  3. Load models: additional api need to developed to add connections on the fly https://github.com/AnishLushte07/multi-tenant-application/blob/master/server/conn/sqldb/dynamicConnection.js#L46

With above 3 steps we can automate setup process,

Expectation is run migration of another existing nodejs application so we can add a add a field sequelizerc in client(tenant) table

sequelizerc: DataTypes.JSON

above field will be updated with https://github.com/AnishLushte07/multi-tenant-application/blob/2ce643aeb78b182050e09bc0b57cb43dcc772863/sequelizerc-tenant2.json#L1-L5 https://github.com/AnishLushte07/multi-tenant-application/blob/master/server/api/client/client.property.js#L11

NOTE: In other words, if we make a provisioning tool, then it will help developers to focus on domain, Automatic Provisioning tool will automate tenant signup process