Create a feed system with Appwrite (Fanout system)
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)
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 ....
Maybe the activities collection can have a type attribute and attributes for all the types.
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, ...) ?
Yes. Check the type and then request whatever else you need
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 ?
If you're really concerned, you can put most of the data into the activity
not very substainable if activity can be edited right ? so I guess no choice to query all activity info
Okay after a month in 42 school, I'm back to dev q feed system with appwrite
Recommended threads
- Invalid document structure: missing requ...
I just pick up my code that's working a week ago, and now I got this error: ``` code: 400, type: 'document_invalid_structure', response: { message: 'Inv...
- custom domain with CloudFlare
Hi all, it seems that CloudFlare has blocked cross-domain CNAME link which made my app hostname which is in CloudFlare, unable to create a CNAME pointing to clo...
- Type Mismatch in AppwriteException
There is a discrepancy in the TypeScript type definitions for AppwriteException. The response property is defined as a string in the type definitions, but in pr...