---
# System prepended metadata

title: Vivek Kushwaha

---

# Vivek Kushwaha | R2
- Solved the System design for click events
- Solved the basics of chat system
- Both the solutions have scaling issue. 
- 

# Question 1: HLD : capture click events : clevertap

Website/App - > users active

capture click events.


id: 
session_id:
enevt type: button click/ coupons / 
time_spent:
created:



client -> load balancer -> event tracking service -> DataBase
        


# Question 2: Chat System

1<>1 chat
text messages.

- list of conversations
- list of messages


Chat:
id: uuid
created_at: timestamp


user_caht:
user_id: uuid
chat_id: uudi

message:
id: uuid
chat_id: uuid
message: text
sent_by: uuid
created_at: timestamp

list of 
:

select chat_id, max(created_at) as latest_message from user_chat join message on message.chat_id=user_chat.id  where user_chat.user_id = <my_user_id> group by chat_id order by latest_message desc;

