Design Instagram

Difficulty: EASYCategory: LLDFrequency: 1Asked On 2025-02-03

Problem Statement

Design a simplified, scalable, and production-ready backend system for Instagram that supports core functionality such as users, following, posting photos, and viewing feeds. Your implementation should focus on clean code structure, concurrency handling, and modularity to reflect a production-grade system.

🎯 Functional Requirements

You are required to implement the following core features:

1. createUser(String username)

Creates a new user with a unique username.

2. follow(String follower, String followee)

Allows one user to follow another.

3. unfollow(String follower, String followee)

Allows a user to unfollow another.

4. postPhoto(String username, String photoId)

Allows a user to post a photo. Each photo has a unique ID.

5. getFeed(String username)

Returns a list of the most recent posts from the user and the people they follow.

Posts should be sorted by most recent first.

Solution

Comments