Giter Site home page Giter Site logo

couchbaselabs / connect-fall-2017-demo Goto Github PK

View Code? Open in Web Editor NEW
4.0 35.0 1.0 12.91 MB

Source Code for the Couchbase Connect 2017 Technical Keynote Demonstration

Home Page: https://youtu.be/-U_UjqnhMBI

License: Apache License 2.0

Shell 3.72% Java 79.83% JavaScript 8.62% HTML 0.59% Vue 6.81% CSS 0.35% Dockerfile 0.07%
couchbase couchbase-lite couchbase-server couchbase-mobile couchbase-sync-gateway couchbase-cluster couchbase-docker-container

connect-fall-2017-demo's Introduction

Couchbase Connect Fall 2017 Demo

Application code for Couchbase Connect SF Fall 2017 demo talk.

Credits

This project includes significant contributions from others.

The web client is based on CoPilot and is used here under terms of the MIT License.

The Android source includes a port of Jasonette and is included here under terms of the MIT License.

Images used in the web client are copyright their respective owners. Attributions are listed under web/client/static/img/README.md.

Other copyrights may apply. Inclusion in this work does not imply additional rights beyond those granted by the copyright holders.

This overall project, as applicable, is released under terms of the Apache 2.0 License. See LICENSE for details.

Instructions

The instructions come in a few forms.

There are several scripts for both Unix command line and Docker-based installations to simplify setup. Instructions based on using the scripts to come.

There’s a short form of the instructions meant for easy copy and paste.

There’s a longer form description that breaks down the steps for better understanding.

Finally, you can find a video walking through the entire setup using the link below.

Tl;dr version

This will show how to configure the demo mostly using the command line.

(N.B. Command line examples are given for a Mac using Bash.)

Clone Repository and Set Working Directory

git clone https://github.com/couchbaselabs/connect-fall-2017-demo.git
cd connect-fall-2017-demo

Couchbase Server

Download and install Couchbase version 5.5 or later. Add the Couchbase Server tools directory to your command path.

export PATH="$PATH:/path/to/install/Couchbase Server.app/Contents/Resources/couchbase-core/bin"

Start in the top level directory of the project (connect-fall-2017-demo).

Run Couchbase Server. The following assumes you’re running on localhost. Configure the node via the command line.

# Basic memory and service configuration
couchbase-cli cluster-init --cluster couchbase://127.0.0.1 --cluster-name cluster \
  --cluster-username Administrator --cluster-password password \
  --services data,index,query,fts,analytics,eventing --cluster-ramsize 256 --cluster-analytics-ramsize 1024 \
  --cluster-index-ramsize 256 --cluster-fts-ramsize 256 --index-storage-setting default
# Main bucket creation
couchbase-cli bucket-create --cluster couchbase://127.0.0.1 -u Administrator -p password \
  --bucket health --bucket-type couchbase --bucket-ramsize 100
# Role-Based Access Control
couchbase-cli user-manage --cluster couchbase://127.0.0.1 -u Administrator -p password \
  --set --rbac-username admin --rbac-password password \
  --rbac-name "J. R. Admin" --roles "Admin" --auth-domain local

Wait for the node to warm up (about 15 seconds or so). Configure the rest of what Couchbase Server needs.

# Indexes for query optimization
cbq -u admin -p password -q --script="CREATE INDEX \`resource-idx\` ON health(resourceType, id);"
cbq -u admin -p password -q --script="CREATE INDEX \`observation-idx\` ON health(subject.reference, issued DESC, valueQuantity.\`value\`)"
cbq -u admin -p password -q --script="CREATE INDEX \`location-idx\` ON health(type.coding[0].code) WHERE resourceType = 'Location';"
# cURL site whitelist
curl -X POST -u admin:password -d "@scripts/config/curl" http://127.0.0.1:8091/settings/querySettings/curlWhitelist
# Full-Text Search index
curl -u admin:password -T "scripts/config/fts-index.json" http://127.0.0.1:8094/api/index/diagnosis
# Eventing Service meta-data bucket creation
couchbase-cli bucket-create --cluster couchbase://127.0.0.1 -u Administrator -p password \
  --bucket eventing --bucket-type couchbase --bucket-ramsize 100
