Back

I need some Tipps to solve a Account/User "Problem" (Creating a Chat-App)

  • 0
  • Web
  • Databases
  • Accounts
  • Self Hosted
  • Users
_alnes_
7 Jul, 2023, 07:00

I want to create a chat web app. So far I only work with the Web SDK (Angular) and all database/auth services work very well.

Now I probably lack the right knowledge (I have ->still<- little Node.js or backend experience) to understand how to develop a dynamic chat app. Statically this would not be a problem:

Let's say there are fixed chat rooms with topics, and the users can register to chat. Then I would create a collection for each chatroom, where the messages would come in. The users would then be informed via appwrite function/realtime when there was new messages.... So far so good.

But if the users address each other directly....I can't create a collection for this 2-person chat in advance...This would have to happen dynamically, but it doesn't work with the Web Sdk.

I could simply build a collection for all chats, and then fish out the id of the respective chat messages....but that's not a good solution and would cost a lot of performance than if every direct chat had its own collection?!

I would like to have some ideas in which direction I have to learn further here? Completely different app structure, or use the Server SDK...do I then have to build my own API (with Server SDK, where the collections are created...) with which the clients then communicate?

Existing knowledge: Html/Css/Javascript (junior)/Typescript (junior) Framework Angular

In your opinion, what knowledge else would be important to add here in order to develop web apps really well with Angular + Appwrite?

Thanks very much <:appwritepeepo:902865250427215882>

TL;DR
The user is seeking tips for solving an account/user "problem" related to creating a chat app using Appwrite. They mention that the URL is not required on the server side and provide a link for more information. They also discuss the idea of creating collections for each direct chat user pair and subscribing to real-time updates. They mention that the solution with Appwrite teams looks good but have concerns about team invitations needing to be confirmed by email. The user is considering using a NoSQL database for more dynamic room structure. They also mention their lack of experience with Node.js and backend development. They ask for ideas on how to proceed and what additional
Binyamin
7 Jul, 2023, 14:22

Those two approaches are common in chat applications.

Usually most chat application uses a NoSQL databases to overcome this complicity precisely - as you can create much more dynamic room structure when you're not obligate to any.

That said, Appwrite although could look like a NoSQL database its still RDMBS one, so the best approach would be the second one and with indexing on some unique values as we can see next.

As for performances MariaDB is a pretty fast, and by using Index you can expect looking on O(log(N)) which means the search for index in 1B message should cost up to 10 searches.

So you can add index for the room ID in the messages collecion for fetching the messages.

The best way would be to utilize and use Appwrite teams, so the permission would work automatically read here about it: https://discord.com/channels/564160730845151244/1118234129037799507/1118531167017259178

_alnes_
12 Jul, 2023, 06:57

The solution with teams looks good. So each direct chat would be a unique team. But what bothers me: Every team invitation has to be confirmed by email, also on the server side? Of course, that makes little sense in a chat app.

_alnes_
12 Jul, 2023, 07:27

My idea was now: Create a collection for each direct chat user pair, then subscribe per realtime to "databases.[ID].collections.[ID].documents"....So each user has for each conversation one realtime-sub. (first without teams) - Could that work?

Binyamin
12 Jul, 2023, 13:42

On a server side there is no need to confirm and the all adding/removing of the team is much more naturally and without even notifying the user.

Binyamin
12 Jul, 2023, 13:42

Yes,

_alnes_
12 Jul, 2023, 13:56

Ah, because: https://appwrite.io/docs/server/teams?sdk=nodejs-default#teamsCreateMembership HTTP Request, url:

URL to redirect the user back to your app from the invitation email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an open redirect attack against your project API.

_alnes_
12 Jul, 2023, 13:57

So this is required, but the url itself does not have to be used. Only if I also want to work with the email on the server side...

_alnes_
12 Jul, 2023, 14:02

Thanks in advance for all the help <:appwritepeepo:902865250427215882>

Binyamin
12 Jul, 2023, 14:21

Yes, the URL is actually not needed in server side, check this: https://github.com/appwrite/appwrite/issues/5676

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