Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved.
FULL-STACK DEVELOPMENT
WITH JAVASCRIPT AND NOSQL
Aaron Benton - @bentonam - aaron.benton@couchbase.com
Solutions Architect at Couchbase
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved.
Couchbase Day – Charlotte, NC
2
Location: C3 Lab – 2525 Distribution Street, Charlotte, NC 28203
Time: 8:30 AM – 3:30 PM
This FREE event will be packed with presentations and hands-on labs you don’t want to miss. After a brief overview of
the Couchbase Data Platform capabilities, we’ll dive into its technical architecture and how it provides flexible and
feature-rich data facilities for consistent mobile and web experiences. Then we’ll dig deeper into Full Text Search and
Couchbase Mobile.
Register: https://www.couchbase.com/resources/events/2018/february/cbd-charlotte
bit.ly/CBDCTL
Crowne Plaza Times Square, Manhattan
• 3 hands-on workshops
• 30+ breakout sessions across 4 tracks
• Demos, labs, and panel discussions
• Face-to-face time with thought leaders and Couchbase engineers
Visit the Connect site: connect.couchbase.com
Become a speaker: bit.ly/cbconnectspeakers
Get inspired at our premier customer event and start your own digital revolution.
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 4
Full Stack Development
NoSQL DevOps UI / UX Testing OS
Source Control Backend Automation APIs Documentation
Networking QA Integration Hosting
Tuning SQL Agile Frontend Frameworks
IDE Cloud Deployment Mobile Containers
BUZZWORD
BINGO
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 5
Development
{…}
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 6
The Power of the Flexible JSON Schema
• Ability to store data in multiple
ways
• De-normalized single
document, as opposed to
normalizing data across
multiple table
• Dynamic Schema to add new
values when needed
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved.
WHAT IS COUCHBASE?
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved. 8
Couchbase Data
Platform
• Service-Centric Clustered Data System
- Multi-process Architecture
- Dynamic Distribution of Facilities
- Cluster Map Distribution
- Automatic Failover
- Enterprise Monitoring/Management
- Security
• Offline Mobile Data Integration
• Streaming REST API
• SQL-like Query Engine for JSON
• Clustered* Global Indexes
• Lowest Latency Key-Value API
• Active-Active Inter-DC Replication
• Local Aggregate Indexes
• Full-Text Search*
• Operational Analytics*
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 9
Couchbase Server Overview
▪ Scale easily to thousands of nodes
▪ Consistent high performance that
supports millions of concurrent users
▪ Flexible JSON data model
▪ 24x365 always-on availability
Couchbase Server
Database Server
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 10
Downloading Couchbase Server
• Download Couchbase Server Online
• couchbase.com/downloads
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 11
Installing Couchbase Server
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved.
DEMO
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 13
Technologies
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 14
Project
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 15
docker-compose.yaml
./docker-compose.yaml ./docker-compose.yaml
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 16
docker-compose.yaml
./docker-compose.yaml ./docker-compose.yaml
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 17
nginx.conf
./.docker/nginx.conf ./.docker/nginx.conf
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 18
Dockerfile
./backend/Dockerfile ./frontend/Dockerfile
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 19
Makefile
./backend/Makefile ./backend/Makefile
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 20
Running the Environment
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 21
Koa - Demo
./backend/app/server.js
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 22
Couchbase Document
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 23
Koa - Connecting to Couchbase
./backend/app/db.js ./backend/app/server.js
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 24
Koa - API Setup
./backend/app/server.js ./backend/app/router.js
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 25
Koa - API Setup
./backend/app/router.js ./backend/app/router.js
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 26
What is N1QL?
• Non-first (N1) Normal Form Query Language (QL)
• It is based on ANSI 92 SQL
• Its query engine is optimized for modern, highly parallel multi-core execution
• SQL-like Query Language
• Expressive, familiar, and feature-rich language for querying, transforming, and manipulating JSON data
• N1QL extends SQL to handle data that is:
• Nested: Contains nested objects, arrays
• Heterogeneous: Schema-optional, non-uniform
• Distributed: Partitioned across a cluster
Flexibility of
JSON
Power of SQL
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 27
Koa - API Setup
./backend/app/router.js ./backend/app/router.js./backend/app/router.js
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 28
Koa - API Setup
./backend/app/router.js ./backend/app/router.js
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 29
Vue
./frontend/src/App.vue ./frontend/src/App.vue ./frontend/src/App.vue
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 30
Vue - Methods
./frontend/src/App.vue ./frontend/src/App.vue
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 31
Vue - Methods
./frontend/src/App.vue
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 32
Running the App
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved.
GIVEAWAY!
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved.
THANK YOU
• Repo: git.io/vAqoJ
• Couchbase Day CLT: bit.ly/CBDCTL
• Couchbase RTP: bit.ly/couchbase-rtp
@bentonam / aaron.benton@couchbase.com
Confidential and Proprietary. Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved. 35
500+ Digital Businesses Run on Couchbase
6 of the Top 10
E-Commerce
Companies
in the US
6 of the Top 10
US & European
Broadcast Companies
6 of the Top 10
Online Casino
Gaming
Companies
The Top 3
Credit Reporting Companies
The top 3
GDS Companies
3 of the Top 10
Airlines

