Home

Awesome

Shopping List

Note: This is a work in progress.

<img src="img/mockup-01.png" alt="Mockup 01" width="270" />        <img src="img/mockup-02.png" alt="Mockup 02" width="270" />        <img src="img/mockup-03.png" alt="Mockup 03" width="270" />

Shopping List is a series of Offline First demo apps, each built using a different stack. These demo apps cover Progressive Web Apps, hybrid mobile apps, native mobile apps, and desktop apps.

The Shopping List demo apps are brought to you by:

Table of Contents

<!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> <!-- END doctoc generated TOC please keep comment here to allow auto update -->

Purposes

These demo apps will each serve multiple purposes:

Features

Shopping List is a simple demo app, with a limited feature set. Here is a list of features written as user stories grouped by Epic:

Implementations

Vanilla JS and PouchDB

Progressive Web App        PouchDB

GitHub Repository:
https://github.com/ibm-watson-data-lab/shopping-list-vanillajs-pouchdb

Polymer and PouchDB

Progressive Web App        Polymer        PouchDB

GitHub Repository:
https://github.com/ibm-watson-data-lab/shopping-list-polymer-pouchdb

React and PouchDB

Progressive Web App        React        PouchDB

GitHub Repository:
https://github.com/ibm-watson-data-lab/shopping-list-react-pouchdb

Preact and PouchDB

Progressive Web App        Preact        PouchDB

GitHub Repository:
https://github.com/ibm-watson-data-lab/shopping-list-preact-pouchdb

Vue.js and PouchDB

Progressive Web App        Vue.js        PouchDB

GitHub Repository:
https://github.com/ibm-watson-data-lab/shopping-list-vuejs-pouchdb

Ember.js and PouchDB

Progressive Web App        Ember.js        PouchDB

GitHub Repository:
https://github.com/ibm-watson-data-lab/shopping-list-emberjs-pouchdb

React Native and PouchDB

React Native        PouchDB

GitHub Repository:
https://github.com/ibm-watson-data-lab/shopping-list-react-native-pouchdb

React Native and Cloudant Sync

React Native        Cloudant Sync

GitHub Repository:
https://github.com/ibm-watson-data-lab/shopping-list-react-native-cloudant-sync

Ionic and PouchDB

Ionic        PouchDB

GitHub Repository:
https://github.com/ibm-watson-data-lab/shopping-list-ionic-pouchdb

Ionic and Cloudant Sync

Ionic        Cloudant Sync

GitHub Repository:
https://github.com/ibm-watson-data-lab/shopping-list-ionic-cloudant-sync

Cordova and PouchDB

Cordova        PouchDB

GitHub Repository:
https://github.com/ibm-watson-data-lab/shopping-list-cordova-pouchdb

Cordova and Cloudant Sync

Cordova        Cloudant Sync

GitHub Repository:
https://github.com/ibm-watson-data-lab/shopping-list-cordova-cloudant-sync

Swift and Cloudant Sync

Swift        Cloudant Sync

GitHub Repository:
https://github.com/ibm-watson-data-lab/shopping-list-swift-cloudant-sync

Kotlin and Cloudant Sync

Kotlin        Cloudant Sync

GitHub Repository:
https://github.com/ibm-watson-data-lab/shopping-list-kotlin-cloudant-sync

Electron and PouchDB

Electron        PouchDB

GitHub Repository:
https://github.com/ibm-watson-data-lab/shopping-list-electron-pouchdb

Interoperability

Implementations of the Shopping List demo app share a data model. This allows the demo apps to be interoperable with one another. For example, a user could plan a shopping trip with a desktop app built using Electron and PouchDB. The same user could then use a native app built using Kotlin and Cloudant Sync while shopping for groceries. Much of the design of this data model is inspired by the CouchDB Best Practices collection from eHealth Africa.

Shopping List Example

{
  "_id": "list:cj6mj1zfj000001n1ugjfkj33",
  "type": "list",
  "version": 1,
  "title": "Groceries",
  "checked": false,
  "place": {
    "title": "Healthy Living",
    "license": "Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright",
    "lat": "44.46282415",
    "lon": "-73.1799710198028",
    "address": {
      "supermarket": "Healthy Living",
      "road": "Dorset Street",
      "city": "South Burlington",
      "county": "Chittenden County",
      "state": "Vermont",
      "postcode": "05406",
      "country": "United States of America",
      "countryCode": "us"
    }
  },
  "createdAt": "2017-08-21T18:40:00.000Z",
  "updatedAt": "2017-08-21T18:40:00.000Z"
}

Notes:

http://nominatim.openstreetmap.org/search/Healthy%20Living%20Vermont?format=json&addressdetails=1&namedetails=1

Shopping List Item Example

{
  "_id": "item:cj6mn7e36000001p9n14fgk6s",
  "type": "item",
  "version": 1,
  "list": "list:cj6mj1zfj000001n1ugjfkj33",
  "title": "Mangos",
  "checked": false,
  "createdAt": "2017-08-21T18:43:00.000Z",
  "updatedAt": "2017-08-21T18:43:00.000Z"
}

Notes:

Here is an example of a Mango / pouchdb-find / Cloudant Query selector that fetches a single shopping list's items:

{
  "selector": {
    "type": "item",
    "list": "list:cj6mj1zfj000001n1ugjfkj33"
  }
}

Note that the above query can also be used to get a count of items within a shopping list by simply using the Array.length property (or equivalent) and accounting for the shopping list document being included in the results. Since PouchDB just runs every reduce function in memory, there is no benefit to using a _count reduce function when using PouchDB. The Cloudant Sync libraries for iOS and Android do not support map/reduce (but do support Cloudant Query / Mango).

Geolocation Context Example

A geolocation context is used to notify the user when the geolocation capability of their device has indicated that they are near a place associated with a shopping list. This provides the user with quick access to the shopping list for their current geographic context.

{
  "_id": "geo:drguywpyxp4t:cj6mn7e36000001p1q02dlz5q",
  "type": "geo",
  "list": "list:cj6mj1zfj000001n1ugjfkj33",
  "version": 1,
  "notified": false,
  "createdAt": "2017-08-21T18:57:00.000Z",
  "updatedAt": "2017-08-21T18:57:00.000Z"
}

Notes:

Here is an example of a Mango / pouchdb-find / Cloudant Query selector that utilizes the built-in _all_docs view to query for geolocation contexts near the current geolocation coordinates of the device (the value drguyw below is the geohash of the user's location at a precision of 6, or ±0.61 km):

{
  "selector": {
    "_id": {
      "$gte": "geo:drguyw",
      "$lte": "geo:drguyw\uffff"
    }
  }
}

Domain Model Implementations

JavaScript

GitHub Repository:
https://github.com/ibm-watson-data-lab/shopping-list-model-js

Swift

GitHub Repository:
https://github.com/ibm-watson-data-lab/shopping-list-model-swift

Kotlin

GitHub Repository:
https://github.com/ibm-watson-data-lab/shopping-list-model-kotlin

Style Guides

General guidelines:

Implementations:

Templates

See the templates directory for templates that can be used for each demo app implementation. This includes the following files: