Netflix-like System Design

Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2019-06-03

Problem Statement

Designing a Netflix-like video streaming platform that allows users to browse, stream, and manage video content. The focus is on object-oriented design, modular architecture, content management, and streaming workflow.


✅ Functional Requirements


1.User Management
•Register, login, and manage user profiles.
•Track user subscriptions and preferences.
•Maintain watch history for each user.
2.Content Management
•Store and manage movies, series, episodes, and trailers.
•Metadata includes: title, genre, duration, releaseYear, rating.
•Support categorization and search/filtering by metadata.
3.Streaming & Playback
•Stream video content to users.
•Support adaptive streaming based on network bandwidth.
•Track playback progress per user for resuming.
4.Recommendations (Optional)
•Suggest content based on user watch history and preferences.
5.Search & Browse
•Search content by title, genre, or actor.
•Browse categories like Trending, Top Picks, Recently Added.
6.Optional Features
•User ratings and reviews.
•Watchlist / Favorites management.
•Multi-device support.


🔐 Constraints & Assumptions


•Focus on LLD, class design, and modular components, not on CDN, caching, or backend scaling.
•Assume video storage and streaming servers exist.
•Streaming logic can be simplified to fetch video URLs and maintain playback state.


🧱 Key Components & Classes


1.User Class
1 2class User { 3private: 4 string userId; 5 string name; 6 vector<string> watchHistory; // list of videoIds 7 Subscription* subscription; 8public: 9 void addToHistory(string videoId); 10 void updateSubscription(Subscription* subscription); 11};
1.Video Class
1 2class Video { 3private: 4 string videoId; 5 string title; 6 string genre; 7 int duration; // in minutes 8 string url; // streaming URL 9public: 10 string getMetadata(); 11};
1.Series & Episode Class
1 2class Series { 3private: 4 string seriesId; 5 string title; 6 vector<Episode*> episodes; 7public: 8 vector<Episode*> getEpisodes(); 9}; 10 11class Episode : public Video { 12private: 13 int episodeNumber; 14public: 15 int getEpisodeNumber(); 16};
1.Subscription Class
1 2class Subscription { 3private: 4 string subscriptionId; 5 string planType; // Basic, Standard, Premium 6 DateTime startDate; 7 DateTime endDate; 8public: 9 bool isActive(); 10};
1.StreamingService Class
•Handles video streaming requests and playback state.
1 2class StreamingService { 3public: 4 void playVideo(User* user, Video* video); 5 void resumeVideo(User* user, Video* video); 6};
1.RecommendationService (Optional)
•Suggests videos based on user preferences and watch history.
2.SearchService Class
•Allows searching videos by title, genre, or metadata.


🔄 Example Workflow


1.User logs in → User object loaded.
2.User selects a video → StreamingService.playVideo() invoked.
3.Playback progress is tracked → User.addToHistory() updates watch history.
4.User searches for content → SearchService returns filtered results.
5.Optional: RecommendationService suggests new content based on watch history.


🧪 Expected Deliverables


•Class diagram showing User, Video, Series/Episode, Subscription, StreamingService, and SearchService.
•Implementation of video playback, watch history, search, and optional recommendations.
•Test cases:
•Play a video and track progress
•Resume video playback
•Search videos by metadata
•Subscription status handling
•Watch history updates


💡 Discussion Points


•Extensibility: adding new content types or multi-language support.
•Scalability: streaming multiple users simultaneously (abstracted in LLD).
•Concurrency: handling multiple playback requests per user.
•Recommendations: simple rule-based or ML-based logic for personalization.


Solution

Comments