Navigation

PlateSpace Tutorial (Android App)

This tutorial demonstrates how to use MongoDB Stitch to integrate the following services for an Android application:

  • Facebook user authentication services
  • Anonymous authentication
  • MongoDB Service

PlateSpace is a sample native application built around a social, mobile, local restaurant search concept. The user will see a list of restaurants, sorted by their physical proximity to the user’s location. The user can browse through the restaurants, in either map view or a list view, and use advanced filtering and keywords to search for more entries.

Tapping on a restaurant leads to the restaurant’s page, which displays additional details including the average rating and reviews.

Logged in users will be able to add/edit ratings & reviews to the restaurant.

Prerequisites

  • Android Studio 2.3.2 or later
  • Android SDK Build-Tools 25.0.1 or later
  • Familiarity with the Java programming language

Procedure

A. Create a MongoDB Stitch App

Estimated Time to Complete: ~8 minutes

1

Log into Atlas.

To use MongoDB Stitch, you must be logged into MongoDB Atlas. If you do not have an Atlas account, follow the instructions in the Atlas documentation to create an account.

2

Create an Atlas cluster.

If you do not already have an Atlas cluster for use with MongoDB Stitch, create a cluster.

Important

You must deploy the Atlas cluster with MongoDB version 3.4 or greater.

Atlas provides a Free Tier M0 replica set as well as paid M10+ clusters. Free Tier deployments have restrictions as compared to paid M10+ deployments but will work for the purposes of this tutorial. For complete documentation on these restrictions, see Atlas M0 (Free Tier) Limitations.

3

Add a MongoDB Stitch application.

  1. In Atlas, click Stitch Apps in the left-hand navigation.
  2. Click the Create New Application. The name can only contain ASCII letters, numbers, underscores, and hyphens.
  3. Select your Atlas cluster for your MongoDB service.
  4. Click Create.

Upon creation of your app, you will be redirected to the MongoDB Stitch console. Your app is created with a MongoDB service named mongodb-atlas.

B. Define Pipelines

Estimated Time to Complete: ~10 minutes

1

Define a pipeline named geoNear.

Define a pipeline that reads from the platespace.restaurants collection to find the nearest restaurants given the input arguments.

  1. Click Pipelines and then click New Pipeline.

  2. Enter the following properties for the pipeline:

    Name geoNear
    Private Leave unselected. If selected, the pipeline is inaccessible by a client and is only accessible in other MongoDB Stitch definitions, such as webhooks and other pipelines.
    Skip Rules Leave unselected. If selected, rules do not apply to the service actions in the pipeline stages.
    Can Evaluate Leave as {}. The Can Evaluate condition determines whether the pipeline can be run. An empty document {} always evaluates to true, indicating that the pipeline can always be run.
    Parameters

    Add the following parameters:

    • longitude
    • latitude
    • query
    • limit
    • minDistance

    Select all except the query parameter as Required. Clients calling the pipeline must include the required parameters.

    Note

    In the pipeline stage, you bind parameters to stage-defined variables to reference them in the stage. See the stage edit step below for details.

  3. For the output type, select Array

  4. For the displayed stage, edit the following:

    Service Select mongodb-atlas
    Action

    Select aggregate

    In the text box that appears, enter the following aggregation:

    {
      "database": "platespace",
      "collection": "restaurants",
      "pipeline": [
        {
          "$geoNear": {
            "near": {
              "coordinates": [
                "%%vars.longitude",
                "%%vars.latitude"
              ],
              "type": "Point"
            },
            "query": "%%vars.query",
            "limit": "%%vars.limit",
            "minDistance": "%%vars.minDistance",
            "distanceField": "dist",
            "spherical": true
          }
        }
      ]
    }
    
    Bind data to %%vars

    You cannot directly reference the parameters in the stage. Instead, define variables that reference the parameters, and reference the variables in the stage.

    Enable Bind data to %%vars and copy the following in the Bind data to %%vars text box:

    {
      "longitude": "%%args.longitude",
      "latitude": "%%args.latitude",
      "query": "%%args.query",
      "limit": "%%args.limit",
      "minDistance": "%%args.minDistance"
    }
    

    Click Done

  5. Click Save.

See Named Pipelines for more information.

2

Define a pipeline named aggregateRestaurant.

