Ask HN: How come there is no example code for B2B-SaaS apps?
21–30 of 94 posts
Re: Ask HN: How come there is no example code for B2B-SaaS apps?
#22Re: Ask HN: How come there is no example code for B2B-SaaS apps?
#23What 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.
Having built a number of these, it's not that simple. For example do you put a tenant column on every table, have a separate table per tenant, or have a separate schema or database? There are tradeoffs for each approach and lots of gotchas you wouldn't expect. Like if you use a separate table or database, migrations take forever, you can run into file descriptor limits in your database, etc.
Re: Ask HN: How come there is no example code for B2B-SaaS apps?
#24I'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.)
It's got:
- multi-tenancy
- roles with-in each tenant
- sub-tenants (think engineering team vs accounting team vs hr team)
- accounts can be members of multiple tenants
- billing for each tenant (even sub tenants or inherit from root tenant)
- Super Admin & "Staff" roles
- Auditing
If anyone's interested in the open source app, follow here - https://twitter.com/tools_hub
Re: Ask HN: How come there is no example code for B2B-SaaS apps?
#25I 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) 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 stru…
Re: Ask HN: How come there is no example code for B2B-SaaS apps?
#26In 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. Once you’ve done that, you don’t have to worry about forgetting a `WHERE tenantId = foo` somewhere and leaking data.…
I found a few tools early on that work for this in Rails. You can guarantee all of your sql includes the tenant.
- Apartment
- Tenancy
There's also several for the PHP ecosystem.
Re: Ask HN: How come there is no example code for B2B-SaaS apps?
#27If you find any, please let us know. We are looking for a Laravel example.
Re: Ask HN: How come there is no example code for B2B-SaaS apps?
#28In 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. Once you’ve done that, you don’t have to worry about forgetting a `WHERE tenantId = foo` somewhere and leaking data.…