Full-Stack Development with JavaScript and NoSQL

  • 1.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. FULL-STACK DEVELOPMENT WITH JAVASCRIPT AND NOSQL Aaron Benton - @bentonam - aaron.benton@couchbase.com Solutions Architect at Couchbase
  • 2.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved. Couchbase Day – Charlotte, NC 2 Location: C3 Lab – 2525 Distribution Street, Charlotte, NC 28203 Time: 8:30 AM – 3:30 PM This FREE event will be packed with presentations and hands-on labs you don’t want to miss. After a brief overview of the Couchbase Data Platform capabilities, we’ll dive into its technical architecture and how it provides flexible and feature-rich data facilities for consistent mobile and web experiences. Then we’ll dig deeper into Full Text Search and Couchbase Mobile. Register: https://www.couchbase.com/resources/events/2018/february/cbd-charlotte bit.ly/CBDCTL
  • 3.
    Crowne Plaza TimesSquare, Manhattan • 3 hands-on workshops • 30+ breakout sessions across 4 tracks • Demos, labs, and panel discussions • Face-to-face time with thought leaders and Couchbase engineers Visit the Connect site: connect.couchbase.com Become a speaker: bit.ly/cbconnectspeakers Get inspired at our premier customer event and start your own digital revolution.
  • 4.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 4 Full Stack Development NoSQL DevOps UI / UX Testing OS Source Control Backend Automation APIs Documentation Networking QA Integration Hosting Tuning SQL Agile Frontend Frameworks IDE Cloud Deployment Mobile Containers BUZZWORD BINGO
  • 5.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 5 Development {…}
  • 6.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 6 The Power of the Flexible JSON Schema • Ability to store data in multiple ways • De-normalized single document, as opposed to normalizing data across multiple table • Dynamic Schema to add new values when needed
  • 7.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. WHAT IS COUCHBASE?
  • 8.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved. 8 Couchbase Data Platform • Service-Centric Clustered Data System - Multi-process Architecture - Dynamic Distribution of Facilities - Cluster Map Distribution - Automatic Failover - Enterprise Monitoring/Management - Security • Offline Mobile Data Integration • Streaming REST API • SQL-like Query Engine for JSON • Clustered* Global Indexes • Lowest Latency Key-Value API • Active-Active Inter-DC Replication • Local Aggregate Indexes • Full-Text Search* • Operational Analytics*
  • 9.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 9 Couchbase Server Overview ▪ Scale easily to thousands of nodes ▪ Consistent high performance that supports millions of concurrent users ▪ Flexible JSON data model ▪ 24x365 always-on availability Couchbase Server Database Server
  • 10.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 10 Downloading Couchbase Server • Download Couchbase Server Online • couchbase.com/downloads
  • 11.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 11 Installing Couchbase Server
  • 12.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. DEMO
  • 13.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 13 Technologies
  • 14.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 14 Project
  • 15.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 15 docker-compose.yaml ./docker-compose.yaml ./docker-compose.yaml
  • 16.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 16 docker-compose.yaml ./docker-compose.yaml ./docker-compose.yaml
  • 17.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 17 nginx.conf ./.docker/nginx.conf ./.docker/nginx.conf
  • 18.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 18 Dockerfile ./backend/Dockerfile ./frontend/Dockerfile
  • 19.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 19 Makefile ./backend/Makefile ./backend/Makefile
  • 20.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 20 Running the Environment
  • 21.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 21 Koa - Demo ./backend/app/server.js
  • 22.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 22 Couchbase Document
  • 23.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 23 Koa - Connecting to Couchbase ./backend/app/db.js ./backend/app/server.js
  • 24.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 24 Koa - API Setup ./backend/app/server.js ./backend/app/router.js
  • 25.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 25 Koa - API Setup ./backend/app/router.js ./backend/app/router.js
  • 26.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 26 What is N1QL? • Non-first (N1) Normal Form Query Language (QL) • It is based on ANSI 92 SQL • Its query engine is optimized for modern, highly parallel multi-core execution • SQL-like Query Language • Expressive, familiar, and feature-rich language for querying, transforming, and manipulating JSON data • N1QL extends SQL to handle data that is: • Nested: Contains nested objects, arrays • Heterogeneous: Schema-optional, non-uniform • Distributed: Partitioned across a cluster Flexibility of JSON Power of SQL
  • 27.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 27 Koa - API Setup ./backend/app/router.js ./backend/app/router.js./backend/app/router.js
  • 28.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 28 Koa - API Setup ./backend/app/router.js ./backend/app/router.js
  • 29.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 29 Vue ./frontend/src/App.vue ./frontend/src/App.vue ./frontend/src/App.vue
  • 30.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 30 Vue - Methods ./frontend/src/App.vue ./frontend/src/App.vue
  • 31.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 31 Vue - Methods ./frontend/src/App.vue
  • 32.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. 32 Running the App
  • 33.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. GIVEAWAY!
  • 34.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2018. All rights reserved. THANK YOU • Repo: git.io/vAqoJ • Couchbase Day CLT: bit.ly/CBDCTL • Couchbase RTP: bit.ly/couchbase-rtp @bentonam / aaron.benton@couchbase.com
  • 35.
    Confidential and Proprietary.Do not distribute without Couchbase consent. © Couchbase 2017. All rights reserved. 35 500+ Digital Businesses Run on Couchbase 6 of the Top 10 E-Commerce Companies in the US 6 of the Top 10 US & European Broadcast Companies 6 of the Top 10 Online Casino Gaming Companies The Top 3 Credit Reporting Companies The top 3 GDS Companies 3 of the Top 10 Airlines

