Live data from Hacker News

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

news.ycombinator.com

81–90 of 94 posts

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

#82
post #25

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) 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…

I’m super interested in this, but not sure what I’m looking at at the twitter account. Is there something on github or similar to look at?

Ya, sorry. The twitter account is a placeholder while we work. Just spun up a repo you can follow.

https://github.com/Internal-Tools-Hub/CorpHome/blob/master/R...

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

#83

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. Once you’ve done that, you don’t have to worry about forgetting a `WHERE tenantId = foo` somewhere and leaking data.…

Its a while ago now and I have no idea what post it was for, but there was a discussion here on HN about how this is a terrible idea as it turns into a complete mess and a nightmare to manage.

I've only done this at one company, and they self-hosted, and it was indeed a complete nightmare to manage, but part of that was the self-hosting part.

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

#84

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. Once you’ve done that, you don’t have to worry about forgetting a `WHERE tenantId = foo` somewhere and leaking data.…

using an ORM it's very simple. once you setup the relationships between models, you always use the highest level model as the entry point of your query and the ORM will scope the query for you. ie in Rails, if your highest level model is Account you just always use @account.customer.find(18). the Rails ORM will automatically scope the query to the current account. using multiple schemas becomes a nightmare when you w…

You can't really write reports or BI dashboards in ORMs, unless you want terrible performance.

So for simple queries, fine, but anything else this won't work.

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

#85

Earlier quoted context omitted.

I 2nd https://jumpstartrails.com . I purchased the "Unlimited Site License", and it is well worth it.

I wish there was something like this ready in Noode.js world (happy to pay)

https://github.com/async-labs/saas/blob/master/README.md

From: https://www.indiehackers.com/post/17-saas-starter-kits-boile...

Probably more than that one.

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

#86

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. 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. Part of the reason there isn’t a generic guide to this is that multi-tenancy is probably a premature optimizati…

That said, Canvas is also AGPL 3 which might be a concern for some people looking for code to base their new SaaS startup on.

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

#87
post #11

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. https://jumpstartrails.com

Intereting. I've been thinking about doing something like this with Python (Flask/Django), albeit a bit more general.

I work on https://www.saaspegasus.com/ as a similar project for Django. Let me know if you have any questions!

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

#88

Earlier quoted context omitted.

using an ORM it's very simple. once you setup the relationships between models, you always use the highest level model as the entry point of your query and the ORM will scope the query for you. ie in Rails, if your highest level model is Account you just always use @account.customer.find(18). the Rails ORM will automatically scope the query to the current account. using multiple schemas becomes a nightmare when you w…

You can't really write reports or BI dashboards in ORMs, unless you want terrible performance. So for simple queries, fine, but anything else this won't work.

no kidding and you're being unreasonable... yes, what ii stated will get you 99% of the way there. what you're belly aching about is the 1% where you have to veer from this and do it yourself. big deal.

look... you wouldn't forego taking a plane across the country cause you have to take a cab the last 2 miles to the hotel. same thing here. just because something falls out at the last 1% doesn't mean it a bad way to do things.

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

#89

Earlier quoted context omitted.

using an ORM it's very simple. once you setup the relationships between models, you always use the highest level model as the entry point of your query and the ORM will scope the query for you. ie in Rails, if your highest level model is Account you just always use @account.customer.find(18). the Rails ORM will automatically scope the query to the current account. using multiple schemas becomes a nightmare when you w…

The highest level entry point makes so much sense. I’ve been building multitenant saas for last 3 years enforcing “where tenant = x” and you’ve just blown my mind.

that's why we're here... learning something new everyday is a great things. now imagine how cool it will be implementing this is your projects from here out :)

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

#90
post #63
post #61

Earlier quoted context omitted.

I like this, I see what they're doing and it looks promising. However It lacks a data request/GDPR takedown section which for me makes the project commercially useless. Most teams/products always look at compliance as the last big rock to implement and it becomes a massive headache. If this project is focused to B2B learning it should have been tackled first (and not missing from the demo).

Is it really such a big problem in b2b? Can't you be only the Processor sign a DPA with your customers and let them handle the biggest part of the headache?

yes. I am a data processor not a controller. If you store data tied to the user you still need a mechanism to retrieve / delete it. This is something I encountered. Even if it is in reality not an issue and by itself the data is meaningless. Perhaps I need better legal advice :)
Post reply on HN