0

My use case:
UserA can create post.
Users B,C,D... can follow userA in order to see his posts on their screen.
My design idea:
/users --> registered users
/posts --> collection where users store their posts (in app I have screen that list all posts by date not related to following users so this is what everybody see).
/feed --> when post is created I copy here photo, title, short description and tags this documents has less data than posts.

In user document I have:

/users
  -userId
    - followers
      -userIdB
      -userIdC
      -userIdD
    - followings

Now when UserA create new post:

  • it is stored in /posts
  • it is copied with less info in /feed
  • fetch list of followers and copy with less info in /users/userB...C...D/feed collection.

  • if userIdE starts to follow userA I copy userA posts to /users/.../userIdE/feed

When I list posts from all I fetch data from /feed When I list posts from users I follow I fetch from /users/myId/feed Until this point I think that design is good (I hope).

This is proof of concept that real users will use but I am limited to my app I can't use firebase functions as client doesn't want to start with paid plan.
What could be a problem to make all this data copy to: feed, users/feed from user phone in terms of cost?
I am also scared that somebody can sit and follow/unfollow same user which will make coping data million times.

1110
  • 7,829
  • 55
  • 176
  • 334
  • Maybe this [answer](https://stackoverflow.com/questions/46979375/firestore-how-to-structure-a-feed-and-follow-system/52153332#52153332) will help. – Alex Mamo Jul 22 '22 at 09:58
  • I read it and if I understand it I can't use it as there there is /posts/userX/[hisPosts] but if I follow 5 users I need to get paging data sorted by date. Not only from one user. – 1110 Jul 22 '22 at 10:05
  • Can you check this [tutorial](https://www.youtube.com/watch?v=35RlydUf6xo&t=530) once? – Roopa M Aug 02 '22 at 07:28
  • That is exactly what I did. – 1110 Aug 02 '22 at 11:03
  • I believe Firebase functions would be the best way to ensure that the client's server can sanity-check the requests and volume of those requests too. Instead of copying the actual data, it might be better to just copy references to it. It will be difficult to understand all constraints from stack overflow post. – Roopa M Aug 04 '22 at 11:19
  • Please contact [Google support](https://cloud.google.com/contact) if you are worried about security issues to share details here. And you may have look at this [link](https://medium.com/@garyalexanderpiong/building-a-working-instagram-clone-using-flutter-and-firebase-1c9f9bb960ef) which may be helpful – Roopa M Aug 04 '22 at 11:19

1 Answers1

0

I believe Firebase functions would be the best way to ensure that the client's server can sanity-check the requests and volume of those requests too.

Instead of copying the actual data, it might be better to just copy references to it.

It will be difficult to understand all constraints from stack overflow post.

Please contact Google support if you are worried about security issues to share details here. And you may have look at this link which may be helpful

Roopa M
  • 2,171
  • 4
  • 12