I am building an app using Firebase. One of the features of this app is a chat feature where users can message other users - nothing fancy, just text-based one user to one user messaging. All of the tutorials online that describe how to implement this such as this one or this one utilize anonymous authentication, so many of the principles don't seem to apply. I am having users authenticate before they can use this feature.
It appears that the two main things I have at my disposal are the ability to modify the contents of specific paths (add, edit, delete, change order) in my app's JSON database structure and observe these changes on the client side as they happen. I could easily put every message in the same child and listen for any changes to the message child then parse every message into conversations on the client-side by looking for messages associated with the current user ID. However, this method seems inefficient as it seems to me like I would have to filter out a lot of superfluous messages.
A description of the general flow of how the observation structure should work, what I need to contain in each message, and how to sort into separate conversations efficiently would be very helpful.