Define a pipeline that calculates the number of reviews and the average rating for a specified restaurant.

  1. Click Pipelines and then click New Pipeline.

  2. Enter the following properties for the pipeline.

    Name aggregateRestaurant
    Private Leave unselected. If selected, the pipeline is inaccessible by a client and is only accessible in other MongoDB Stitch definitions, such as webhooks and other pipelines.
    Skip Rules Leave unselected. If selected, rules do not apply to the service actions in the pipeline stages.
    Can Evaluate Leave as {}. The Can Evaluate condition determines whether the pipeline can be run. An empty document {} always evaluates to true, indicating that the pipeline can always be run.
    Parameters

    Add the following parameter:

    • restaurantId

    Set the parameter as required. Clients calling the pipeline must include this parameter.

    Note

    In the pipeline stage, you bind parameters to stage-defined variables to reference them in the stage. See the edit stage step below for details.

  3. For the output type, ensure that Single Document is selected.

  4. For the displayed stage, edit the following:

    Service Select mongodb-atlas.
    Action

    Select aggregate.

    In the text box that appears, enter the following aggregation:

    {
      "database": "platespace",
      "collection": "reviewsRatings",
      "pipeline": [
        {
          "$match": {
            "restaurantId": "%%vars.restaurantId",
            "rate": {
              "$exists": true
            }
          }
        },
        {
          "$group": {
            "_id": "$restaurantId",
            "average": {
              "$avg": "$rate"
            },
            "count": {
              "$sum": 1
            }
          }
        }
      ]
    }
    
    Bind data to %%vars

    You cannot directly reference the parameter restaurantId in the stage. Instead, define a variable that references the parameter, and then reference the variable in the stage.

    Enable Bind data to %%vars and copy the following in the Bind data to %%vars text box:

    {
      "restaurantId": "%%args.restaurantId"
    }
    

    Click Done.

  5. Click Save.

See Named Pipelines for more information.

3

Define a pipeline named updateRatings.

Define a pipeline that updates the platespace.restaurants collection with the number of reviews and the average rating for a specified restaurant.

  1. Click Pipelines and then click New Pipeline.

  2. Enter the following properties for the pipeline.

    Name updateRatings
    Private Leave unselected. If selected, the pipeline is inaccessible by a client and is only accessible in other MongoDB Stitch definitions, such as webhooks and other pipelines.
    Skip Rules Enable skip rules. In a later step, you will set up write rules that prevents write operations to this collection. As such, in order for the pipeline to bypass this rule and write to the collection, you need to skip rules.
    Can Evaluate Leave as {}. The Can Evaluate condition determines whether the pipeline can be run. An empty document {} always evaluates to true, indicating that the pipeline can always be run.
    Parameters

    Add the following parameter:

    • restaurantId

    Select the parameter as required. Clients calling the pipeline must include this parameter.

    Note

    In the pipeline stage, you bind parameters to stage-defined variables to reference them in the stage. See the edit stage step below for details.

  3. For the output type, ensure that Single Document is selected.

  4. For the displayed stage, edit the following:

    Service Select mongodb-atlas.
    Action

    Select update.

    In the text box that appears, enter the following aggregation:

    {
      "database": "platespace",
      "collection": "restaurants",
      "query": {
        "_id": "%%vars.restaurantId"
      },
      "update": {
        "$set": {
          "averageRating": "%%vars.pipelineResult.average",
          "numberOfRates": "%%vars.pipelineResult.count"
        }
      },
      "upsert": false,
      "multi": false
    }
    
    Bind data to %%vars

    You cannot directly reference the parameter restaurantId in the stage. Instead, define a variable that references the parameter, and then reference the variable in the stage. You can also reference other named pipelines using the %pipeline expansion.

    Enable Bind data to %%vars and copy the following in the Bind data to %%vars text box:

    {
      "restaurantId": "%%args.restaurantId",
      "pipelineResult": {
        "%pipeline": {
          "name": "aggregateRestaurant",
          "args": {
            "restaurantId": "%%args.restaurantId"
          }
        }
      }
    }
    

    Click Done.

  5. Save.

See Named Pipelines for more information.

C. Define Rules

Estimated Time to Complete: ~6 minutes

1

Add rules for each collection the MongoDB service must access.

  1. Click on the MongoDB service mongodb-atlas.

  2. In the Rules tab, add the following namespaces:

    1. Database: platespace

      Collection: restaurants

    2. Database: platespace

      Collection: reviewsRatings

Note

You must add rules for each collection the MongoDB service accesses.

See MongoDB Service Rules for more information.

2

Review the rules for platespace.restaurants collection.

Click on platespace.restaurants to view the read rule, write rule, the validation rule, and the filter rule.

