Creating a Cloud application that runs on Bluemix and consumes a NoSQL Database and Watson services.

Hello everyone – It has been a long time since I wrote an article. A few years in fact and work has kept me very busy. I am now the Cloud Architect at IBM for the Bluemix Platform. I wrote a sample application that runs on Bluemix using a web application on a Tomcat Server that has web pages written in JavaScript and Java for the backend. I consume a DBaaS- Database-as-a-Service Cloudant DB. I also use the Watson language translation service.

The problem that I created for the above application to be the solution is as follows:

World renowned Chef Gabriel is one of the most famous chefs on the planet. His recipes are well sort after by everyone from every part of the world.

The demand for his amazing recipes is very high and because of this he would like to able to share them with everyone on earth regardless of the language that they speak. Furthermore Chef Gabriel constantly changes an updates his recipes as new ideas come to him. Chef Gabriel approach IBM looking for a solution to his problem.

Proposed solution:

IBM Architect Gabriel proposes that Chef Gabriel can store all his recipes in the SoftLayer Cloud using Cloudant a NoSQL DB(the exact details of the DB were not shared with the Chef as Chefs wouldn’t understand technical terms).

Chef Gabriel’s website can also be hosted within Bluemix(SoftLayer). The website will connect to the DB that houses all of his recipes. Since visitors to his site speak different languages we will make use of Watson Language Translator. This will enable all the visitors to choose the language that they want to view the recipe in. The Website application will then retrieve the language form the DB and then make a translation to the language that the visitor has chosen. The visitor to the website can then view the recipe in his preferred language.

Architecture diagram:


Sequence diagram:


The web application will retrieve the list of languages from Watson language Translator and the list of stored recipes in the Cloudant DB. This will then appear on screen and the visitor can select the recipe and the language he wants and the Web Application will retrieve that recipe and then have it translated in the relevant language.

My end result is a website that stores recipes. You can request a recipe in a language of your choice as long as that language is offered by Watson Language Translator.

There was one work around I had to implement because Cloudant DB did not seem to allow one to, via the Java SDK, write the ids for the documents in the database. It only allowed them to be auto generated. Hence I had to retrieve all the recipe documents in order to get the name of a particular recipe. This would be processor intensive and affect performance for large scale systems. Fortunately this is a demo. However please note I am aware of this facets.

The technologies I used were:

  • REST based HTTP/HTTPS calls,
  • JQuery- for the webpage
  • Gson for JSON.
  • CSS- for stylesheets
  • Java – for the backend
  • Cloudant noSQL- for the database
  • Watson Language translator – for the language translation.

I include a diagram of the UML that shows the relationship between the RecipeRequest and Recipe and Language objects. Note the RecipeRequest is really an association class that connects a recipe to a language that is to be translated. This is because a Recipe cannot have a property of language. A recipe is purely a method. In theory even a drawing ,or a picture, could be a recipe. A language is a concept in its own right. Hence I used an association RecipeRequest to connect the Recipe to a Language.


The website url is Please try it out. The code resides at You can clone the repository. Remember you need to use the Cloud Foundry commands to deploy to the Bluemix runtime. Below is are screenshots of the website.

A screen shot:


When we change the language the recipe is translated:


That ends my post. Happy coding.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s