Back

Best practices for SaaS

  • 0
  • Databases
  • Auth
  • General
Faye
2 Apr, 2024, 11:34

Heyo!

Planning on making something new towards SaaS, but there's one thing that is kind of bothering me.

Users can register and subscribe, this will create a project for their company. A user however, can have multiple companies, each with isolated data. So that means a new project per company.

If a user logs into their account, how do I know which projects they have access to..?

Any ideas? 🙂

TL;DR
Developers discussing best practices for SaaS implementation through the Appwrite SDK. The solution involves creating a central Project to handle payment status of each user and using an external OAuth service for managing permissions and sign-ins. The users would be able to create multiple Projects (companies) with isolated data. The best approach seems to be using separate Databases for each company or assigning Labels for each company the user has access to within one Project.
ideclon
2 Apr, 2024, 11:43

How would you allow a user in one Project to access a different Project?

Faye
2 Apr, 2024, 11:43

exactly

ideclon
2 Apr, 2024, 11:43

I'd personally probably try to keep it all in one Project and use a separate Database for each company.

ideclon
2 Apr, 2024, 11:44

And then each user would get Labels for each company they have access to

ideclon
2 Apr, 2024, 11:44

Or Teams

Faye
2 Apr, 2024, 11:44

I thought of that

Faye
2 Apr, 2024, 11:44

but that sounds like a massacre to maintenance

Faye
2 Apr, 2024, 11:45

I could make a "global" project with database, which contains all project id's and who created them? 🤔

ideclon
2 Apr, 2024, 11:45

Well, the other possible alternative is to take Auth out of Appwrite entirely and use your own OAuth system, which could manage which Projects users are able to sign into. But that sounds lie just as much - if not more - maintenance

ideclon
2 Apr, 2024, 11:46

How would that allow a user on one Project to access resources in another?

Faye
2 Apr, 2024, 11:46

So the thing is, a user who pays can create a project, but the projects don't intersect, see it like 2 seperate mysql databases

ideclon
2 Apr, 2024, 11:47

When you say Project and User here, I'm assuming you're referring to the Appwrite concepts?

Faye
2 Apr, 2024, 11:47

yes

Faye
2 Apr, 2024, 11:48

When making changes to the SaaS things, I'd like to update all the databases, making them universal seems.. very handy

ideclon
2 Apr, 2024, 11:48

A User in Appwrite always exists within one Project. A single user can't have access to two Projects.

ideclon
2 Apr, 2024, 11:49

If I understand what you're saying here correctly, you'd have to be in one Project

Faye
2 Apr, 2024, 11:50

Correct.. which is the hard part, I'd like a registered user who paid to be able to create "projects", each project being it's individual company so I guess you'd have to make a login in a login? 🤔

ideclon
2 Apr, 2024, 11:51

The only reasonable solution I can see here is moving Auth out of Appwrite and using an outside OAuth service

Faye
2 Apr, 2024, 11:51

How would that work exactly?

ideclon
2 Apr, 2024, 11:55

All users would be created in the external system. There'd be a central Project to handle payment status of each user. The user would be able to sign into a management portal, I guess? Where they'd be signed into the central Project. In there, they can create a Project (which I supposed would call a Function).

The central Project would have a Permissions collection which would contain project IDs and whatever user identifier the OAuth system sends.

When the user enters a Project, they'd automatically be signed in via OAuth. If the user doesn't yet exist on that Project, a Function would be triggered which would check the Permissions in the central Project and assign the correct access to this new user.

ideclon
2 Apr, 2024, 11:56

How does that sound?

Faye
2 Apr, 2024, 11:57

Why wouldn't appwrite be able to do this? Sounds almost identical to my idea 😃

ideclon
2 Apr, 2024, 11:59

How would you sign users in?

Faye
2 Apr, 2024, 12:00

Through the normal appwrite sdk

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more