MongoDB Authorization

MongoDB Stitch rules do not override the read and write access (i.e. authorization) that may have been set up separately in MongoDB. That is, MongoDB Stitch rules determine whether the fields are readable or writable; not whether the client has authorization to read or write to a particular database or collection.

Similarly, MongoDB Stitch validation rules do not override document validation rules set up separately in MongoDB.

  1. Review the read rule for the top-level document of platespace.restaurants.

    Modify the read rule for the top-level document to the following and click Save:

    { }
    

    The new rule specifies that all the fields in the documents are always readable. For more information on MongoDB read rules, see MongoDB Service Read Rule.

  2. Review the write rule for the top-level document of platespace.restaurants.

    Modify the write rule for the top-level document to the following and click Save:

    {
       "%%true": false
    }
    

    The new rule specifies that no fields are writable . For more information on MongoDB write rules, see MongoDB Service Write Rule.

  3. Delete the owner_id field.

    For this collection, the owner_id field does not exist. Delete the owner_id field by hovering over it and clicking the x on the right-hand side.

  4. Allow all other fields for platespace.restaurants.

    By default, Allow All Other Fields flag is enabled so that any unlisted fields are readable/writeable as long as the document meets the read/write rules. Alternatively, you can explicitly define all the fields for this collection and disable Allow All Other Fields to control the shape of the documents.

  5. Review filters for platespace.restaurants.

    1. Click on the Filters.

    2. Delete the default filter.

      For more information on filters, see MongoDB Service Filters.

  6. Save your changes.

3

Review the rules for platespace.reviewsRatings collection.

Click on platespace.reviewsRatings to view the read rule, write rule, the validation rule, and the filter rule.

MongoDB Authorization

MongoDB Stitch rules do not override the read and write access (i.e. authorization) that may have been set up separately in MongoDB. That is, MongoDB Stitch rules determine whether the fields are readable or writable; not whether the client has authorization to read or write to a particular database or collection.

Similarly, MongoDB Stitch validation rules do not override document validation rules set up separately in MongoDB.

  1. Review the read rule for the top-level document of platespace.reviewsRatings.

    Modify the read rule for the top-level document to the following and click Save:

    { }
    

    The new rule specifies that all the fields in the documents are always readable. For more information on MongoDB read rules, see MongoDB Service Read Rule.

  2. Review the write rule for the top-level document of platespace.reviewsRatings.

    Leave the rule as is.

    {
       "owner_id": "%%user.id"
    }
    

    The rule specifies that all fields in the documents are writable if the id of the current user matches the owner_id field of the document. For more information on MongoDB write rules, see MongoDB Service Write Rule.

  3. Review the validation rule on the owner_id field of platespace.reviewsRatings. To view the rule, click on the owner_id field.

    {
      "%or": [
        { "%%prev": "%%user.id" },
        { "%%prev": { "%exists": false } }
      ]
    }
    

    The rule specifies that a write operation is valid if either of the following conditions are true:

    • The operation modifies a document where the value of the owner_id field matches the %%user.id.
    • The operation modifies a document that previously did not have an owner_id field, such as inserting a new document.

    For more information on MongoDB validation rules, see MongoDB Service Validation.

  4. Allow all other fields.

    By default, Allow All Other Fields flag is enabled so that any unlisted fields are readable/writeable as long as the document meets the read/write rules. Alternatively, you can explicitly define all the fields for this collection and disable Allow All Other Fields to control the shape of the documents.

  5. Review the filters for platespace.reviewsRatings.

    1. Click on Filters.

      By default, the collection has the following filter rule:

      When Match Expression
      { "%%true": true } { "owner_id": "%%user.id" }

      This filter indicates that when %%true equals true (i.e. always), apply the following filter { "owner_id": "%%user.id" } to the read and write operations. This filter is in addition to the query predicates for read and write operations.

    2. Delete the default filter.

      For more information on filters, see MongoDB Service Filters.

  6. Save your changes.

D. Set Up Facebook Auth

Estimated Time to Complete: ~7 minutes

1

