4 ms·
If I understand this is more of a coding question. I'd argue it would be best for most web based SaaS to have a single codebase, with a single branch that repr
by shireboy 2y ago
If I understand this is more of a coding question. I'd argue it would be best for most web based SaaS to have a single codebase, with a single branch that represents the production site. That code base would then be smart enough to enable the right features based on the current user and/or tenant and their subscription level and payment status. Pseudocode:
public DoFoo(){
if(CurrentUser.IsFreeSku && CurrentUser.FoosThisMonth >= 10) return Error('Free users are only allowed to do 10 foos each month);
FooService.DoFoo();
CurrentUser.FoosThisMonth ++
}
Similar in the UI you may hide or show things based on the current user/tenant and their sub level.
<div class='hidden-paid-user'>Click here to get our paid service</div>
You would still have server code enforce the subscription level rules because a malicious user could circumvent any client-based rules. How exactly you do both will depend on the framework your saas uses.
- 101008 2y agoThis is a nightmare
- squigglydonut 2y agoWhy
- rareitem 2y agoBecause you'll end up with lots of "if (user.isPaidUser) {...}"
- resonious 2y agoFor me personally, I don't see the issue with this. It's an accurate representation of the app's behavior.
- shireboy 2y agoWell, yeah, but this was just pseudocode to convey the concept that you should solve the problem in code, not by maintaining separate code branches, deployments, etc. One approach would be to have an implementation of FooService for each sku, and code that uses the right one based on the current user/tenant/payment status/etc. This gets into dependency injection, inheritance, and other language/framework specific things. The actual approach would vary based on the project. It may be that CurrentUser.Sku and CurrentUser.IsPaymentCurrent is sufficient. Or it may be that you need a FooService per SKU, or any number of other ways to handle.
- squigglydonut 2y agoOk this makes sense to me. Bundling feature sets by SKU.
- squigglydonut 2y agoI get that but then what would the alternative be? I am not saying that there is not an alternative but if you know another way I am curious to hear from you about that.