I'm truly baffled! There are probably 1000s of consumer (B2C) SaaaS example and OSS apps in virtually all languages. But there is virtually ZERO examples or OSS projects that talk about B2B multi-tenant apps! The worst part is that even companies like Google Cloud don't provide an example.<p>What I'm looking for is: A SaaS app that allows people to create tenants (companies), and allows admin of the tenant to login and manage group of users, keep track of billing for each tenant, have super-admin who can access any tenant. But the rest of the app code is shared across the tenants.
I'm looking for code that's either in Java or JavaScript(NodeJS). Are you in the same boat as me? If not, could you please point me to something? I really appreciate that!
In my experience, a lot of projects start off with shared tenancy (using a tenant id discriminator in the database) and eventually migrate to completely separate schema for each tenant (i.e. a separate “installation” of a single-tenancy app for each tenant) to avoid security and architectural pitfalls.<p>Once you’ve done that, you don’t have to worry about forgetting a `WHERE tenantId = foo` somewhere and leaking data. The actual code is shared (i.e. not installed separately or in separate processes) and you would simply use your dependency injection or equivalent to resolve the DB connection contingent on $user’s validated claims.<p>“Networking” or sharing entities across tenants becomes harder this way.. but purer/cleaner. You essentially create a federation layer and communicate across instances via a hard code wall (via network requests to yourself and an API) rather than “in memory” which <i>is</i> less efficient and requires a lot of boiler plate, but it’s going to be what you’re going to end up doing anyway.
I've been working on something like this for Ruby on Rails in case anyone is interested. It has multitenancy, billing separate for each tenant, automatic query filtering for the current tenant, etc. <a href="https://jumpstartrails.com" rel="nofollow">https://jumpstartrails.com</a>
One of the largest open-source Rails apps has all of those features: Canvas LMS[1]. It uses Switchman[2] for abstracting the multi-tenancy logic.<p>Their approach has scaled to millions of concurrent users, but admittedly not helpful if you’re looking for a guide since the code is buried in a legacy monolith.<p>Part of the reason there isn’t a generic guide to this is that multi-tenancy is probably a premature optimization if a generic guide would be helpful. Just use nested user accounts to accomplish your business logic. By the time you really need true multi-tenancy, generic sample code won’t be much more helpful than the docs of the various plugins like Switchman.<p>1: <a href="https://github.com/instructure/canvas-lms" rel="nofollow">https://github.com/instructure/canvas-lms</a>
2: <a href="https://github.com/instructure/switchman" rel="nofollow">https://github.com/instructure/switchman</a>
Try this <a href="https://saasstartupkit.com/" rel="nofollow">https://saasstartupkit.com/</a> built in Golang. My company has used it for a proof of concept as it definitely is built around b2b multi-tenancy. Good starting point for us at the time.
You should look into Feathers JS [0]. You've the option to write in Javascript or Typescript and its built on top of nodejs/express.<p>Feathers JS has got builtin authentication and it is easy to add tenants. I've created a quick example and published it here [1], there maybe some rough edges, please mail me if you have any questions.<p>As others have mentioned with multi tenancy you must have good test cases that verify you've appropriate filters in place to avoid leaking data.<p>[0] <a href="https://feathersjs.com/" rel="nofollow">https://feathersjs.com/</a>
[1] <a href="https://github.com/bjacobt/feathers-multi-tenant-example" rel="nofollow">https://github.com/bjacobt/feathers-multi-tenant-example</a>
I know it's a little early and it will be in Ruby on Rails. However, I'm working on open sourcing a clone of Stripe's Home [1] as part of a series of open source B2B applications & they should check all those boxes (besides the Java/Node)<p>I'm also happy to walk you (or others in the thread if time permits) though the source code of a closed source app I have over a video call if you need to grok the mechanics/db structure. (email in profile.)<p>It's got:<p>- multi-tenancy<p>- roles with-in each tenant<p>- sub-tenants (think engineering team vs accounting team vs hr team)<p>- accounts can be members of multiple tenants<p>- billing for each tenant (even sub tenants or inherit from root tenant)<p>- Super Admin & "Staff" roles<p>- Auditing<p>If anyone's interested in the open source app, follow here - <a href="https://twitter.com/tools_hub" rel="nofollow">https://twitter.com/tools_hub</a><p>[1] - <a href="https://stripe.com/blog/stripe-home" rel="nofollow">https://stripe.com/blog/stripe-home</a>
I have been working on this:<p><a href="https://github.com/userdashboard/dashboard" rel="nofollow">https://github.com/userdashboard/dashboard</a><p>Dashboard powers the basic 'web app with registrations' and then using modules it can be supplemented with organizations, Stripe Subscriptions and Stripe Connect to standardize / reuse the "SaaS boilerplate". It runs parallel to your application server so you can use whatever stack you like. Users browse your Dashboard server URL and it proxies your application server for content.<p>The software is complete but it needs niceties like useful charts and information added to the UI and I'll be prioritizing that in the coming weeks. It's got a really nice documentation site being generated with Github Actions but it's not publishing correctly unfortunately, probably tomorrow that will be resolved.
<a href="http://abp.io/" rel="nofollow">http://abp.io/</a> is probably the best open source one I've seen. They also offer a paid product which is fairly comprehensive. I don't quite like their frontend stuff but the backend side of things is definitely what you're looking for.<p>There are plenty of paid products in every language which are basically B2B SaaS templates.<p>ABP, bullettrain, Laravel etc.
There's little sample code because some parts of the problem are disproportionately harder than others.<p>For example, in saas, if you have a serious product then you'll soon find that some of your tenants want to use SSO. So you need not only the stuff you mentioned already but also admin screens for setting up e.g saml for individual tenants. Add that to your points and you don't need sample code, you need a whole product (we use keycloak, there are plenty of other options).<p>As to billing, that's a whole gigantic separate area and again something where you don't want sample code, you want a complete product (I have heard jbilling talked of favorably).<p>In short, the problem space is too big to be addressed with some sample code.
Does this help?<p><a href="https://docs.microsoft.com/en-us/azure/sql-database/saas-dbpertenant-wingtip-app-overview" rel="nofollow">https://docs.microsoft.com/en-us/azure/sql-database/saas-dbp...</a>
This may not match your description but definitely matches the title - OSS B2B SaaS app: <a href="https://github.com/getsentry/sentry" rel="nofollow">https://github.com/getsentry/sentry</a><p>They also have a separate repo to help you run it: <a href="https://github.com/getsentry/onpremise" rel="nofollow">https://github.com/getsentry/onpremise</a>
Why? It’s difficult and knowledge of how to do single and multi-tenant applications for B2B keep a ton of people employed. However it’s not that far off from consumer projects. Most established players moved fast to build custom code to match their use cases. It’s not OSS material.<p>For B2B, “super-admin” should only be done with logged permission. Usually an email request.<p>Here’s two projects to help point you in the right direction.<p><a href="https://github.com/terraform-google-modules/terraform-google-project-factory" rel="nofollow">https://github.com/terraform-google-modules/terraform-google...</a><p>WorkOS is attempting to simplify this. <a href="https://m.youtube.com/watch?v=IR2QZQrzoiA&t=1433s" rel="nofollow">https://m.youtube.com/watch?v=IR2QZQrzoiA&t=1433s</a>
I’m using Jumpstart Pro (paid) for a rail’s app i’m working on, I know you requested node, but you may find it very useful to see how they implemented multitenancy and ruby/rails code is very readable.<p><a href="https://youtu.be/6wuaVWKVclo" rel="nofollow">https://youtu.be/6wuaVWKVclo</a><p><a href="https://jumpstartrails.com/" rel="nofollow">https://jumpstartrails.com/</a>
<a href="https://github.com/vanilla/vanilla" rel="nofollow">https://github.com/vanilla/vanilla</a> can be run in a “multi-tenant” setup. It is always done with separate databases and configs though.<p>Localhost setups are always multi-tenant, even if our infrastructure is more strongly isolated. In the end, if you can load different configurations for your app at runtime, and that configuration includes info about how to connect to your DB, cache, etc, then it’s pretty easy to do.<p><a href="https://github.com/vanilla/vanilla-docker/blob/master/docs/vanilla-localhost-dirs.md" rel="nofollow">https://github.com/vanilla/vanilla-docker/blob/master/docs/v...</a> this is an example of how we do the localhost setups, although I’d using separate DB credentials for any production site.
<a href="https://github.com/async-labs/saas" rel="nofollow">https://github.com/async-labs/saas</a> "Build your own SaaS business with SaaS boilerplate. Productive stack: React, Material-UI, Next, MobX, WebSockets, Express, Node, Mongoose, MongoDB. Written with TypeScript"
Will you consider a SaaS option? We are finishing up a identity management platform which does exactly that (at least access management part with 3-tiers of multi-tenancy). Our dedicated option allows you to host up to 1000-5000 tenants in a completely isolated infrastructure. Happy to have a chat.
What is the problem just build it your self. A simple template that has a login with a todo list can be extended to have a companies table. When you have added this, you can add a n to n relation between companies and users and poof you have a B2B saas app template.
Check this [SaaS Deployment Guide](<a href="https://github.com/aws-quickstart/saas-identity-cognito" rel="nofollow">https://github.com/aws-quickstart/saas-identity-cognito</a>) out from AWS.
I'm not sure you'll find something with such a specific requirement.<p>The first thing that came to mind is server management tools like free alternatives to cpanel/webhostmanager<p><a href="https://froxlor.org/" rel="nofollow">https://froxlor.org/</a><p>You'll have better luck searching online if you look for "free / open source" + specific problem/solution rather than "b2b saas app"<p>in this example i searched for "free alternative to cpanel"
An engineer from Nodewood posted on here at the same time as this post about their SaaS starter kit, built in Node.js and includes billing but no mention of multi-tenancy:<p><a href="https://news.ycombinator.com/item?id=23054417" rel="nofollow">https://news.ycombinator.com/item?id=23054417</a>
I have built many over the years in Java but nothing is public, I was thinking of abstracting away a Microservice template as a starting point for my projects.<p>What you are mentioning is a very specific example of that, happy to have a chat and perhaps we can build that together and open source it ?
And then add in a user authentication system like Auth0 or Cognito with a way to pass authentication tokens among microservices within the app. All stuff that should be boilerplate samples but in practice burns an enormous amount of time getting in place.
Multitenancy with Rails - 2nd edition<p>If you are doing Rails by any chance this is just what you need. <a href="https://leanpub.com/multi-tenancy-rails-2" rel="nofollow">https://leanpub.com/multi-tenancy-rails-2</a>
you could get pretty far with laravel spark if you don't mind picking up some php. <a href="https://spark.laravel.com/" rel="nofollow">https://spark.laravel.com/</a>