Real-time Chat Application Design: Architecture and Workflow

Kacper Bąk
8 min readApr 8, 2023

In this diagram, I have four entities: ChatService, Message, Sender, and Receiver. The ChatService is responsible for sending and receiving messages, and it provides two methods for doing so (sendMessage and receiveMessage).Message represents a message object with properties such as id, sender, receiver, content, and timestamp. The Sender and Receiver classes represent the clients who use the chat service to send and receive messages, respectively.

The diagram shows that a Sender creates a Message object and sends it to the ChatService by calling the sendMessage method. The ChatService then handles the message and sends it to the intended Receiver, who receives the message by calling the receiveMessage method.

Overall, this diagram shows the basic relationship between the Sender, Receiver, and ChatService in a chat system.

In this diagram, the user sends a polling request to the client, which then sends the request to the server. The server retrieves data from the database and sends it back to the client, which then sends the data back to the user. This is a simple example of how polling works in a client-server architecture.

In this design, the client initiates the Long Polling by sending a request to the server. The server waits for events to occur or for a timeout to happen. If an event occurs, the server sends a response to the client and closes the connection. The client then processes the response and initiates a new Long Polling request to wait for more events.

This design shows the basic flow of a Long Polling sequence, where the client and server maintain a persistent connection to enable real-time communication.

--

--