How To Build Social Media Site From Scratch (Facebook / Twitter )

Hi, Users

I’m building Social Media Site from Scratch .But its not well structured .

Feature I need .

Home Feed -
1 I need Pagination,

2 How to design db and get User Home feed
User feeds
+ Friends Feed (with there privacy for all feed , for single feed (privacy)
+ get share post also
with ascending order

Im also implementing share post feature .
im just duplicated the share post (with shared user id , which is not good )
( how twitter handling it share post )

Friends -
Comments -

Chat System - Real Time (like Facebook ) – Need Help
How to design DB for this (single and group chat )
Which technologies use for this .

Privacy Settings - User Profile Settings
For Email (Friends , Public , Private )
Address (Friends , Public , Private )
Feeds (Friends , Public , Private )

                    When User Create Feed it also set feed Privacy (Friends , Public , Private )

This is a vast topic. I would probably take a course on it. This one looks pretty good.