45
CouchDB/PouchDB approach for hybrid mobile applications Ihor Vlasyuk, SoftServe

Couch DB/PouchDB approach for hybrid mobile applications

Embed Size (px)

Citation preview

Page 1: Couch DB/PouchDB approach for hybrid mobile applications

CouchDB/PouchDB approach for hybrid mobile applicationsIhor Vlasyuk, SoftServe

Page 2: Couch DB/PouchDB approach for hybrid mobile applications

Who I am?

Technical Lead at SoftServe.Involved to mobile development.

Page 3: Couch DB/PouchDB approach for hybrid mobile applications

Agenda

● Modern solution architecture overview● Typical Problems● Quick solutions overview● PouchDB/CouchDB concept● QA

Page 4: Couch DB/PouchDB approach for hybrid mobile applications

Typical Modern Solution

Page 5: Couch DB/PouchDB approach for hybrid mobile applications

Let’s Digg

Page 6: Couch DB/PouchDB approach for hybrid mobile applications

What we have?

● Server side API code● Frontend code● Native mobile code● Database code

Page 7: Couch DB/PouchDB approach for hybrid mobile applications

What With Mobile Code?

Page 8: Couch DB/PouchDB approach for hybrid mobile applications

What With Developers?

Page 9: Couch DB/PouchDB approach for hybrid mobile applications

What Are Results?

● Lot of platform specific code● Problem with synchronization● Lot of peoples involved to project● Lot of different technologies used

Page 10: Couch DB/PouchDB approach for hybrid mobile applications

And What to Do?

Page 11: Couch DB/PouchDB approach for hybrid mobile applications

And What to Do?

Don’t ask me I don’t know. No Pain No Gain.

Page 12: Couch DB/PouchDB approach for hybrid mobile applications

Let’s think together

● We need to minimize number of technologies used on project

● Nice to have one code base

Page 13: Couch DB/PouchDB approach for hybrid mobile applications

Cross Platform Solutions

Page 14: Couch DB/PouchDB approach for hybrid mobile applications

Let’s Holy War begin

Page 15: Couch DB/PouchDB approach for hybrid mobile applications

Quick Overview

Page 16: Couch DB/PouchDB approach for hybrid mobile applications

Quick Overview

● Native applications● Web based applications● Hybrid applications

Page 17: Couch DB/PouchDB approach for hybrid mobile applications

Native Applications

Pros● Offers best user experience to build

complex, reach and responsive applications that offer the best performance

● Has access to all native features provided by platform

Page 18: Couch DB/PouchDB approach for hybrid mobile applications

Native Applications

Cons● Its typically device and platform

specific● Requires installation, upgrading and

uninstallation● Distribution of the application is more

cumbersome and it’s often depended from AppleStore, Android market etc.

Page 19: Couch DB/PouchDB approach for hybrid mobile applications

Web Based Applications

Pros● Reuses existing web applications● Minor tweaks to CSS and HTML are

enough to change UI experience● No installation, upgrade, uninstall● HTML5 can take advantage some

native features like geolocation, local storage etc.

Page 20: Couch DB/PouchDB approach for hybrid mobile applications

Web Based Applications

Cons● Even with HTML5, access to native

features is very limited● Difficult to implement application that

will work in disconnected state● Performance and usability is not as

good as native applications

Page 21: Couch DB/PouchDB approach for hybrid mobile applications

Hybrid Applications

Hybrid applications are built by combining native components and web components. Web components are built using HTML, CSS, and JavaScript and wrapped by a native container (internal browser) that not only displays them but also gives them access to native functionality through JavaScript.

Page 22: Couch DB/PouchDB approach for hybrid mobile applications

Hybrid Applications

Pros● Existing web assets can be used.● Access to all native features.● Can provide a rich user experience by

using native components intelligently

Page 23: Couch DB/PouchDB approach for hybrid mobile applications

Hybrid Applications

Cons● Accessing native functionality using

JavaScript comes with a certain overhead and is not as efficient as a native app.

● UI with HTML5 and CSS still not so responsive as native

Page 24: Couch DB/PouchDB approach for hybrid mobile applications

No Silver Bullet

Page 25: Couch DB/PouchDB approach for hybrid mobile applications

So we went with Cordova

Page 26: Couch DB/PouchDB approach for hybrid mobile applications

Stop! And What With This?

● Lot of platform specific code● Problem with synchronization● Lot of peoples involved to project● Lot of different technologies used

Page 27: Couch DB/PouchDB approach for hybrid mobile applications

Aha Unresolved Problem

● Lot of platform specific code● Problem with synchronization● Lot of peoples involved to project● Lot of different technologies used

Page 28: Couch DB/PouchDB approach for hybrid mobile applications

Welcome CouchDB

Page 29: Couch DB/PouchDB approach for hybrid mobile applications

What is CouchDB?

CouchDB is one of what many are calling NoSQL solutions. Specifically, CouchDB is a document-oriented database and within each document fields are stored as key-value maps. Fields can be either a simple key/value pair, list, or map.

Page 30: Couch DB/PouchDB approach for hybrid mobile applications

What is CouchDB?

CouchDB offers us these features:● Easy replication of a database across

multiple server instances● REST-like interface for document

insertion, updates, retrieval and deletion

● JSON-based document format (easily translatable across different languages)

Page 31: Couch DB/PouchDB approach for hybrid mobile applications

Sync Problem

Page 32: Couch DB/PouchDB approach for hybrid mobile applications

Sync Problem

Page 33: Couch DB/PouchDB approach for hybrid mobile applications

Sync Problem

Page 34: Couch DB/PouchDB approach for hybrid mobile applications

Welcome PouchDB

Page 35: Couch DB/PouchDB approach for hybrid mobile applications

WTF?

You Said that we are trying to decrease number of technologies used in solution?

Page 36: Couch DB/PouchDB approach for hybrid mobile applications

What is PouchDB?

PouchDB is a JavaScript implementation of CouchDB. Its goal is to emulate the CouchDB API with near-perfect fidelity, while running in the browser or in Node.js.

Page 37: Couch DB/PouchDB approach for hybrid mobile applications

What is PouchDB?

PouchDB and CouchDB were designed for one main purpose: sync. Jason Smith has a great quote about this:The way I like to think about CouchDB is this: CouchDB is bad at everything, except syncing. And it turns out that's the most important feature you could ever ask for, for many types of software."

Page 38: Couch DB/PouchDB approach for hybrid mobile applications

PouchDB concept

Page 39: Couch DB/PouchDB approach for hybrid mobile applications

With PouchDB

Page 40: Couch DB/PouchDB approach for hybrid mobile applications

CouchDB, PouchDB and Cordova

Page 41: Couch DB/PouchDB approach for hybrid mobile applications

Setup

<script src="pouchdb-3.5.0.min.js"></script>

Page 42: Couch DB/PouchDB approach for hybrid mobile applications

Synchronization

Page 43: Couch DB/PouchDB approach for hybrid mobile applications

Conflicts

Page 44: Couch DB/PouchDB approach for hybrid mobile applications

Messaging (pub/sub)

Page 45: Couch DB/PouchDB approach for hybrid mobile applications

Questions?