Hi, :)
I remember Todd saying that a good structure for Firebase is to store the same data in multiple places for fast reads and using cloud functions to update those data everywhere for writes. My question then becomes what actions should be taken in the "frontend" like Flutter, Dart code and in the "backend" like firebase cloud functions. Let's take these two scenarios
1) User updated profile image. I assume I should use the frontend to update the main place for that profile image reference in something like a "users" collection. And any other place that image occurs, like chat previews should be taken care of by cloud functions. If thats the case why should it be this way? I could just update everyplace with flutter/dart code and since the firebase calls would be async there is nothing blocking the changes for the user, and I assume it wouldn't be any slower than cloud functions?
2) I think u guys might give a good answers for the first scenario, then my question becomes. If I make a chat application and structure the data something like [collection: users] -> [user doc] -> [collection: chats] -> [recipient doc] -> [collection: messages] -> [message doc]. Here i will send a message and store that for both users, I will also have some information on the recipient doc like last message, time and so on. These docs will also need updates when a new message is sent. Which actions (1. store message for me, 2. store message for the receiver, 3. update the recipient doc for me, 4. update the recipient doc for the receiver) should then be done in flutter/dart code and which in cloud function and does it make a difference?
Let me know if I should explain something further or add more details
Best regards, Sohaib