Design a Stock Broker System

Difficulty: MEDIUMCategory: HLDFrequency: 1Asked On 2025-05-22

Problem Statement

Functional Requirements:

1.Stock Subscription: Users can subscribe to one or more stocks from a predefined list.
2.Rule Creation: Users can define custom rules for each stock, e.g.:
3."Notify me if price of Uber goes above $60"
4."Alert if Tesla drops below $500"
5.Real-Time Stock Monitoring: Continuously monitor stock prices and evaluate user-defined rules.
6.Trigger Notification: When a rule is violated, send a notification to the corresponding user (email, SMS, push, etc.).
7.Manage Subscriptions: Users can update, delete, or pause rules and subscriptions.


Non-Functional Requirements:

1.Low Latency: Notifications should be triggered in near real-time.
2.Scalability: Handle millions of users and stock-price updates per second.
3.Reliability: Ensure no missed notifications or duplicate alerts.
4.Extensibility: Support new rule types (e.g., percentage change, moving average) in future.


Scope of the Design:

Design the architecture and major components such as:

1.User Service (manages subscriptions and rules)
2.Stock Price Stream Processor (ingests real-time stock data)
3.Rule Engine (evaluates stock data against user-defined rules)
4.Notification Service (sends alerts)
5.Storage Layer (stores user rules and subscriptions)


Discuss:

1.How to handle high-throughput stock feeds
2.Efficient rule matching and evaluation
3.Failures and retries in notifications


Asked in many interview experiences:

https://www.interviewstop.com/InterviewPrep/InterviewExperiences/uber-l4-bangalore-offer-2?company=Uber&role=Software+Engineer+II

https://www.interviewstop.com/InterviewPrep/InterviewExperiences/uber-l4-interview-process-1?company=Uber&role=Software+Engineer+II

https://www.interviewstop.com/InterviewPrep/InterviewExperiences/uber-sde-2-offer-bangalore?company=Uber&role=Software+Engineer+II


Solution

Comments