4. Pick implementation technology
The SoMa application is an ASP.NET MVC 4 project that will expose a REST API.
The main reasons we chose this technology are:
Provides Templates for MVC applications and Web APIs. This make it faster to develop
reliable Web APIs and applications.
The .NET Platform provides lots of libraries to work with.
Twitter Bootstrap is available as a NuGet package. Fast front-end development framework.
Uses LESS.
Also, NuGet packages for working with the Twitter and Flickr APIs.
Bing Maps are integrated in the .NET Framework.
Visual Studio Add-Ons for better development: Productivity Power Tools 2012.
Fast deployment to Windows Azure and reliable cloud service.
5. Pick Domain
Picked Domain Name! See us at: http://soma.azurewebsites.net/
Hosting in the
using
6. Synonyms providers analysis – complete analysis here
Thesaurus - HTTP GET request to http://thesaurus.altervista.org/thesaurus/v1
Parameters: word, language, application key, response type
Request example: http://thesaurus.altervista.org/thesaurus/v1?word=finish%20line&language=en_US&key=u8JKaOitVKHOahvUs&output=xml
Response:
<response>
<list>
<category>(noun)</category>
<synonyms>finishing line|line|finish|destination|goal</synonyms>
</list>
</response>
Pros:
Provides pretty accurate synonyms
The results don't require heavy processing
One synonym list for each definition (synset) of a word -> limit searches to the most relevant ones (or the most likely to be relevant) -> only consider
the main and most common synset.
7. Synonyms providers analisys
The Synonyms API from STANDS4 - offers a web API for retrieving synonyms, thesaurus information and antonyms of a given word.
Parameters: API user id, developer token id, word
Request example: http://www.stands4.com/services/v2/syno.php?uid=1001&tokenid=tk324324&word=doctor
Response
<results>
<result>
<term>doctor, doc, physician, MD, Dr., medico</term>
<definition>a licensed medical practitioner</definition>
<example>"I felt so bad I went to see my doctor"</example>
<partofspeech>noun</partofspeech>
<synonyms>doc, medico, doctor, physician, mendelevium, medical student</synonyms>
<antonyms/>
</result>
[...]
</results>
More information:
Less accurate synonyms
The most widely used synset is given as the first result
8. REST API – complete documentation here
Created a REST API for SoMa that includes hypermedia controls.
Exposing 2 main resources:
/websites - Resource representing all the websites supported by the SoMa application. For
the moment, we decided on Twitter and Flickr. If the time allows it, we will also support
Vimeo.
/resources - Generic name for all content downloaded from the supported websites: posts,
tweets, pictures, videos, etc.
API Key required in order to prove the authenticity of the requests and to limit
their number. This should protect the application from attacks like Denial of
Service.
To get all the available websites supported by the application a GET Request can
be made to the /websites resource.
9. REST API
GET request to: /websites?key={INSERT_YOUR_KEY} => Response:
[{
"Name":"Flickr",
"Links":
[{
"Rel":"linkrels/websites/query_by_tag",
"Uri":"/websites/flickr"
}]}, {
"Name":"Twitter",
"Links":
[{
"Rel":"linkrels/websites/query_by_tag",
"Uri":"/websites/twitter"
}]
}]
10. REST API
To query, for example, new photos a POST request can be made to /websites/flickr that
contains in the POST body one or more of the following parameters:
Name
tag
max_no_entries
key
use_synonyms
ignore_previous
Definition
The tag you want to search for. For example: cat.
The maximum number of the entries from the response.
A valid API Key is needed in order to use the REST API.
The API implicitly make use of synonyms but if it is wanted this can be disabled
by using the parameter with the ‘false’ value like: use_synonyms=false
The API implicitly uses previous search results (if they exists) to provide faster
access to resources. If the ignore_previous parameter is used with the value
‘true’ the previous stored content (if it exists) will be deleted and a new search
will be made for the provided tags.
The user has also the possibility to make a DELETE request in order to remove
from the cache the information stored for a specific tag.
11. REST API
To retrieve, for example, the photos associated with a tag a GET request can be made to:
/resources/photos/{tag}?key={INSERT_YOUR_KEY}. Possible result:
[{
"PhotoName":"BlackCat.jpg",
"Id":"f9299cb7d7a9b9c3f57b83461c541a24",
"Url":"http://www.flickr.com/photos/doug88888/5717852049",
"Website":"flickr",
"Links":
[{
"Rel":"linkrels/resources/photos/get",
"Uri":"/resources/photos/cat/f9299cb7d7a9b9c3f57b83461c541a24"
}] }, {
"PhotoName":"Cat.jpg",
"Id":"f2fb87bbad9d093c5a631b548be70c8f",
"Url":"http://www.flickr.com/photos/ronanmccormick/9837068194",
"Website":"flickr",
"Links":
[{
"Rel":"linkrels/resources/photos/get",
"Uri":"/resources/photos/cat/f2fb87bbad9d093c5a631b548be70c8f"
}]
}]
12. REST API
The user has also the possibility to request an individual resource using the tag
and the id of that resource. For example, using the URL provided in the previous
response he can request more information by making a GET request to:
/resources/photos/cat/f2fb87bbad9d093c5a631b548be70c8f?key={INSERT_YO
UR_KEY}. The response may be:
{
"PhotoName":"Cat.jpg",
"Id":"f2fb87bbad9d093c5a631b548be70c8f",
"Url":"http://www.flickr.com/photos/ronanmccormick/9837068194",
"Website":"flickr",
"Author":"Ronan McCormick“
}
13. Architecture & Design – complete documentation here
Application created using the concept API First. The front-end makes use of the REST API in
order to complete user requests.
Resource Models - general (Resource) and specific classes (PhotoResource,
MessageResource) stored in specific repositories (MessagesRepository, PhotosRepository).
Resources are stored organized after their tag and id.
The retrieved information is Cache persistent. In order to save cache space the photo content
is not downloaded but only referenced by Url inside the resource model. The content will be
downloaded and displayed on Bing Maps at the load time of the information on the page.
Repositories for storing resources:
Repository: abstract class that contains the cache keys used in identifying the stored information
for the application;
MessageRepository: stores the information regarding the messages obtained from Twitter;
PhotosRepository: stores the information regarding the photos obtained from Flickr;
14. Architecture & Design
SynonymsProvider – supports the interaction between the application and the service
used for obtaining synonyms;
FlickrSearch – Supports the interaction between the application and the Flickr service;
TwitterSearch – Supports the interaction between the application and the Twitter
service;
WebsitesController – Provides access to the /websites resource representing the
resources stored by the application.
FlickrController – Processes the POST requests sent using the /websites/flickr endpoint
of the REST API.
TwitterController – Processes the POST requests sent using the /websites/twitter
endpoint of the REST API.
15. Architecture & Design
ResourcesController – Provides access to the /resources endpoint representing
the resources stored by the application.
PhotosController – Processes GET and DELETE requests sent using the
/resources/photos endpoint of the REST API.
MessagesController – Processes GET and DELETE requests sent using the
/resources/messages endpoint of the REST API.
The Class Diagram for the soma Project can be found here.
A Sequence Diagram representing a request being made with a specific tag for
receiving messages from Twitter can be found here.
The complete documentation of SoMa’s Architecture & Design that also
contains microdata can be found here.
16. Prototype
A demo is up and running at : http://soma.azurewebsites.net/
Any of the following requests can be tried:
Retrieve supported websites:
http://soma.azurewebsites.net/api/websites?key=lro2e32
Retrieve resources types:
http://soma.azurewebsites.net/api/resources?key=lro2e32
Retrieve photos for the ‘cat’ tag:
http://soma.azurewebsites.net/api/resources/photos/cat?key=lro2e32
17. MidTerm Evaluation
Blog available at: http://wadesoma.wordpress.com/
SoMa website: http://soma.azurewebsites.net/
Source Code available at: https://wadesoma.codeplex.com/
Documentation available at: http://students.info.uaic.ro/~irina.grosu/soma/