Design the Feeds section of a social media application (like Instagram or Facebook) that allows users to see posts from friends, followed accounts, or recommended content in a personalized order.
Focus on object-oriented design, class relationships, and service interactions rather than distributed scalability (HLD is separate).
Functional Requirements (FR)
1.Post Management
•Users can create, edit, and delete posts (text, images, videos).
•Each post has metadata: author, timestamp, content type, media URLs, tags, privacy settings.
2.Feed Generation
•Fetch posts from followed users/friends.
•Optionally include recommended posts (ads or popular posts).
•Support chronological or relevance-based ordering.
3.Interactions
•Like, comment, and share posts.
•Track counts for likes, comments, and shares.
4.Notifications
•Notify users about likes, comments, or shares on their posts.
5.Pagination & Infinite Scroll
•Load posts in pages or via infinite scrolling.
•Support fetching more posts efficiently.
Non-Functional Requirements (NFR)
•Low Latency – Feed should load in under 200ms for active users.
•Consistency – Interaction counts (likes/comments) should be accurate.
•Thread Safety – Handle concurrent updates to likes, comments, and posts.
•Extensibility – Easy to add new content types or ranking algorithms.
Core Entities & Attributes
Entity Key Attributes
User userId, name, profilePicture, friendsList, followingList
Post postId, authorId, content, mediaUrls, timestamp, tags, privacy, likeCount, commentCount, shareCount
Comment commentId, postId, userId, content, timestamp
Like likeId, postId, userId, timestamp
Feed feedId, userId, list of Post references, lastUpdated
Service Layer / APIs
UserService
•followUser(followerId, followeeId)
•getUserDetails(userId)
PostService
•createPost(authorId, content, mediaUrls, tags, privacy)
•editPost(postId, newContent)
•deletePost(postId)
FeedService
•getFeed(userId, page, limit) → Returns posts in order.
•updateFeed(userId, newPost) → Updates feed when a new post is created.
InteractionService
•likePost(userId, postId)
•commentPost(userId, postId, content)
•sharePost(userId, postId)
Expectations in LLD
•Class Diagram – Show classes like User, Post, Comment, Like, Feed with associations.
•Service Logic –
•How posts are added, retrieved, and updated.
•Handling feed generation per user.
•Maintaining accurate like/comment counts.
•Design Patterns –
•Observer for notifying feed updates.
•Factory for different post types (image, video, text).
•Concurrency Considerations –
•Thread-safe updates to likes, comments, shares.
•Safe addition/removal of posts in feeds.
•Trade-offs –
•Real-time feed updates vs batch updates.
•Pre-computed feed vs on-demand feed generation.
✅ This LLD problem tests:
•OOP and class design skills
•Service interactions for content and user engagement
•Concurrency handling for social interactions
•Understanding of feed personalization and updates