Ramsk
Ramsk

Reputation: 181

multi-tenant-schemas:dynamic api routing using django restframework

I am newbie to Multi-Tenant architecture, developing SaaS product using django-tenant-schema

my requirement was something like clients would register for product. For every registered client, I was creating new schema by following single database and isolated schemas approach. Whenever client requested from a browser I was able to identify them by using subdomain and giving privilege to acces their specfic schema. While I was starting coding lot of questions were popup in my head. I am really sorry for asking here but stackoverflow is only my last hope. Database was like below

Database

Q1.What kind of admin actions we can perform on every client?

I have rest api for example http://client.example.com/api/user_list/ here client maybe ClientA or ClientB

Q2. How can we implement api routing which gets client name dynamically when user requested at browser which let us to use corresponding schema to display current client's user_list.

Any reply can be helpful. Thanks in advance.

Upvotes: 3

Views: 1603

Answers (1)

Ramsk
Ramsk

Reputation: 181

I followed django-tenants ,and their team implemented almost everything required for django multi-tenant SaaS(Software As a Service) application. So I haven't done much work beyond understanding architecture; I just want to answer this question.

First start with admin and their privileges; for the above requirement, I have two admin roles: tenants_admin, tenant_admin.

Here, tenants_admin (who serve the product) are able to manage tenants(individual company who buy the product); tenants_admin can manipulate data of tenants and they are located at tables in public schema.

Now coming to tenant_admin, who has privilege over data of tenant users (let's say employees in single company).

Now clone the project from django-tenants, create app particularly for tenants. These tenant schemas are strongly isolated from each other, include both the app name and rest_framework to tenant apps. Afterwards implement REST API as usual; these API will be navigated automatically by using middleware we created for project.

Upvotes: 4

Related Questions