@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:

- All requests are divided into two groups: Commands (change state but doesn't return) and Queries (doesn't change a state but return a state). This separation is visible in
MessageFeature. It's CQRS.
- All updates are coming from a special object called
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 to UpdateChannel 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 in UpdateChannel thread).
@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,UpdateChannelmay subscribe to updates from DB, transform data and deliver it further.UpdateDispatcher. The responsibility: listening toUpdateChannelin 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 inUpdateChannelthread).