Gooood :)))) now we are in part 3 - we wanna talk about Chat Service Architecture
A chat service consists of two major parts:
Chat App or client part, which is a desktop, web, or smartphone chat application.
Chat Server Engine or server part, which is a pool of external servers responsible for the chat operation. This is the place where all the chat magic happens.
Both parts contain various components that communicate 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. I want to show you all components in chat service:
Chat REST API handles the tasks that are not connected directly to message dispatch and delivery, such as user authentication, changing of user settings, friends invitation, downloading sticker packs, etc. The Chat App (the chat client part) communicates 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 communicates with the Chat WebSocket Server via the Chat WebSocket Client Library. This connection is open two ways; that means users donโt 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's split into three separate root components:
Chat Client Engine handles all of the communication 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.
So we need WebSocket protocol that makes it possible to open a two-way interactive communication session between the user's browser and a server. so you can send messages to a server and receive event-driven responses without having to poll the server for a reply.
In our project we create a websocket server with nodejs and a websocket client with Golang
References:
1) yellow.systems: Chat Service Architecture
2) developer.mozilla.org: WebSocket
In part 4 we are going to write our websocket server with nodejs๐
Top comments (0)