May 11, 2019

Building a social network from scratch


Ever wonder why the traffic of Facebook is so high? Perhaps it helps to understand it by creating social networks by your own. The first step in doing so is to program a RSS feedreader. The simplest one which is available is given in the following mini python program.
import feedparser
url="rss.xml"
feed = feedparser.parse( url )
items = feed["items"]
for item in items:
  title = item[ "title" ]
  url = item[ "link" ]
  print "#",title
  a="["+url+"]("
  b=url+")"
  print a+b+"\n"
The feedreader takes a given RSS file and converts the items into the markdown syntax. The second step is create a second Python script which combines different RSS files into one. The well known planet feedreader has demonstrated this ability in the past but the easier to understand way is to program the script from scratch. Now the software is able to generate of a large variety of RSS feeds a markdown textfile. But what has this to do with a social network? Right, what is missing is a personalized account system. The user needs a button to login, and then he can select some criteria to get a certain subfeed.
Such a system is equal to what is known as Facebook timeline. That means, each user in the system has a profile. User1 for example has an ini file which contains: robotics+python, while user2 ini file is: machinelearning+vision. And the feedreader is providing according to the keyword the correct newsfeed.
To make the social network more pleasent the next needed fucntion (which has to be programmed in a script language for example php or python) is to create an upvote/downvote database. The user can press the upvote button on a certain item from the RSS feed, and this decision is stored in the internal database. As a result, user2 can see how often user1 has pressed the button.
Last but not least, a commenting function is needed which is also linked to the items of the RSS feed. This allows the user to annotate an item with a textual description. If extra groups are added we have a fully working social network which can be used in the intranet.
Let us go a step backward and ask how a minimal social network looks iike. It starts everything with a RSS feedreader which is producing HTML code. A desktop application which displays the RSS feed in a GUI is called a feedreader while a server application which redirects the feed to a HTML page is called social network. The term social network is referencing to a website in the internet which has a news aggregation feature. News aggregation is equal to combine different RSS feeds to a new one, this is called a mashup or content curation. The other well known features like user management, upvote buttons and commenting are added to the feedreader later.
Is Facebook a website in which people can read together websites? Yes, this is Facebook. They can login into the website, see the annotated RSS feed on the screen and add a comment. What makes Facebook different from a blog is, that Facebook aggregates the entire internet. That means, different blogs are part of Facebook, but Facebook can't be embedded into a blog. The reason is, that social networks are meta websites while blogs are content websites.
Let us take a look to a project which can be called a prototype social network, https://github.com/dg/rss-php is a RSS feedreader plugin for php. PHP is a very good language for webservice programming. Around this script the other features like user login can be created and voila, the resulting software is a full social network. The only thing what is missing is some traffic but this can be generated with a php script as will. The technology is called autoposting. Because the social network sourcecode is known, it is very easy to fill the database with non-sense spam. The users will feel like in heaven, because the content gets updated every hour.
The reason why this minimal social network will get very soon real users is because a social networks allows the users to stay on top of the world. In a normal weblog or online-forum the user sits inside the small website. On the other side an evil admin is there and if the user says something against the forum he gets banned. In social networks the user looks down to existing websites. If he doesn't like a certain article from a blog he can downvote the article. Not in the comment section within the blog which is manipulated, but with the comment section of the social network. This brings the reader into a very powerful position. A single social network aggregates different blogs, but a single blog gets a slashdot effect from the crowd.
I'm not the first one who describes who social networks are working. A practical project which has realized the described functionality already is called Feedly. Feedly was started as a Feedreader and later some user login features were added. The today's feedly looks very similar to all the mainstream social networks. The difference is, that it makes more clear what a social network is. The term feedly is superior to the term social, because in the core an RSS feed is needed, the user doesn't have the top priority. Sure, somebody may arguen, that in Feedly the user can upload a profile picture and provide his full name. But the software will work without these information as well. The only thing what feedly needs to know is the RSS stream to curate the timeline. Without the RSS stream, feedly won't work.

No comments:

Post a Comment