Architecture-Live Chat
Architecture-Live Chat
Architecture-Live Chat
chat tool
1 Chat Architecture: How We Approach It
A chat consists of two major parts:
Both parts contain various components that commuCustomer ate to each other and
bring the chat into action.
Chat Server Engine is a core of the chat architecture that handles message delivery
and dispatch. In our version of chat architecture, it includes the following
components:
Chat REST API handles the tasks that are not connected directly to message
dispatch and delivery, such as user authentication, changing of user settings,
friend's invitation, downloading sticker packs, etc. The Chat App (the chat
client part) commuCustomer ates with the Chat REST API via the Chat REST
API Client Library.
Chat WebSocket Server is responsible for transmitting messages between
users. The Chat App commuCustomer ates with the Chat WebSocket Server
via the Chat WebSocket Client Library. This connection is open two ways;
that means users do not have to make requests to the server if there are any
messages for them; they just get them right away.
Chat Media Storage Server is a pool of servers responsible for storing user
media files. The files are uploaded to them via the Chat Media Storage
Client Library.
Chat App is the other major part of the chat architecture, the one that users directly
interact with. It is split into three separate root components:
Chat Client Engine handles all of the commuCustomer ation with the Chat
Server Engine via its internal components: Chat REST API Client Library,
Chat WebSocket Client Library and Chat Media Storage Client Library. It also
comprises the Chat Push Message Handler that deals with push
notifications.
Chat UI displays data to users via its widgets: Chat Contact List UI, Chat
Dialog UI, Chat Push Message Widget—extension for mobile apps that
allow for replying to messages without opening the app and Chat Internal
Notification Widget—a widget that pops up at the top of the screen while the
user is chatting in a dialog and notifies about the incoming message in
another dialog.
Chat Device Storage is an internal database (read: your device storage),
which stores messages and files so that users can access them offline. Its
internal component, Chat Media Cache, gets media files from the Chat Media
Storage and stores them on the device so that the user can access them
anytime without having to reach the Chat Media Storage every time.
Reusability. When the chat components are designed separately, they can
be easily reused in other projects.
Scalability. Each architecture component is a potential bottleneck when a
project grows bigger and begins to serve a larger audience. The advantage of
independent components is that they can be scaled separately without
affecting the entire architecture.
Integration. Independent components can be easily integrated with the
customer’s services upon request. For example, if the customer wants user
files to be stored in their CRM, you can integrate the CRM with the Chat
Media Storage without having to change the entire architecture.
Customization and migration. All the architecture components can easily be
adjusted to the customer’s needs. For example, they can be powered by
different services: the Chat WebSocket Server can be built on PubNub, Twilio,
or Firebase, while Cloud nary or Amazon S3 can power Chat Media Storage.
Alternatively, you can build any of the components entirely from scratch if you
need them to perform specific tasks.
The same is true for migration. If you want to migrate one component to another
service, you can do so without disturbing the rest of the components. We have seen
it ourselves when we migrated one of our products, Famlicious, from one service to
another.
1.1.2. Architecture
When a client gets connected to the Chat server the User map is
updated, having the entry of the username, public name, server’s
name, and status. In this map, we store client’s minimal
.information which needs to be fetched frequently
In the Group Map, we store all the group with their members.
While sending a message to a group, we could fetch the recipient
.of the messages
The operator will receive the conversation request, and send answer to the
customer (the system will generate a CSRF token for the operator)
Unpredictable with high entropy, as for session tokens in general.
Tied to the user's session.
Strictly validated in every case before the relevant action is
executed.