Back

Create a feed system with Appwrite (Fanout system)

  • 0
  • Databases
  • Web
loup
30 Jul, 2023, 08:56

Create a feed system with Appwrite (Fanout system)

TL;DR
The user wants to create a feed system with Appwrite using a fanout system. They are concerned about the sustainability of the system if activities can be edited. The solution is to query all activity info and put most of the data into the activity. The user can check the type and request any additional information needed. They can create multiple feed collections for different activities and use a hybrid model (push and pull) depending on the number of followers. The push model can be implemented using an Appwrite function triggered by a write in specific collections, while the pull model can be implemented client-side by requesting the last activity from the following user list and
loup
30 Jul, 2023, 15:06

I wanna add a feed system in my nextjs app using Appwrite where I can have the last activity from the user I follow. The problem is HOW TO DO IT. When I look on few exemple (twitter, facebook, etc...) all use FANOUT SYSTEM. With 2 model :

  • push model
  • pull model

So push model is litteraly store a feed for each user. Like having a collection feed in appwrite DB where all document got :

  • userId (target user feed)
  • activityId (id of the activity) And pull model is just get the last activity from following user list.

So Twitter, FB, etc.. use hybrid model (push and pull) depending of the amount of following user. That mean if Justin Timberlake with 64M followers, like a movie, we don't gonna use push model because edit 64M feed is to heavy load.

So I guess the push model need an appwrite function who gonna be triggered by the write inside specific collection "likes", "review", etc... and create/delete inside feed collection a new document for a specific userId And the pull model is gonna be client-side where we gonna request the last activity from the celebrity following user list of the connected user and after merge the them and sort them chronological with the feed (from push model)

loup
30 Jul, 2023, 16:22

My first problem is how store differente activity in the feed : movie liked_ movie review, .... If activityId (attribut inside each document from feed collection) is a relationship attribut I can target to only one collection so im stuck. Maybe use multiple feed collection for each activity likes :

  • feed_movie_liked
  • feed_movie_review ....
Drake
30 Jul, 2023, 17:44

Maybe the activities collection can have a type attribute and attributes for all the types.

loup
30 Jul, 2023, 18:17

Yes but if I dont have relationnal attribut I have to make a query for each activity (for example: take the review text, take the rating movie, ...) ?

Drake
30 Jul, 2023, 18:30

Yes. Check the type and then request whatever else you need

loup
30 Jul, 2023, 18:36

But it can be kinda heavy in terme of queries consumption if we don’t have directly the info of the activity when querying the feed ?

Drake
30 Jul, 2023, 19:08

If you're really concerned, you can put most of the data into the activity

loup
30 Jul, 2023, 20:46

not very substainable if activity can be edited right ? so I guess no choice to query all activity info

loup
29 Aug, 2023, 09:43

Okay after a month in 42 school, I'm back to dev q feed system with appwrite

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