{"id":23577628,"url":"https://github.com/couchbaselabs/connect-fall-2017-demo","last_synced_at":"2025-05-05T23:16:59.298Z","repository":{"id":66815652,"uuid":"99531020","full_name":"couchbaselabs/connect-fall-2017-demo","owner":"couchbaselabs","description":"Source Code for the Couchbase Connect 2017 Technical Keynote Demonstration","archived":false,"fork":false,"pushed_at":"2018-10-30T21:41:35.000Z","size":13221,"stargazers_count":4,"open_issues_count":11,"forks_count":1,"subscribers_count":34,"default_branch":"master","last_synced_at":"2025-05-05T23:16:54.353Z","etag":null,"topics":["couchbase","couchbase-cluster","couchbase-docker-container","couchbase-lite","couchbase-mobile","couchbase-server","couchbase-sync-gateway"],"latest_commit_sha":null,"homepage":"https://youtu.be/-U_UjqnhMBI","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/couchbaselabs.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-07T03:00:34.000Z","updated_at":"2020-11-05T18:29:13.000Z","dependencies_parsed_at":"2023-03-13T20:29:27.643Z","dependency_job_id":null,"html_url":"https://github.com/couchbaselabs/connect-fall-2017-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/couchbaselabs%2Fconnect-fall-2017-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/couchbaselabs%2Fconnect-fall-2017-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/couchbaselabs%2Fconnect-fall-2017-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/couchbaselabs%2Fconnect-fall-2017-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/couchbaselabs","download_url":"https://codeload.github.com/couchbaselabs/connect-fall-2017-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252590636,"owners_count":21772941,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["couchbase","couchbase-cluster","couchbase-docker-container","couchbase-lite","couchbase-mobile","couchbase-server","couchbase-sync-gateway"],"created_at":"2024-12-26T22:29:43.279Z","updated_at":"2025-05-05T23:16:59.292Z","avatar_url":"https://github.com/couchbaselabs.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Couchbase Connect Fall 2017 Demo\n\nApplication code for Couchbase Connect SF Fall 2017 demo talk.\n\n== Credits\n\nThis project includes significant contributions from others.\n\nThe web client is based on link:https://github.com/misterGF/CoPilot[CoPilot] and\nis used here under terms of the link:https://opensource.org/licenses/MIT[MIT License].\n\nThe Android source includes a port of link:https://jasonette.com/[Jasonette] and is\nincluded here under terms of the link:https://opensource.org/licenses/MIT[MIT License].\n\nImages used in the web client are copyright their respective owners.\nAttributions are listed under web/client/static/img/README.md.\n\nOther copyrights may apply.\nInclusion in this work does not imply additional rights beyond those granted by the copyright holders.\n\nThis overall project, as applicable, is released under terms of the Apache 2.0 License.\nSee `LICENSE` for details.\n\n== Instructions\n\nThe instructions come in a few forms.\n\nThere are several scripts for both Unix command line and Docker-based installations to simplify setup.\nInstructions based on using the scripts to come.\n\nThere's a short form of the instructions meant for easy copy and paste.\n\nThere's a longer form description that breaks down the steps for better understanding.\n\nFinally, you can find a video walking through the entire setup using the link below.\n\nlink:https://youtu.be/RlSMLkd9vrg[Couchbase Connect SV 2017 Demo Setup Walkthrough]\n\nvideo::RlSMLkd9vrg[youtube,width=640,height=360]\n\n=== Tl;dr version\n\nThis will show how to configure the demo mostly using the command line.\n\n(N.B. Command line examples are given for a Mac using Bash.)\n\n==== Clone Repository and Set Working Directory\n\n[source,shell]\n----\ngit clone https://github.com/couchbaselabs/connect-fall-2017-demo.git\ncd connect-fall-2017-demo\n----\n\n==== Couchbase Server\n\nDownload and install Couchbase version 5.5 or later.\nAdd the Couchbase Server tools directory to your command path.\n\n[source,shell]\n----\nexport PATH=\"$PATH:/path/to/install/Couchbase Server.app/Contents/Resources/couchbase-core/bin\"\n----\n\nStart in the top level directory of the project (`connect-fall-2017-demo`).\n\nRun Couchbase Server.\nThe following assumes you're running on `localhost`.\nConfigure the node via the command line.\n\n[source,shell]\n----\n# Basic memory and service configuration\ncouchbase-cli cluster-init --cluster couchbase://127.0.0.1 --cluster-name cluster \\\n  --cluster-username Administrator --cluster-password password \\\n  --services data,index,query,fts,analytics,eventing --cluster-ramsize 256 --cluster-analytics-ramsize 1024 \\\n  --cluster-index-ramsize 256 --cluster-fts-ramsize 256 --index-storage-setting default\n# Main bucket creation\ncouchbase-cli bucket-create --cluster couchbase://127.0.0.1 -u Administrator -p password \\\n  --bucket health --bucket-type couchbase --bucket-ramsize 100\n# Role-Based Access Control\ncouchbase-cli user-manage --cluster couchbase://127.0.0.1 -u Administrator -p password \\\n  --set --rbac-username admin --rbac-password password \\\n  --rbac-name \"J. R. Admin\" --roles \"Admin\" --auth-domain local\n----\n\nWait for the node to warm up (about 15 seconds or so).\nConfigure the rest of what Couchbase Server needs.\n\n[source,shell]\n----\n# Indexes for query optimization\ncbq -u admin -p password -q --script=\"CREATE INDEX \\`resource-idx\\` ON health(resourceType, id);\"\ncbq -u admin -p password -q --script=\"CREATE INDEX \\`observation-idx\\` ON health(subject.reference, issued DESC, valueQuantity.\\`value\\`)\"\ncbq -u admin -p password -q --script=\"CREATE INDEX \\`location-idx\\` ON health(type.coding[0].code) WHERE resourceType = 'Location';\"\n# cURL site whitelist\ncurl -X POST -u admin:password -d \"@scripts/config/curl\" http://127.0.0.1:8091/settings/querySettings/curlWhitelist\n# Full-Text Search index\ncurl -u admin:password -T \"scripts/config/fts-index.json\" http://127.0.0.1:8094/api/index/diagnosis\n# Eventing Service meta-data bucket creation\ncouchbase-cli bucket-create --cluster couchbase://127.0.0.1 -u Administrator -p password \\\n  --bucket eventing --bucket-type couchbase --bucket-ramsize 100\n# Eventing Service function\ncurl -X POST -u admin:password -d \"@scripts/config/eventing\" http://127.0.0.1:8096/api/v1/functions/monitor\n# Analytics Service indexes for query optimization\ncat scripts/config/analytics | while read query\ndo\n  curl -u admin:password --data-urlencode \"statement=${query}\" http://127.0.0.1:8095/analytics/service\ndone\n# Load sample data\nfor file in data/*.json\ndo\n  cbimport json -c couchbase://127.0.0.1:8091 -d file://${file} -g '%id%' -f lines -b health -u admin -p password\ndone\n----\n\n==== Web Client and Server\n\nStart in the top level directory of the project (`connect-fall-2017-demo`).\n\n[source,shell]\n----\n# Build Vue.js web client\ncd web/client\nnpm install\nnpm run build\n# Build and run Node.js web server\ncd ../server\nnpm install\ncat \u003e .env \u003c\u003cEOF\nUA_APPLICATION_KEY='\u003cyour app key\u003e'\nUA_APPLICATION_MASTER_SECRET='\u003cYour app master secret\u003e'\nCLUSTER='couchbase://localhost'\nCLUSTER_USER='admin'\nCLUSTER_PASSWORD='password'\nCLUSTER_CBAS='localhost:8095'\nPORT=8080\nEOF\nnpm start\n----\n\n==== Sync Gateway\n\nStart in the top level directory of the project (`connect-fall-2017-demo`).\n\n[source,shell]\n----\n/path/to/couchbase-sync-gateway/bin/sync_gateway sync-gateway/cc-2017-sg-config.json\n----\n\n==== Android Mobile Application\n\nOpen mobile/android/CBCHealth in Android Studio to build the application.\n\nThe Android mobile app uses Urban Airship for push notifications.\nIf you want to include this feature, you must fill out the Urban Airship configuration with your own keys.\nSee `mobile/android/CBCHealth/app/src/main/assets/airshipconfig.properties.sample`.\n\nIf you don't want to include push notifications, remove the following line from the application's `AndroidManifest.xml` file.\n\n[source,xml]\n----\n\u003cmeta-data\n  android:name=\"com.urbanairship.autopilot\"\n  android:value=\"com.couchbase.mobile.notifications.Autopilot\" /\u003e\n----\n\n=== Detailed Version\n\nThis is a work in progress.\n\n=== On the machine that will host the web server\n\nInstall 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 link:https://github.com/creationix/nvm/blob/master/README.md=install-script[here].\n\nClone the repo\n\n[source,shell]\n----\ngit clone https://github.com/couchbaselabs/connect-fall-2017-demo.git\n----\n\n==== Configuring the server\n\n[source,shell]\n----\ncat \u003e .env\nUA_APPLICATION_KEY='\u003cyour app key\u003e'\nUA_APPLICATION_MASTER_SECRET='\u003cYour app master secret\u003e'\nCLUSTER='couchbase://localhost'\nCLUSTER_USER='\u003cusername\u003e'\nCLUSTER_PASSWORD='\u003cpassword\u003e'\nCLUSTER_CBAS='localhost:8095'\n----\n\n==== Running the server\n\nBuild requires a package to compile the native part of the Couchbase Node client.  Install if needed.\n\n[source,shell]\n----\nnpm install -g node-gyp\n----\n\nYou may also need to install the native compilation tools (e.g. g++).  On Redhat\n\n[source,shell]\n----\nyum group install \"Development Tools\"\n----\n\nIn the directory demo/web/server install Node packages.\n\n[source,shell]\n----\nnpm install\n----\n\nRun the server.\n\n[source,shell]\n----\nnode ./bin/www\n----\n\nOr, for simple crash resilience, run a script.\n\n[source,shell]\n----\n#! /usr/bin/env bash\n\nwhile true\ndo\n  node ./bin/www\ndone\n----\n\nTo prevent some systems from killing the process when you log out, run with nohup, like this.\n\n[source,shell]\n----\nnohup ./server.sh \u003c /dev/null \u003e\u0026 server.log \u0026\n----\n\n==== Configuring the client\n\nUnder `src/config` in the client code, update `serverURI` in the `index.js` file to point to your web server.\n\n==== Building the client\n\nShift to the directory demo/web/client.  Install the Node packages.\n\n[source,shell]\n----\nnpm install\n----\n\nDecide if you want to run the production version or development version.  The development version supports hot\nreloading, but currently requires running a separate development server.\n\nTo use the development server:\n\n[source,shell]\n----\nnpm run dev\n----\n\nYou should find the pages served up on localhost:8080.\n\nTo run a production version:\n\n[source,shell]\n----\nnpm run build\n----\n\nYou should find the pages served on localhost:3000\n\n==== Enabling push notifications\n\nThe 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.\n\n[source,shell]\n----\nexport UA_APPLICATION_KEY=\u003cyour application key\u003e\nexport UA_APPLICATION_MASTER_SECRET=\u003cyour application master secret\u003e\n----\n\nThese keys come from your Urban Airship project.\n\n=== Couchbase Server\n\n==== Data\n\nThe file `augment-data.json` contains records hand written to work with the demo.  To add these to a bucket, use (e.g.)\n\n[source,shell]\n----\ncbimport json -u admin -p password -b health -c couchbase://127.0.0.1:8091 -d file://augment-data.json -g '%id%' -f lines\n----\n\nOn Macs look for cbimport in `/Applications/Couchbase\\ Server.app/Contents/Resources/couchbase-core/bin/`\n\n==== Whitelisting sites for curl\n\nThe curl functionality in N1QL requires sites to be white/black listed.  For this application, whitelist the Google\ngeocoding endpoint by creating\n\n`/opt/couchbase/var/lib/couchbase/n1qlcerts/curl_whitelist.json`\n\nwith contents\n\n[source,shell]\n----\n{\n  \"all_access\":false,\n  \"allowed_urls\":[\"https://maps.googleapis.com/maps/api/geocode/json\"]\n}\n----\n\n==== Indexes\n\nSeveral queries examine resourceType and id:\n\n[source,shell]\n----\nCREATE INDEX `resource-idx` ON health(resourceType, id);\n----\n\nMapping hospitals queries on location resources and specific type codes:\n\n[source,shell]\n----\nCREATE INDEX `location-idx` ON `health`(type.coding[0].code) WHERE resourceType = 'Location';\n----\n\nMonitoring incoming observations from our select patient:\n\n[source,shell]\n----\nCREATE INDEX `observation-idx` ON `health`((`subject`.`reference`),`issued` DESC,(`valueQuantity`.`value`))\n----\n\nFull text search:\n\nThe full text search index definition can be found in `demo/models/fts-index.json`.  Load it with something like this.\n\n[source,shell]\n----\ncurl -T fts-index.json http://admin:password@localhost:8094/api/index/diagnosis\n----\n\n=== Installing Couchnode from GitHub\n\nTo install from the latest\n\n[source,shell]\n----\nnpm install --save git+https://git@github.com/brett19/couchnode.git\n----\n\nTo pin the installation to a specific commit\n\n[source,shell]\n----\nnpm install --save git+https://git@github.com/brett19/couchnode.git#dba79ef33b1f4e7d5e88906538624c65caf3d841\n----","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcouchbaselabs%2Fconnect-fall-2017-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcouchbaselabs%2Fconnect-fall-2017-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcouchbaselabs%2Fconnect-fall-2017-demo/lists"}