-
Notifications
You must be signed in to change notification settings - Fork 463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chat App Discussions #13
Comments
@weeeBox Hi. Thanks for all your contribution to this repo. I would be interested to deep dive into data flow (end to end) and how we can keep data as single source of truth for presentation layer with different use cases:
|
The actual implementation depends on the target platform but the idea is simple:
My point - you only update the database and other components "react" to that.
Same idea - you receive the message - you write it to the database, UI-component react to the changes.
You keep adding messages to the database but the network client ignores them while there's no connection. Once the connection is back - the network client send everything in a batch.
You update messages in 2 different ways:
You generally don't pull any data on an interval basis - that does scale as the number of the clients go up |
@matzuk, I think it could be too much detail for the interview - it's really hard to explain in such a short time. I would start simple and only add details if needed. Nobody expects you to build a robust solution - it's more about the process and communications. If you bring MVx patterns - don't forget non-technical trade-offs: how easy it is to teach junior engineers to use a specific architecture. When you bring a 3rd-party library - you need to have a good understanding of the updates, support, and deprecation. There's always a trade-off - you need to clearly communicate this to the interviewer. |
@weeeBox , If we come across a feature like Chat Backup to cloud. What are your thoughts on this? Do you see anything else to consider apart from below items?
Also, Any use case you can think of, where we use these backed up data in our app apart from just restoring it when user reinstalls the app? |
@rakeshh91, this WhatsApp screenshot should answer all your questions 🙂 |
Hi @weeeBox
|
probably we can explain what is |
Great discussion. I found the complexity goes up greatly if you have to support multiple devices and/or message deletion. Both are possible with xmpp, for example, but hard to add to an app that wasn't designed from the start with both in mind. |
@weeeBox Hi!
Here, there are some points about Chat Design based on my experience.
The main distinguishing feature of any Chat application is a very big number of states inside the App. Use A sent you a message, your message that was sent to a User B is delivered, the status of User C changed, Used D changed the name of Group AA and etc. How it affects the Application.
The first one is Architecture (close to the Presentation layer).
MVC, MVP, MVVM may work at the beginning but these solutions are absolutely non-scalable due to a big number of events and states that may affect each other and the absence of a State handling approach. That's why MVI approach does matter because MVI tries to set rules on how to handle a state. There are different implementations that you can consider as an example. My favorite one now is MVIKotlin.
The second consequence is CQRS and a Single source of True.
Let me show a diagram:
MessageFeature
. It's CQRS.UpdateChannel
. It's a source of queries in terms of CQRS and the single source of True (source of updates). Under the hood,UpdateChannel
may subscribe to updates from DB, transform data and deliver it further.UpdateDispatcher
. The responsibility: listening toUpdateChannel
in a separate Thread (because the number of events is so big), distributing events to relative handlers (handlers are working in separate ThreadPool to avoid pauses inUpdateChannel
thread).The text was updated successfully, but these errors were encountered: