TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: How come there is no example code for B2B-SaaS apps?

159 点作者 node-bayarea大约 5 年前
I&#x27;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&#x27;t provide an example.<p>What I&#x27;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&#x27;m looking for code that&#x27;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!

32 条评论

ComputerGuru大约 5 年前
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&#x2F;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.
评论 #23057679 未加载
评论 #23056862 未加载
评论 #23057791 未加载
评论 #23057781 未加载
评论 #23056838 未加载
评论 #23060265 未加载
评论 #23057472 未加载
评论 #23058381 未加载
评论 #23057341 未加载
评论 #23057045 未加载
excid3大约 5 年前
I&#x27;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:&#x2F;&#x2F;jumpstartrails.com" rel="nofollow">https:&#x2F;&#x2F;jumpstartrails.com</a>
评论 #23056259 未加载
评论 #23057846 未加载
评论 #23057612 未加载
guptaneil大约 5 年前
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:&#x2F;&#x2F;github.com&#x2F;instructure&#x2F;canvas-lms" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;instructure&#x2F;canvas-lms</a> 2: <a href="https:&#x2F;&#x2F;github.com&#x2F;instructure&#x2F;switchman" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;instructure&#x2F;switchman</a>
评论 #23061828 未加载
评论 #23058686 未加载
tasssko大约 5 年前
Try this <a href="https:&#x2F;&#x2F;saasstartupkit.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;saasstartupkit.com&#x2F;</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.
评论 #23057186 未加载
bjacobt大约 5 年前
You should look into Feathers JS [0]. You&#x27;ve the option to write in Javascript or Typescript and its built on top of nodejs&#x2F;express.<p>Feathers JS has got builtin authentication and it is easy to add tenants. I&#x27;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&#x27;ve appropriate filters in place to avoid leaking data.<p>[0] <a href="https:&#x2F;&#x2F;feathersjs.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;feathersjs.com&#x2F;</a> [1] <a href="https:&#x2F;&#x2F;github.com&#x2F;bjacobt&#x2F;feathers-multi-tenant-example" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bjacobt&#x2F;feathers-multi-tenant-example</a>
评论 #23057148 未加载
masonhensley大约 5 年前
I know it&#x27;s a little early and it will be in Ruby on Rails. However, I&#x27;m working on open sourcing a clone of Stripe&#x27;s Home [1] as part of a series of open source B2B applications &amp; they should check all those boxes (besides the Java&#x2F;Node)<p>I&#x27;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&#x2F;db structure. (email in profile.)<p>It&#x27;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 &amp; &quot;Staff&quot; roles<p>- Auditing<p>If anyone&#x27;s interested in the open source app, follow here - <a href="https:&#x2F;&#x2F;twitter.com&#x2F;tools_hub" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;tools_hub</a><p>[1] - <a href="https:&#x2F;&#x2F;stripe.com&#x2F;blog&#x2F;stripe-home" rel="nofollow">https:&#x2F;&#x2F;stripe.com&#x2F;blog&#x2F;stripe-home</a>
评论 #23058455 未加载
评论 #23056815 未加载
benologist大约 5 年前
I have been working on this:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;userdashboard&#x2F;dashboard" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;userdashboard&#x2F;dashboard</a><p>Dashboard powers the basic &#x27;web app with registrations&#x27; and then using modules it can be supplemented with organizations, Stripe Subscriptions and Stripe Connect to standardize &#x2F; reuse the &quot;SaaS boilerplate&quot;. 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&#x27;ll be prioritizing that in the coming weeks. It&#x27;s got a really nice documentation site being generated with Github Actions but it&#x27;s not publishing correctly unfortunately, probably tomorrow that will be resolved.
james_s_tayler大约 5 年前
<a href="http:&#x2F;&#x2F;abp.io&#x2F;" rel="nofollow">http:&#x2F;&#x2F;abp.io&#x2F;</a> is probably the best open source one I&#x27;ve seen. They also offer a paid product which is fairly comprehensive. I don&#x27;t quite like their frontend stuff but the backend side of things is definitely what you&#x27;re looking for.<p>There are plenty of paid products in every language which are basically B2B SaaS templates.<p>ABP, bullettrain, Laravel etc.
评论 #23057175 未加载
abraae大约 5 年前
There&#x27;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&#x27;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&#x27;t need sample code, you need a whole product (we use keycloak, there are plenty of other options).<p>As to billing, that&#x27;s a whole gigantic separate area and again something where you don&#x27;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.
x3haloed大约 5 年前
Does this help?<p><a href="https:&#x2F;&#x2F;docs.microsoft.com&#x2F;en-us&#x2F;azure&#x2F;sql-database&#x2F;saas-dbpertenant-wingtip-app-overview" rel="nofollow">https:&#x2F;&#x2F;docs.microsoft.com&#x2F;en-us&#x2F;azure&#x2F;sql-database&#x2F;saas-dbp...</a>
评论 #23057054 未加载
评论 #23056903 未加载
kamyarg大约 5 年前
This may not match your description but definitely matches the title - OSS B2B SaaS app: <a href="https:&#x2F;&#x2F;github.com&#x2F;getsentry&#x2F;sentry" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;getsentry&#x2F;sentry</a><p>They also have a separate repo to help you run it: <a href="https:&#x2F;&#x2F;github.com&#x2F;getsentry&#x2F;onpremise" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;getsentry&#x2F;onpremise</a>
phiggins大约 5 年前
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:&#x2F;&#x2F;github.com&#x2F;terraform-google-modules&#x2F;terraform-google-project-factory" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;terraform-google-modules&#x2F;terraform-google...</a><p>WorkOS is attempting to simplify this. <a href="https:&#x2F;&#x2F;m.youtube.com&#x2F;watch?v=IR2QZQrzoiA&amp;t=1433s" rel="nofollow">https:&#x2F;&#x2F;m.youtube.com&#x2F;watch?v=IR2QZQrzoiA&amp;t=1433s</a>
评论 #23121662 未加载
hijp大约 5 年前
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&#x2F;rails code is very readable.<p><a href="https:&#x2F;&#x2F;youtu.be&#x2F;6wuaVWKVclo" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;6wuaVWKVclo</a><p><a href="https:&#x2F;&#x2F;jumpstartrails.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;jumpstartrails.com&#x2F;</a>
charrondev大约 5 年前
<a href="https:&#x2F;&#x2F;github.com&#x2F;vanilla&#x2F;vanilla" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;vanilla&#x2F;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:&#x2F;&#x2F;github.com&#x2F;vanilla&#x2F;vanilla-docker&#x2F;blob&#x2F;master&#x2F;docs&#x2F;vanilla-localhost-dirs.md" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;vanilla&#x2F;vanilla-docker&#x2F;blob&#x2F;master&#x2F;docs&#x2F;v...</a> this is an example of how we do the localhost setups, although I’d using separate DB credentials for any production site.
langbot大约 5 年前
<a href="https:&#x2F;&#x2F;github.com&#x2F;async-labs&#x2F;saas" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;async-labs&#x2F;saas</a> &quot;Build your own SaaS business with SaaS boilerplate. Productive stack: React, Material-UI, Next, MobX, WebSockets, Express, Node, Mongoose, MongoDB. Written with TypeScript&quot;
评论 #23058695 未加载
评论 #23058110 未加载
abhishektwr大约 5 年前
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.
评论 #23057904 未加载
sneeuwpopsneeuw大约 5 年前
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.
评论 #23055672 未加载
评论 #23056145 未加载
mmaha大约 5 年前
Check this [SaaS Deployment Guide](<a href="https:&#x2F;&#x2F;github.com&#x2F;aws-quickstart&#x2F;saas-identity-cognito" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;aws-quickstart&#x2F;saas-identity-cognito</a>) out from AWS.
hayksaakian大约 5 年前
I&#x27;m not sure you&#x27;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&#x2F;webhostmanager<p><a href="https:&#x2F;&#x2F;froxlor.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;froxlor.org&#x2F;</a><p>You&#x27;ll have better luck searching online if you look for &quot;free &#x2F; open source&quot; + specific problem&#x2F;solution rather than &quot;b2b saas app&quot;<p>in this example i searched for &quot;free alternative to cpanel&quot;
hbcondo714大约 5 年前
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:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=23054417" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=23054417</a>
hackerm0nkey大约 5 年前
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 ?
yodon大约 5 年前
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.
harshamv22大约 5 年前
Multitenancy with Rails - 2nd edition<p>If you are doing Rails by any chance this is just what you need. <a href="https:&#x2F;&#x2F;leanpub.com&#x2F;multi-tenancy-rails-2" rel="nofollow">https:&#x2F;&#x2F;leanpub.com&#x2F;multi-tenancy-rails-2</a>
dawie大约 5 年前
If you find any, please let us know. We are looking for a Laravel example.
评论 #23056958 未加载
评论 #23055353 未加载
评论 #23056849 未加载
mariushn大约 5 年前
<a href="https:&#x2F;&#x2F;nodex.wensia.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;nodex.wensia.com&#x2F;</a> (it&#x27;s not OSS, but $99)
stedaniels大约 5 年前
They&#x27;re are literally dozens of these startup frameworks for most of the web languages out there.
mikst大约 5 年前
I think because it&#x27;s much easier to do deploy templates than multitennancy.
cultofmetatron大约 5 年前
you could get pretty far with laravel spark if you don&#x27;t mind picking up some php. <a href="https:&#x2F;&#x2F;spark.laravel.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;spark.laravel.com&#x2F;</a>
villgax大约 5 年前
That&#x27;s kind of their daily bread &amp; butter.
swiley大约 5 年前
Doesn&#x27;t open stack do this?
gfodor大约 5 年前
I&#x27;m starting a SaaS that adds multitenancy to an app as a service.
mister_hn大约 5 年前
Isn&#x27;t Gitlab a B2B SaaS app?