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:
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 Toolkit. A 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:
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”