Set up an app in Facebook.

  1. Log in to your Facebook Developer account. If you do not have a Facebook developer account or even a Facebook account, see Facebook - Register and Configure an App.

  2. Add a new Facebook application.

  3. Once created, your application view opens to Product Setup. If not, go to your newly added app and click Add Product.

  4. In Product Setup, set up Facebook Login.

  5. Choose Android for the platform.

  6. In the Quickstart for Android:

    1. You can skip the Download the Facebook SDK for Android step and the Import the Facebook SDK step as the platespace android app project covers these steps.

    2. For Tell Us about Your Android Project step, enter the following:

      • For Package Name, enter:

        com.mongodb.platespace
        
      • For Default Activity Class Name, enter:

        com.mongodb.platespace.application.PlateSpaceApplication
        
    3. Click Save. You may be prompted to verify the Google Play Package Name since your app is not listed publicly on Google Play. Click Use this package name.

    4. Continue to the next step.

    5. Generate the development key hash per instructions and save in the Key Hashes field and continue.

    6. Optional. You can enable/disable Single Sign On and continue to the next step.

    7. Note the following entries for your project file:

      • facebook_app_id and fb_login_protocol_scheme to copy into your project’s strings.xml file in a later step.

        <string name="facebook_app_id">012345678900000</string>
        <string name="fb_login_protocol_scheme">fb1234985978493875</string>
        
      • meta-data entry to copy into your project’s AndroidManifest file in a later step.

        <meta-data android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id"/>
        

      You will use these entries during the setup step of the platespace Android project in this tutorial.

    8. You can omit the remaining steps as they are already incorporated into the ToDo Android project.

  7. Click Settings under Facebook Login in the left-hand navigation menu.

  8. Under Valid OAuth redirect URIs, add the following entry:

    https://stitch.mongodb.com/api/client/v1.0/auth/callback
    
  9. Save changes.

2

Retrieve the App ID and App Secret for your Facebook app.

  1. Click Settings for your Facebook application (i.e. not the Settings under Facebook Login).
  2. Note the App ID and App Secret. You will use the information in the Authentication section of the MongoDB Stitch Admin Console.
3

Configure MongoDB Stitch for Facebook Authentication.

  1. In the MongoDB Stitch console, click Authentication in the left side navigation .

    The Authentication page displays the Authentication Providers information.

  2. For Facebook, click the Edit button.

  3. In the Edit Provider dialog,

    • Switch Facebook to enabled.
    • Enter your new Facebook App ID in the Client ID field and Facebook App Secret in Client Secret field.
  4. Click Save.

E. Set Up Anonymous Auth

Estimated Time to Complete: ~2 minutes

1

Click Authentication in the left side navigation in the MongoDB Stitch console.

The Authentication page displays the Authentication Providers information.

2

Enable Anonymous Authentication.

  1. For Allow users to log in anonymously, click the Edit button.
  2. Switch Allow users to log in anonymously to enabled.
  3. Close the dialog.

F. Download the PlateSpace Application Source

Estimated Time to Complete: ~2 minutes

Download from the MongoDB Stitch GitHub example repository and unzip. The source code for the PlateSpace application can be found in the PlateSpace directory.

G. Populate the restaurants Collection from Yelp.

Estimated Time to Complete: ~8 minutes

1

Create a new Yelp app.

  1. Log in to your Yelp developer account.
  2. Create a new Yelp app.
2

Get an OAuth token for your Yelp app.

To get your auth token, issue the following POST operation, substituting <CLIENT_ID> with your client id and <CLIENT_SECRET> with your client secret:

curl -X POST https://api.yelp.com/oauth2/token -d 'grant_type=client_credentials&client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>'

For more information, see https://www.yelp.com/developers/documentation/v3/authentication

3

Edit the config.js file with your Yelp token.

  1. From the downloaded examples directory, navigate to the PlateSpace/ETL folder.

  2. Edit the config.js file:

    For YELP_AUTH_TOKEN, enter "Bearer <YOUR_YELP_TOKEN>" where <YOUR_YELP_TOKEN> is the auth token for your app.

4

Edit the config.js file with your Atlas cluster connection info.

  1. Go to Atlas, and click on Clusters.

  2. For your cluster linked to the MongoDB Stitch app, click Connect to view the Connect dialog.

  3. Click Connect your application and copy the URI Connection string.

  4. Edit the config.js file:

    For MONGODB_ATLAS_URI, enter the connection string to your Atlas cluster.

    Substitute <PASSWORD> for your password and test database with the target database platespace.

5

Add IP Address to your Atlas cluster’s IP Whitelist.

Add to your Atlas cluster’s IP Whitelist the IP address from which you will run the load script.

  1. From the Connect dialog (see previous step), you can add to the IP Whistelist.
  2. Add the IP address from which you will run the load script.
6

