Keen Learner

The tale of a thirsty mind

Leave out all to ‘REST’ — June 14, 2016

Leave out all to ‘REST’

It has been sometime since I mentioned how Davide, Alessandro and me met our algorithm while working for Google Summer of Code project WikiToLearn:Ratings.
So now after the formulation of algorithm to calculate the Page Rating , it was the time to actually initialize a repository and start coding .So after some careful discussions about what language to use we narrowed down on JAVA to construct a RESTful API(Rest what?) .
This API will be requested for a Page’s Rating when a user will visit the page on the wiki platform. So how will our API work ? From where do we get the data? Will you store it somewhere? So before I spill the beans let us learn how to make a sandwich !

The Sandwich Architecture:

FN_sandwich-thinkstock_s4x3
MediWiki–RESTful API–OrientDB

So just like you have a top, juicy veggies and  a fine base in a sandwich our API too has a 3 layered architecture:

MediaWiki API <TOP>

One thing is certainly true that to actually generate some sort of rating we need to access the data stored in the MediaWiki servers. So we have a lot of client APIs  available. So after careful examinations of all my requirements I zeroed down on Wikdata ToolkitA wonderful client API with a great custom query support, just what I needed.So now we can easily access the MediaWiki database by simply manipulation the ApiConnection object returned by the API.This is great as we reduced our efforts of manually handling the Networking calls to the MediaWiki Database.

RESTful API <Juicy veggies>

This is the heart of our API this is the part that is responsible for all the computations  and request initiation and handling. So to achieve the REST architecture we used JAX-RS ideology and utilized Jersey framework. In the rest architecture everything is a resource. We can easily access a page by simply constructing a URL like:
http://en.wikitolearn.org/Main_Page

So we see that everything here is constructed like a directory structure similar to you computer at home. Well this is just one of numerous features of REST architecture.

Often when we make a project like this , we need to integrate existing pieces of technology to get optimal performance.So it was clear that we needed to import a great deal of libraries and JAR’s . This can be an intimidating experience ! Nobody wants to be a maze runner 😛 .Therefore to save ourselves from some trouble we use Build Tools.

We used Maven for this task. It’s so convenient to just add a dependency in the pom.xml build the project and Maven does all the hard work like downloads, imports etc for you.Further we used Apache Tomcat   to host our RESTful API.

OrientDB Graph API <Base>

So what do we do after we have done fetching the data and computing the results? Well we store them 😛 . So to achieve this I am using a Native Java API (Graph API) for handling the database efficiently.

So this was all about our Sandwich architecture. I am currently coding the RESTful API. My aim is to make a nexus  of all the elements like Pages, Users, Revisions which are linked by various suitable relations. You can find my work on our community repository, and before I sign off just a small thing to always remember while you code…

“The journey of a thousand commits begins with a single init”

geekhumor-ft

Advertisements
How I met our Algorithm! — June 5, 2016

How I met our Algorithm!

So I have successfully completed the community bonding period 😀 and it was 23, May 2016 when Davide, Alessandro and me decided to dig deeper into our Google Summer of Code project WikiToLearn:Ratings.

The best thing about this project is that we will be developing a piece of technology from scratch. Well, that excites me. Not only because this job is challenging but because when you have the liberty to build something starting from its very roots ,  when you have the opportunity to think about the whole architecture you feel really connected to your job.(Some Job Satisfaction here 😛 ).

Therefore we decided to begin the project by laying down the procedures and equations for computing the Rating of the pages. Basically the entire algorithm starting from a user voting for a page to the final display of the results.It took us 3 days to design the initial draft.The procedures defined here are quite rigorous but ultimately we were able to get a clear picture of what is supposed to be done and how.

The next step was to map the proposed mathematical model to code. That is to think of ways to access the database of WikiToLearn to get the desired information.
Now WikiToLearn uses MediaWiki so the next step was to get familiar with this platform and to find out how things work here. Sooner I found myself playing with the MediaWiki APIThis was a necessary step as we will be using the API to fetch the data that will be needed by the algorithm. So after some PHP scripting sessions I finally managed to understand what all information we can directly get from the API and what other things we needed to cook ourselves. So this was the proceedings of my first week of GSoC.

Therefore now when we have listed down all the items that we need to fetch we will be starting by writing down a service to fetch the data from the database via the MediaWiki API. So let’s begin the quest.

Gotta fetch ’em all !

😎

e663312cc594c51c8f8c9f1187519bed