Architecture : How would you go about building an activity feed like Facebook?

View original thread
Jos Fabre's photo

Doesn't matter which database or frontend framework. Start with data structure. For scalability purpose I would probably have many cross tables to link data, or the possibility to link to different tables from inside other tables, so changing structures is not so hard later on. Than choose a framework/orm/dbal that can easily create links and associations. E.g. just a quick mindsnippet:

user (id, role, state, personal data)
group(id, name, data)
x_user_group(user_id, group_id)
post (id, type, date, author, content)
x_post_group(post_id, group_id)
media (id, type, author, ...)
x_post_media (post_id, media_id)    
related (table, row1_id, row2_id) {every object can be related to others of that type}
follow(id, user_id, table, row_id) {user can follow users, posts, new types later on...}
comment(id, table, row_id, author, content)

Then you can create an activity feed based on who and what user follows and relations and comments for those objects

Show all replies
Michael J. Ryan's photo

It's not a gazillion records it's a gazillion users requesting different subsets of data across join operations.