Load data into restaurants collection.

  1. Install dependencies for the script.

    yarn
    
  2. Run the load script to populate the platespace.restaurants collection:

    node index.js
    

If you wish to delete the collection, you can run node clearRestCollection.js.

H. Set Up and Run PlateSpace App

Estimated Time to Complete: ~8 minutes

1

Open the project in Android Studio.

  1. Open Android Studio.
  2. Select Open an existing Android Studio project.
  3. Navigate to the downloaded example directory and open PlateSpace/android.
2

Update the project with your MongoDB Stitch App ID.

From the Project view,

  1. Go to app > java > com.mongodb.platespace.mongodb > mongod.

  2. Open the MongoDBManager.java file.

  3. For the APP_ID variable, replace "YOUR_APP_ID" with your MongoDB Stitch App ID.

    /*
     * Helper class to keep all the statics
     * */
     private class Statics
     {
         private static final String DB_NAME = "YOUR_DB_NAME";
         private static final String SERVICE_NAME = "mongodb-atlas";
         private static final String DB_NAME = "platespace";
     }
    

In the MongoDB Stitch console, you can find your App ID in the Clients view.

3

Update project with your Facebook App ID.

If using Facebook authentication, from the Project view:

  1. Go to the app/res/values folder and open the strings.xml.

    Add your facebook_app_id entry and update the fb_login_protocol_scheme entry. The entries are listed in step 6 in the Facebook Login Quickstart.

    <string name="facebook_app_id">012345678900000</string>
    <string name="fb_login_protocol_scheme">fb1234985978493875</string>
    
  2. Go to the manifests folder and open the AndroidManifest.xml. Review your facebook meta-data entry inside the <application> block. The entry should match the one listed in step 6 in the Facebook Login Quickstart.

    <meta-data android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/facebook_app_id"/>
    
4

Retrieve Google Maps API Key.

  1. Go to https://developers.google.com/maps/documentation/android-api/.

  2. In the Quick start steps section, click Get a Key.

  3. In the dialog, either:

    • Select an existing project and Enable API, or
    • Create a new project and Create and Enable API.
  4. Copy the API Key.

  5. In the Android Studio, go to app > src > release > res > values > google_maps_api.xml.

    Note

    There are two google_maps_api.xml. The other is in app > src > debug > res > values > google_maps_api.xml.

5

Review code to connect to MongoDB Stitch.

The app/java/com.mongodb.platespace/mongodb/MongoDBManager.java file contains logic that instantiates:

  • A StitchClient instance to connect to your MongoDB Stitch application.
  • A MongoClient instance that provides access to the MongoDB service named mongodb-atlas in your MongoDB Stitch app.
