Skip to content

Chat App Discussions #13

@matzuk

Description

@matzuk

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

  1. 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.
  2. 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.
  3. 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions