Over a million developers have joined DZone.

Creating a Cloud App With Bluemix, a NoSQL DB, and Watson

DZone's Guide to

Creating a Cloud App With Bluemix, a NoSQL DB, and Watson

See how this web app combines IBM Bluemix, Cloudant, and Watson's translation services to create a scalable multilingual experience for users.

· Cloud Zone ·
Free Resource

Create a continuous deployment pipeline with open source tools. Watch the screencast.

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 — Cloudant DB. I also use the Watson language translation service.

I created for the above application to solve the problem as follows:

World-renowned Chef Gabriel is one of the most famous chefs on the planet. His recipes are highly sought 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 Warth regardless of the language that they speak. Furthermore, Chef Gabriel constantly changes and updates his recipes as new ideas come to him. Chef Gabriel then approached 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 the Watson Language Translator service. 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 from the DB, then translate the text into the language that the visitor has chosen. The visitor to the website can then view the recipe in their 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 Cloudant DB. This will then appear on the screen, and the visitor can select the recipe and the language they want. The web application will retrieve that recipe and then have it translated into 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 workaround I had to implement. 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 facet.

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'll 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 https://gabrieljcampbell.mybluemix.net/. Please try it out. The code resides on my GitHub. You can clone the repository. Remember, you need to use the Cloud Foundry commands to deploy to the Bluemix runtime. Below are screenshots of the website.

A screenshot:


When we change the language, the recipe is translated:


That ends my post, which can also be found here.

Happy coding.

Leverage your CDN to optimize + secure your cloud infrastructure. Here's how.

ibm bluemix ,watson ,cloud foundry ,cloud ,cloudant ,tutorial

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}