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
joy Joy Haywood joy@example.com
dale Dale Haywood dale@example.com
deanna Deanna Howling deanna@example.com
jason Jason Schaefer jason@example.com

Prints

Name Description Price Image Path
Alaska Lauren loves this photo even though she wasn't present when the photo was taken. Her husband took this photo on a guy's weekend in Alaska. 75 alaska.jpg
Japan Lauren and her husband babymooned in gorgeous Japan. 95 japan.jpg
Kenya Jason and Lauren went on safari in Kenya after Lauren spent 4 weeks working in Nairobi as part of the IBM Corporate Service Corps. 120 kenya.jpg
Australia Lauren loved her trip to Australia so much that she named her daughter Sydney. 120 sydney.jpg
Antarctica Lauren's husband took this spectacular photo when they visited Antarctica in December of 2012. This is one of our hot sellers, so it rarely goes on sale. 100 penguin.jpg
Las Vegas What happens in Vegas, stays in Vegas...unless you take a picture. 90 vegas.jpg
Israel Lauren and her husband were able to tour Israel after Lauren spoke at IBM Business Connect in Tel Aviv in 2014. 80 israel.jpg

Orders

2015-12-24 04:34:52
joy
Alaska
Credit card
Joy Haywood
423 Purple St
Honolulu, HI 96818

2016-04-06 09:55:48
joy
Japan
Credit card
Joy Haywood
423 Purple St
Honolulu, HI 96818

2015-12-29 16:25:02
joy
Antarctica
Credit card
Joy Haywood
423 Purple St
Honolulu, HI 96818

2016-04-22 14:48:30
joy
Las Vegas
Credit card
Joy Haywood
423 Purple St
Honolulu, HI 96818

2016-05-06 10:18:30
dale
Japan
Paypass
Dale Haywood
25 Takeflight Ave
Houston, TX 77036

2016-05-06 10:15:25
dale
Australia
Paypass
Dale Haywood
25 Takeflight Ave
Houston, TX 77036

2016-05-05 22:15:45
dale
Las Vegas
Paypass
Dale Haywood
25 Takeflight Ave
Houston, TX 77036

2016-01-17 08:46:20
deanna
Alaska
Credit card
Deanna Howling
2 Flamingo Lane
Chicago, IL 60629

2016-06-09 12:05:30
deanna
Antarctica
Credit card
Chuck Howling
529 Green St
Omaha, NE 68104

2016-10-20 13:50:00
deanna
Las Vegas
Paypass
Deanna Howling
2 Flamingo Lane
Chicago, IL 60629

2016-10-15 13:13:17
jason
Alaska
Paypass
Jason Schaefer
123 Sweet Lane
Apt #5
Valentine, NE 69201

2016-06-09 06:45:42
jason
Australia
Credit card
Chuck Howling
529 Green St
Omaha, NE 68104

2016-02-03 16:05:02
jason
Las Vegas
Paypass
Jason Schaefer
123 Sweet Lane
Apt #5
Valentine, NE 69201

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.