Hello, developers!

This is version 2 of Lauren's Lovely Landscapes. Version 1 is a static sample app that demonstrates how easy it is to deploy an app using IBM Bluemix. Version 2 expands Lauren's Lovely Landscapes to dynamically display prints as well as allow users to register, sign in, sign out, and buy prints.

Version 1 is hosted at http://laurenslovelylandscapes.mybluemix.net. The tutorial associated with Version 1 is posted at https://www.ibm.com/developerworks/cloud/library/cl-intro1-app.

The rest of the information on this page pertains to Version 2.

No prints listed on the home page?

Insert the sample data.

Want your own copy of the app?

I thought you might. Get a copy of my code here. Or you can deploy the app to Bluemix (so you can see it running live and make changes to it) with the simple click of a button:

Deploy to Bluemix

Like videos?

Me too! Get the inside scoop on how I developed the app in my video series below.

The Data

Schema diagram

Graph of sample data

Insert sample data

Click here to insert the sample data. Note that it may take a minute or two.

Delete the data

To start over with a fresh graph, click here to delete the data.

Users

Username First Name Last Name Email

Prints

Name Description Price Image Path

Orders

Visualizing the Orders

If you would like to visualize the orders in a graph, you can do so by deploying the app and then doing the following:

  1. If you have not already inserted the sample data in your deployed version of the app, complete the following steps:
    1. Open your deployed version of the app
    2. Click <for developers> in the top menu
    3. Click the link to insert the sample data
  2. Log into Bluemix
  3. In the Services section of the Dashboard, click on your app's Graph instance
  4. Click Open
  5. In the menu at the top of the page, select landscapes_graph to switch to the graph with your app's data (g is selected by default)
  6. Input a Gremlin query like the following and execute it: def gt = graph.traversal();gt.V().has("type", "user").outE("buys").inV().has("type","print").path();

The following video will walk you through the steps above, so you can visualize the orders.

The Recommendation Engine

One of the biggest strengths of using a graph database is the ability to quickly generate recommendations for your users. This app generates three recommendations for its users on the home page. The recommendation engine used in this app is based on the Apache TinkerPop recipe for recommendations.

The app generates personalized recommendations for a user who is authenticated by looking for other users who have bought the same prints and seeing what they have purchased. Below is a detailed flow of the personalized recommendations:

  1. Find the node associated with the authenticated user.
  2. Traverse the "buys" edges to find all of the print nodes the authenticated user has bought.
  3. Traverse the "buys" edges to find all of the user nodes (excluding the authenticated user) who have purchased this set of prints.
  4. Traverse the "buys" edges to find all of the prints (excluding the prints the authenticated user has bought) this set of users has bought.
  5. Group and sort the print nodes to determine the top three prints this set of users has bought.

If less than three recommendations are generated (for example, if the user is not authenticated or if the user loves the site and has purchased all of the prints), the app searches for the most purchased prints and presents them in the remaining recommendation spots.

Take a look at getRecommendedPrints() in graph.py to see the associated code.

The following video will walk you through the theory and code behind the recommendation engine.