K
Kinde5mo ago
Dave

Need advice on multi-tenant design

My NextJs webapp facilitates companies developing apps and making them accessible via plans and subscriptions. Using an example, company A develops App1 and App2, accessible on app1.companyA .com and app2.companyA.com respectively.
Company B subscribes to a 5-user license for the use of App1 from company A (assuming via a product plan). Up to 5 users (employees) of Company B can create user accounts for App1 from Company A and access it. Company C subscribes to a 10-user license plan for App2, allowing up to 10 users (employees) from company C to use App2. Company C also offers its own app, App3, which is subscribed to by Company A. I’m assuming using features for app access and org_codes for separation of users by company will be part of the solution (also to leverage the upcoming plans/subscription functionality). However, I don’t know how to put it together, specifically, what is offered out of the box, and how to best implement what is not, utilizing Kinde framework. Please help. Thanks, Dave
5 Replies
Oli - Kinde
Oli - Kinde5mo ago
Hey @Dave, Thanks for reaching out and providing a detailed scenario of your setup. If you are looking for advice on how to use Kinde's multi-tenancy (known as organizations in Kinde), here is how I would suggest setting up in Kinde based on your example: - Organizations -> Company A -> Company A - App1 -> Company A - App2 -> Company B -> Company C Think of organizations as a 'group of users'. Applications: -> Company A - App1 -> Company A - App2 -> Company B -> Company C I would have a 1:1 mapping between the applications and the relavant organization. Please let me know if you have any questions on the above. Also, please let me know if you have any further questions.
Kinde docs
About organizations
Our developer tools provide everything you need to get started with Kinde.
Dave
DaveOP5mo ago
Thank you for the info, Oli. I'd like to avoid having separate silos of users for the same company if possible. It's hard to guess how plans and subscriptions will work, but I was assuming I'd implement organisations and then, for example, when company B subscribes to a 5-user license for app1 from company A, I'd programmatically set an integer feature flag of 5 for app1 users for that organisation and then monitor how many users logged in. I was basically assigning the organisation concept to a physical company with it's users being their team of employees, consultants etc. Then for apps, I was thinking of feature flags for controlling access to functionality. Is this a logical way of doing it and does it make sense given the upcoming plans/subscriptions functionality?? Also, if a feature is enabled for an organisation, can I use roles and permission to control a user's access to that feature? Thx.
Oli - Kinde
Oli - Kinde4mo ago
Hey Dave, Thanks for getting back to me. I will look into your reply early next week and get back to you. Hey @Dave, Havent forgotten about this. Still discussing your comments above with my team. Hey @Dave, Sorry for the delayed response. There are many ways to tackle your desired setup with Kinde, but I think your approach (you said above) is probably the best approach. I'll share a few comments below.
I'd like to avoid having separate silos of users for the same company if possible.
Okay in that case, I would suggest only have an organization per Company, i.e. 3 organizations for Company A, B and C in your example.
programmatically set an integer feature flag of 5 for app1 users for that organisation and then monitor how many users logged in.
This sounds like a good approach.
Then for apps, I was thinking of feature flags for controlling access to functionality.
This also sounds like a logical approach.
Is this a logical way of doing it and does it make sense given the upcoming plans/subscriptions functionality??
It doesn't seem like our upcoming Billing product (with plans and subscriptions configuration) will solve your use-case outlined here. The upcoming Billing product will allow you to create plans and subscriptions for your applications and not unique plans/subscriptions for each company in your system. If you want to create unique plans and subscriptions for each of the companies, you will need to have a Kinde business per company.
Is this a logical way of doing it and does it make sense given the upcoming plans/subscriptions functionality??
Sounds like your approach above is the best approach.
Let me know if you have any further questions.
Dave
DaveOP4mo ago
Thanks Oli for the info. The upcoming plans/subscriptions functionality is very important for me. If I relaxed the constraint to allow a separate Kinde Organisation for each company/app combo, would this work with the upcoming billing product?
I understand the core of the billing product uses features for creating plans. At what level are the plans created? Per organisation?
Having a Kinde business per company is also an option except I don't see a "create business" function in the API. It appears businesses can only be created in the UI, which would be a show stopper for this option. THx.
Oli - Kinde
Oli - Kinde4mo ago
Hey Dave, I havent forgotten about this message. I will get back to you over the weekend. Have a good weekend mate! Hey @Dave, I am so so terribly sorry. I usually mark messages as unread in Discord as a reminder for me to get back to you, but I must have clicked on this message and not marked it as unread 🤦 This is my bad, I am so sorry for not getting back to you earlier.
If I relaxed the constraint to allow a separate Kinde Organisation for each company/app combo, would this work with the upcoming billing product?
Yes this would work so then you can assign a plan to each Kinde Organisation representing a company/app combo
I understand the core of the billing product uses features for creating plans. At what level are the plans created? Per organisation?
Plans are created at an environment level and they can be assigned to 1 or multiple organisations. Plans are not created at an organisation level, but you could technically create a plan (at the environment-level) for each org and then assign that plan only to a single org.
Having a Kinde business per company is also an option except I don't see a "create business" function in the API. It appears businesses can only be created in the UI, which would be a show stopper for this option. THx.
The reason for is there are a few critical details we need to collect when creating a new business, e.g. name, Kinde domain, and data region. These details cannot be changed once a Kinde business is created, so we are wary that an API endpoint to create a new business will likely create a lot of false businesses. Please let me know if you have any further questions. You can guarantee I wont miss your replies this time - apologies again!
Want results from more Discord servers?
Add your server