A chat application enables real-time communication between users through text-based messages. It is commonly used in personal messaging, customer support, collaboration tools, and social networking platforms.
In this chapter, we will explore the low-level design of a simple in-memory chat application.
Let's start by clarifying the requirements:
Before starting the design, it's important to ask thoughtful questions to uncover hidden assumptions and better define the scope of the system.
Here is an example of how a conversation between the candidate and the interviewer might unfold:
Candidate: Should the application support both one-on-one and group chats?
Interviewer: Yes, it should support both types of conversations.
Candidate: Can the users edit or delete message after sending?
Interviewer: No. Once a message is sent, it cannot be modified or deleted.
Candidate: Should users be able to see their chat history?
Interviewer: Yes, the system should store and display full conversation history for each user.
Candidate: Should we support message delivery status indicators, such as sent, delivered, or read?
Interviewer: Not for this version. Just assume messages are delivered once they are sent. No need to track read receipts or delivery confirmations.
Candidate: Should the system preserve the order of messages?
Interviewer: Yes, messages must be delivered in the order they were sent.
After gathering the details, we can summarize the key system requirements.