**
Design website like stack over flow
Replay , comments
Requirement:
-
User should able to post their queries
-
Other users should be able to respond/comment to the queries
-
Users can upvote or downvote
-
Delete and update post and comment.
-
If deleted post delta comments as well
-
Post can have tags buildin or custom tags
-
Feed for user
Non-Functional
-
Read is most compared to post
-
Latency can take a hit.
-
data should not be lost
-
Page load should be fast: within 5 ms
-
Size of post should be restricted 10KB
-
Comment chain limit 10
Estimates:
1M post /per day = 1M/86000 = 10/sec
5M read per day = 50/sec
Entities:
User
{
interestTag:[tech, new]
userId
userName
}
Tag{
Name
id
}
User Post
{
userId
postId>>>> question Id
String post details
upVote
Downvote
Tag id
createtime
}
User answers
{
userId
answerId
questionId>>>> question
String post details
upVote
Downvote
Tag id
createtime
}
User post comments
{
questionId
answerId
commentId
String comment
comments:[{createdTime, commentId}]
createtime
}
Ans:
{
postId
Ans
}
Q1-
A2
A
AX, AY
B
BX, By,BZ
C
A3
A4
**
_**How do we maintain Nested comment hierarchy?
Adjacency list Nested Set Model Closure Table