# Eventing Service function
curl -X POST -u admin:password -d "@scripts/config/eventing" http://127.0.0.1:8096/api/v1/functions/monitor
# Analytics Service indexes for query optimization
cat scripts/config/analytics | while read query
do
  curl -u admin:password --data-urlencode "statement=${query}" http://127.0.0.1:8095/analytics/service
done
# Load sample data
for file in data/*.json
do
  cbimport json -c couchbase://127.0.0.1:8091 -d file://${file} -g '%id%' -f lines -b health -u admin -p password
done

Web Client and Server

Start in the top level directory of the project (connect-fall-2017-demo).

# Build Vue.js web client
cd web/client
npm install
npm run build
# Build and run Node.js web server
cd ../server
npm install
cat > .env <<EOF
UA_APPLICATION_KEY='<your app key>'
UA_APPLICATION_MASTER_SECRET='<Your app master secret>'
CLUSTER='couchbase://localhost'
CLUSTER_USER='admin'
CLUSTER_PASSWORD='password'
CLUSTER_CBAS='localhost:8095'
PORT=8080
EOF
npm start

Sync Gateway

Start in the top level directory of the project (connect-fall-2017-demo).

/path/to/couchbase-sync-gateway/bin/sync_gateway sync-gateway/cc-2017-sg-config.json

Android Mobile Application

Open mobile/android/CBCHealth in Android Studio to build the application.

The Android mobile app uses Urban Airship for push notifications. If you want to include this feature, you must fill out the Urban Airship configuration with your own keys. See mobile/android/CBCHealth/app/src/main/assets/airshipconfig.properties.sample.

If you don’t want to include push notifications, remove the following line from the application’s AndroidManifest.xml file.

<meta-data
  android:name="com.urbanairship.autopilot"
  android:value="com.couchbase.mobile.notifications.Autopilot" />

Detailed Version

This is a work in progress.

On the machine that will host the web server

Install node. Note the server requires version 7 or higher. I recommend using nvm to manage Node versions if you have an existing installation. (The nvm installation guide can be found here.

Clone the repo

git clone https://github.com/couchbaselabs/connect-fall-2017-demo.git

Configuring the server

cat > .env
UA_APPLICATION_KEY='<your app key>'
UA_APPLICATION_MASTER_SECRET='<Your app master secret>'
CLUSTER='couchbase://localhost'
CLUSTER_USER='<username>'
CLUSTER_PASSWORD='<password>'
CLUSTER_CBAS='localhost:8095'

Running the server

Build requires a package to compile the native part of the Couchbase Node client. Install if needed.

npm install -g node-gyp

You may also need to install the native compilation tools (e.g. g++). On Redhat

yum group install "Development Tools"

In the directory demo/web/server install Node packages.

npm install

Run the server.

node ./bin/www

Or, for simple crash resilience, run a script.

#! /usr/bin/env bash

while true
do
  node ./bin/www
done

To prevent some systems from killing the process when you log out, run with nohup, like this.

nohup ./server.sh < /dev/null >& server.log &

Configuring the client

Under src/config in the client code, update serverURI in the index.js file to point to your web server.

Building the client

Shift to the directory demo/web/client. Install the Node packages.

npm install

Decide if you want to run the production version or development version. The development version supports hot reloading, but currently requires running a separate development server.

To use the development server:

npm run dev

You should find the pages served up on localhost:8080.

To run a production version:

npm run build

You should find the pages served on localhost:3000

Enabling push notifications

The Node web server reads configuration parameters for Urban Airship from the shell environment. In the shell, before running the server, export the keys as follows.

export UA_APPLICATION_KEY=<your application key>
export UA_APPLICATION_MASTER_SECRET=<your application master secret>

These keys come from your Urban Airship project.

Couchbase Server

Data

The file augment-data.json contains records hand written to work with the demo. To add these to a bucket, use (e.g.)

cbimport json -u admin -p password -b health -c couchbase://127.0.0.1:8091 -d file://augment-data.json -g '%id%' -f lines

On Macs look for cbimport in /Applications/Couchbase\ Server.app/Contents/Resources/couchbase-core/bin/

Whitelisting sites for curl

The curl functionality in N1QL requires sites to be white/black listed. For this application, whitelist the Google geocoding endpoint by creating

/opt/couchbase/var/lib/couchbase/n1qlcerts/curl_whitelist.json

with contents

{
  "all_access":false,
  "allowed_urls":["https://maps.googleapis.com/maps/api/geocode/json"]
}

Indexes

Several queries examine resourceType and id:

CREATE INDEX `resource-idx` ON health(resourceType, id);

Mapping hospitals queries on location resources and specific type codes:

CREATE INDEX `location-idx` ON `health`(type.coding[0].code) WHERE resourceType = 'Location';

Monitoring incoming observations from our select patient:

CREATE INDEX `observation-idx` ON `health`((`subject`.`reference`),`issued` DESC,(`valueQuantity`.`value`))

Full text search:

The full text search index definition can be found in demo/models/fts-index.json. Load it with something like this.

curl -T fts-index.json http://admin:password@localhost:8094/api/index/diagnosis

Installing Couchnode from GitHub

To install from the latest

npm install --save git+https://[email protected]/brett19/couchnode.git

To pin the installation to a specific commit

npm install --save git+https://[email protected]/brett19/couchnode.git#dba79ef33b1f4e7d5e88906538624c65caf3d841

connect-fall-2017-demo's People

Contributors

hodgreeley avatar krugster avatar mschoch avatar nraboy avatar robashcom avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

durai4585

connect-fall-2017-demo's Issues

Define Analytics scenario

What trend can we show for data exploration, e.g - high fever in in October was due to a H1N1 outbreak.

Android: Appointment UI enhancement

Feedback from Rob:


This is really excellent. There are only two things I would change; both in the red “button”.

  1. Because it is full width, it does not look so much like an action button, but more like it will take me to a new screen called “Schedule” where I imagine I will “schedule” my doctors visit. It should be centered and maybe 70% of the screen width.
  2. The label “SCHEDULE >” is potentially confusing for the reasons above plus the “>” which generally means we are going to be taken somewhere (navigation), rather than initiate some action. So I would re-imagine the whole screen from the top down (from the title text in the blue area…) as follows:

Schedule a Visit [not “Couchbase Connected Health”]

Doctor [instead of “Schedule With:”] [no need for : after these labels]
Date
Time

Set Appointment [for the button label]

Prepare dataset

  • Needs to include data for results with "Mongo-itis" search.

UX design for screens

Based on CoPilot framework. CoPilot

See starting wireframes included in demo writeup doc.

These currently show mostly the web portal.

  • Mobile landing page (see existing)
  • Review temp page (see existing)
  • Advice Nurse (patient) dashboard
  • Patient details
  • Case search
  • Incident map
  • Care provider's patient messaging/scheduling page

Define notifications scenario

Do we show notifications triggered by business logic, by hand, both?

Current scenario suggests a N1QL query to do this.

Deployment

  • Specify deployment requirements (AWS?, etc.)
  • Deployment coding work
  • Test plan

Specs for mobile UI

Overall app ui/ux, which parts need to function. BS&W/FollowMyHealth has interesting example in app stores.

Current list:

  • Temperature page
  • Alerts (standard Android notification, or ...?)

TBD:

  • Landing page
  • ?

Android App Issue

When taking temperature with the app in the background, a new Android Activity is generated. Please investigate.

Server scenarios to showcase

  • Integration
    • Bringing data from different systems
  • Operational elements
    • Fast failover
    • Query planning
    • Node failures

Demo script gap draft

Review and identify any outstanding gaps (missing features to highlight, details not sufficient, work not scoped)

Partner/Customer Participation

At the end of the demo, have Everyday Health or BD come on stage to discuss how they are engaging their Patients using the Couchbase Engagement Database. Everyday Health has app that is very similar to the scenario above. BD has an application that is in line with the fictitious example above. They monitor data from insulin devices, apply business rules and take action based on those rules.

Suggested:

  • Everyday Health
  • BD (Bluetooth glucose monitoring)
  • Mio Global (wearables)
  • Sync Think

Integrate mobile w/patient dashboard

  • Finalize data model (FHIR?)
  • Define endpoint
  • Integrate with Dashboard, patient details views
  • Integrate eventing (out of range alert on dashboard)

Cleanup patient details UI

-make the extended details the same bulleted list as the main details
Key: Value
-Cleanup the stock details to not show the json
-Resize the temperature graph to only take up the width of the graph instead of the whole page
-List of cases below should create a new column for extended attributes when present and should scroll horizontally so as not to squeeze existing columns

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.