Cleartrip SDE-2 Machine Coding F2F

cleartrip logo
cleartrip
SDE-2
October 11, 202527 reads

Summary

I recently had a machine coding interview at Cleartrip for the SDE-2 role. The challenge involved designing and implementing a real-time order notification system to alert various users about significant order lifecycle events.

Full Experience

I recently interviewed at Cleartrip for an SDE-2 position, which included a machine coding round. The objective was to design and implement a real-time order notification system for an e-commerce platform. This system needed to alert various users like customers, sellers, and logistics partners about significant events in an order's lifecycle, with a focus on extensibility.

The core requirements involved handling three primary order event types: 'Order Placed', 'Order Shipped', and 'Order Delivered'. Different stakeholders were interested in specific events: customers for all three, sellers only for 'Order Placed', and logistics only for 'Order Shipped'. Critically, notifications were only to be sent to stakeholders linked to a particular order.

The system also needed to support multiple configurable notification channels, such as Email, SMS, and App Push. I had to implement functionalities allowing stakeholders to subscribe to specific event types with preferred channels, and manage these subscriptions by unsubscribing or adding/removing channels.

Bonus requirements included implementing an 'Event replay' feature for specific orders, event types, and stakeholders, ensuring concurrency handling for subscription management, and designing the notification sending process to be asynchronous and non-blocking.

Interview Questions (1)

Q1
Design Real-Time Order Notification System
System DesignHard

Objective Develop a real-time order notification system for a modern e-commerce platform. The system should alert various users (customers, sellers, logistics etc) about significant events in an order's lifecycle. The system must be designed in an extensible manner so that more users can be easily accommodated in the future if needed.

Requirements Handling Event : Implement a system that handles three primary order events types

  • Order Placed: Triggered when a customer successfully creates an order.
  • Order Shipped: Triggered when the seller ships the package.
  • Order Delivered: Triggered when the logistics partner confirms delivery.

Messaging Stakeholders : The system must notify different types of subscribers, each interested in specific events:

  • Customer: Should be notified of all three events (Order Placed, Order Shipped, Order Delivered).
  • Seller: Should only be notified when an order is placed.
  • Logistics (Delivery Partner): Should only be notified when an order is shipped to manage the delivery.
  • Only stakeholders linked to a particular order should be notified

Notification Channels : The system must support multiple channels for sending notifications. The choice of channel should be configurable. For example, it could be possible that the customer is receiving only mails for order getting placed. Types of notification channels could be

  • Email Notification
  • SMS Notification
  • App Push Notification

Functional Requirements

  • Subscribe to Event:

    • Allow a stakeholder (e.g. a Customer) to subscribe to notifications for a specific event type with preferred channels of choice (e.g an Email).
    • Notifications should only be sent to Stakeholders linked with a particular order.
  • Manage Subscriptions : Stakeholders should be able to

    • Unsubscribe from Event : Allow a stakeholder to unsubscribe from notifications for a particular event type. Once any stakeholder unsubscribes from a particular event type, they will not receive any notification for any order for that particular event type.
    • Add / Remove Channels : A stakeholder should be able to manage their preferred channels for receiving notifications i.e add or remove channels as per choice. (It can be assumed that by default all the channels would be enabled by default for any user)

Bonus Requirements:

  • Event replay : Implement a feature to replay the notification events for a particular order id, event type and stakeholder.

    • When we replay a certain event, the stakeholder will receive the message on all the subscribed channels again for that particular order. For example if I can replay an Order delivery message for the Order - 001 for the Customer who had subscription on Email and Phone, The tagged customer with that particular order will receive the message on Email and Phone.
    • The preferred channels for stakeholders during replay should be the latest preference on each subscription. For example, if customer A had Email and App push notification as preferred channels for Order 0 while getting notifications initially and later changed it to SMS only, the replay would only include SMS notifications.
  • Concurrency : Handle cases related to user concurrency where multiple stakeholders could be trying to add / remove subscriptions

  • Asynchronous : The notifications should be sent in a non-blocking manner for the order system.

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!