This project is a simplified version of Reddit, featuring subreddit timelines, user subscriptions, post submissions, upvotes, comments, and user profiles.
- Subreddit Timeline: Posts are ordered by recency of creation time.
- User Subscriptions: Users can subscribe to and submit posts to subreddits.
- Upvotes and Comments: Each post can receive upvotes and comments.
- User Profile: Displays all the subreddits a user subscribes to and all upvotes they have received.
Endpoint: GET /subreddits/{subreddit_id}/posts
Description: Retrieve posts from a specific subreddit ordered by the recency of their creation time.
Parameters:
subreddit_id(required): ID of the subredditlimit(optional): Number of posts to retrieveoffset(optional): Offset for pagination
Endpoint: POST /users/{user_id}/subscriptions
Description: Subscribe a user to a subreddit.
Parameters:
user_id(required): ID of the usersubreddit_id(required): ID of the subreddit to subscribe to
Endpoint: DELETE /users/{user_id}/subscriptions/{subreddit_id}
Description: Unsubscribe a user from a subreddit.
Parameters:
user_id(required): ID of the usersubreddit_id(required): ID of the subreddit to unsubscribe from
Endpoint: POST /subreddits/{subreddit_id}/posts
Description: Submit a new post to a subreddit.
Parameters:
subreddit_id(required): ID of the subreddituser_id(required): ID of the user submitting the posttitle(required): Title of the postcontent(required): Content of the post
Endpoint: POST /posts/{post_id}/upvote
Description: Upvote a post.
Parameters:
post_id(required): ID of the postuser_id(required): ID of the user upvoting the post
Endpoint: POST /posts/{post_id}/comments
Description: Add a comment to a post.
Parameters:
post_id(required): ID of the postuser_id(required): ID of the user commentingcontent(required): Content of the comment
Endpoint: GET /users/{user_id}/profile
Description: Retrieve the user's profile, including subscribed subreddits and received upvotes.
Parameters:
user_id(required): ID of the user
-
User
user_id(Primary Key)usernameemailpassword_hash
-
Subreddit
subreddit_id(Primary Key)namedescription
-
Subscription
subscription_id(Primary Key)user_id(Foreign Key to User)subreddit_id(Foreign Key to Subreddit)
-
Post
post_id(Primary Key)subreddit_id(Foreign Key to Subreddit)user_id(Foreign Key to User)titlecontentcreation_time
-
Upvote
upvote_id(Primary Key)user_id(Foreign Key to User)post_id(Foreign Key to Post)
-
Comment
comment_id(Primary Key)post_id(Foreign Key to Post)user_id(Foreign Key to User)contentcreation_time
Problem: High traffic on popular subreddits can cause delays in loading the timeline due to the large volume of posts.
Solution: Implement caching strategies for frequently accessed subreddits and use pagination (also known as paging) to load posts incrementally.
Problem: Unauthorized access to user data and actions (e.g., upvoting, commenting) due to inadequate authentication and authorization checks.
Solution: Implement robust authentication (e.g., OAuth or FireBase) and authorization mechanisms to ensure users can only perform actions they are permitted to and can only access their own data.
Problem: Unauthorized access to user data and actions (e.g., upvoting, commenting, unauthorized login) due to inadequate authentication and authorization checks.
Solution: Implement robust authentication (e.g., OAuth or FireBase) and authorization mechanisms to ensure users can only perform actions they are permitted to and can only access their own data.