private MongoDBManager(Context context)
{
    //initialize the Stitch client and the MongoClient

    mStitchClient = new StitchClient(context, Statics.APP_ID);
    mMongoDBClient = new MongoClient(mStitchClient, Statics.SERVICE_NAME);
6

Review code to authenticate application users.

StitchClient.getAuthProviders() returns a task yielding an AvailableAuthProviders instance. Using this, you can determine what forms of authentication your MongoDB Stitch application permits.

Call the StitchClient.logInWithProvider() method with an instance of one of the available AuthProvider subclasses:

Note

Currently, the PlateSpace app has not implemented the Email/Password Authentication authentication code.

The app/java/com.mongodb.platespace/mongodb/MongoDBManager.java file demonstrates use of these methods.

Anonymous Authentication:

//login anonymously
mStitchClient.logInWithProvider(new AnonymousAuthProvider()).continueWith(new Continuation<Auth, Object>()
{
    @Override
    public Object then(@NonNull final Task<Auth> task) throws Exception
    {
        if (task.isSuccessful())
        {
            //we are logged in anonymously

            Log.i(TAG, "User Authenticated as " + mStitchClient.getAuth().getUserId());
            if (loginListener != null)
            {
                loginListener.onSuccess(null);
            }
        }
        else
        {
            //failed

            String msg = "Error logging in anonymously";
            Log.e(TAG, msg, task.getException());
            if (loginListener != null)
            {
                loginListener.onError(task.getException());
            }
        }
        return null;
    }

Facebook Authentication:

mStitchClient.getAuthProviders().addOnCompleteListener(new OnCompleteListener<AvailableAuthProviders>()
    {
        @Override
        public void onComplete(@NonNull final Task<AvailableAuthProviders> task)
        {
            if (!task.isSuccessful())
            {
                // Could not retrieve authentication providers;
            }
            else
            {
                if (task.getResult().hasFacebook())
                {

                    /*
                    * Facebook authentication is enabled by the service,
                    * try to login using the access token we got from Facebook SDK
                    * */
                    mStitchClient.logInWithProvider(FacebookAuthProvider.fromAccessToken(accessToken)).continueWith(new Continuation<Auth, Object>()
                    {
                        @Override
                        public Object then(@NonNull final Task<Auth> task) throws Exception
                        {
                            if (task.isSuccessful())
                            {
                                //we are logged in with Facebook
                            }
                            else
                            {
                                // Error logging with facebook
                            }
                            return null;
                        }
                    });
                }
                else
                {
                    /*
                    * The service does not support Facebook authentication
                    * */
                }
            }
        }
    });
7

Review code to query a collection and execute pipelines.

The app/java/com.mongodb.platespace/mongodb/MongoDBManager.java contains code to query data from the database:

Document query = new Document();

if (filters != null)
{

    if (filters.isVeganFriendly())
    {
        query.put("attributes.veganFriendly", true);
    }
}


if (keyword != null)
{
    query.put(Restaurant.Field.NAME, new Document("$regex", keyword).append("$options", "i"));
}

if (farthestRestaurant != null)
{
    query.put(Restaurant.Field.ID, new Document("$ne", farthestRestaurant.getId()));
}

List<Document> items = new ArrayList<>();
items.add(new Document("result", "%%vars.geo_matches")); //bind the arguments to our named pipeline required parameters


double minDistance = farthestRestaurant == null ? 0 : farthestRestaurant.getDistance();


Document argsMap = new Document()
        .append("latitude", latitude) //the current phone latitude
        .append("longitude", longitude) //the current phone longitude
        .append("query", query) //query will contain any additional parameters
        .append("minDistance", minDistance) //pagination parameter
        .append("limit", limit); //pagination limit


Document pipelineMap = new Document()
        .append("name", "geoNear") //our named pipeline in the service
        .append("args", argsMap); //required parameters for the named pipeline


/*
* To execute the named pipeline we need to use the pipeline stage
* */
PipelineStage literalStage = new PipelineStage("literal", new Document("items", items),
        new Document("geo_matches", new Document("$pipeline", pipelineMap)));

mStitchClient.executePipeline(literalStage).continueWith(...);
8

Run the application.

Running the app requires the following:

  1. Click Run.

  2. If no virtual device is available, click Create New Virtual Device.

    1. Select the Phone device for your app. You can use the default selection.
    2. Click Next.
    3. Click Download on one of the recommended system images.
    4. You may need to agree to the terms.
    5. Click Finish.
  3. Select the virtual device from the Available Virtual Devices.

  4. Click OK.

  5. Wait for the device to come online.

  6. Either sign in using Facebook or Skip to login anonymously.

    Important

    Location permissions must be granted to the application. This may require that you open Google Maps on the virtual device and accept the Terms of Service and Privacy Policy.

Collection Information

Each document in the platespace.restaurants collection has the form:

{
   "_id" : <ObjectId>,
   "name" : <String>,
   "address" : <String>,
   "phone" : <String>,
   "Image_url" : <String>,
   "website" : <String>,
   "averageRating" : <Double>,
   "numberOfRates" : <Double>,
   "openingHours" :  { "end" : <String>, "start" : <String> },
   "attributes" : {
      "veganFriendly" : <Boolean>,
      "openOnWeekends" : <Boolean>,
      "hasParking" : <Boolean>,
      "hasWifi" : <Boolean>
   },
   "location" : {
      "coordinates" : [ "longitude" : <Double>, "latitude" : <Double> ],
      "type" : "Point"
   }
}

Note

openingHours and attributes are custom fields added by our sample script to load data and not from Yelp. The field values are generated with dummy data.

Each document in the platespace.reviewsRatings collection has the form:

{
   "_id" : <ObjectId>,
   "owner_id" : <string>,
   "restaurantId" : <ObjectId>,
   "nameOfCommenter" : <String>,
   "comment": <String>,
   "rate" : <Integer>,
   "dateOfComment" : <Date>
}

Additional Information

The PlateSpace app includes the following dependencies:

  • SimpleRatingBar, a UI component used for rating restaurants
  • Calligraphy for custom fonts in Android
  • AutoFitTextView to set the size of a TextViews according to available container space
  • Glide for loading images from URLs.
  • Facebook SDK to authenticate via Facebook
  • Paginate to paginate using RecyclerView