Editor's Notes

  • #2 My Name is Aaron Benton, I work as a Solutions Architect for Couchbase Special Thanks to Tracy Lee and Modern Web for having me I have 20 minutes so lets get started
  • #3 We’ll spend a little bit of time looking at NoSQL and leveraging Couchbase, but if you’d like to know more come checkout our FREE Couchbase Day in Charlotte on Feb. 27th
  • #4  If you can’t make it to Charlotte for the day come to New York for 2 full days and hands on workshops Coupons for free access
  • #5 Trying to define what “Full Stack Development” means is like playing a game of buzzword bingo We’re going to focus on mainly on NoSQL and the Backend, with just a little frontend today
  • #6 As developers we spend all of our time dealing with and constructing objects. When it comes time to save that object in a relational system, we have to deconstruct it and save it in a form that we did not construct it in, this is what is effectively called the impedance mismatch
  • #12 We’re going to setup Couchbase Server really quick, and since screen recordings don’t break.
  • #14 We’ll use Couchbase as our NoSQL Database Node, Koa and Babel for our backend Vue for frontend And we’ll use Nginx to to front both the backend API and Vue
  • #16 There’s a lot going on here We using nginx as both our web server for our front-end and as a proxy for our nodejs api We’re also using a single Couchbase container, this is a container that I have published that launches a Couchbase instance and auto-configures it for you based on environment variables but you could easily build you own to suit your needs You’ll notice that both Nginx and Couchbase are pulled from DockerHub but we’re building our Nodejs container from a Dockerfile I’ll also point out that we have an nginx.conf and mime.types that are apart of our project, that we’re linking inside of the docker container, as well as our “frontend” directory”
  • #17 There’s a lot going on here We using nginx as both our web server for our front-end and as a proxy for our nodejs api We’re also using a single Couchbase container, this is a container that I have published that launches a Couchbase instance and auto-configures it for you based on environment variables but you could easily build you own to suit your needs We’ve defined a fully function environment of 4 containers, in about 50 lines of YAML
  • #18 You can find plenty of documentation and configuration on nginx Basically we’re defining an HTTP server, that has 2 upstream servers, 1 is our backend API and one is our Due App Now we define 2 rules one for /api that goes to our node app and one for the /root that goes to our Vue app
  • #19 Two of our containers for the frontend (Vue) and backend (API) use their own Dockerfile’s These are straight forward
  • #20 Here we’re using make instead of embedding these commands inside our package.json scripts block This allows for abstraction and easier management You can still have these scripts but have them point to the specific make command
  • #21 Here we’re using make instead of embedding these commands inside our package.json scripts block This allows for abstraction and easier management You can still have these scripts but have them point to the specific make command
  • #23 Let’s create a document in Couchbase manually And now we’ll retrieve it
  • #25 We import koa-body for parsing JSON body We add simple error / 404 handling shoutout to the marquee tag, notice the very first thing that happens is we await next() Lastly we attach the middleware for koa body and the router Next we define our router and imports
  • #26 Here we are defining endpoints to to create a person and an address For the document ID we are using a UUID Creating and Retrieving documents is straight forward, but what if we want to retrieve all of the people or all of the addresses? In a relational environment you’d use a SQL query… in Couchbase you can use N1QL which is SQL for JSON
  • #28 We import koa-body for parsing JSON body We add simple error / 404 handling shoutout to the marquee tag, notice the very first thing that happens is we await next() Lastly we attach the middleware for koa body and the router
  • #29 Lastly we need to define an endpoint that will allow us to associate an address to a person For this we are going to use the Sub-Document API Think of this an an UPDATE SQL Statement Instead of retrieving an entire document, modifying it on the application and writing the entire back we give Couchbase the instructions on how to update the document Additionally we need endpoints to retrieve an individual person and an address
  • #30 Now lets look at our Vue app I’m not going to cover the template and bindings you can see that in the repo We’re using axios which is a promised based http client for node and the browser We setup our data for person, address, people and addresses We mount our calls for people and addresses
  • #31 Next we define our methods for creating a person and an address
  • #32 Lastly we define a method that allows us to link an address to a person
  • #33 Lastly we define a method that allows us to link an address to a person