JS App Architecture

19
JS APP ARCHITECTURE NoSQL, SSJS, & Sencha

description

These are the slides from the presentation I gave to the Sencha meetup group in Austin, TX. It covers the NoSQL-NodeJS-ExtJS development stack at a high level.

Transcript of JS App Architecture

Page 1: JS App Architecture

JS APP ARCHITECTURE

NoSQL, SSJS, & Sencha

Page 2: JS App Architecture

Corey Butler 15yrs+ Web Experience Founder @ Ecor Systems, LLC Chief Consultant @ Ecor Group (we’re on senchadevs.com) DW/BI & Web Practices

Ext JS Since v2. Started in the Adobe, Microsoft, & IBM worlds. Started in Fortune 500, Entrepreneur since 2000.

Available Via: Blog: coreybutler.com Twitter: @goldglovecb LinkedIn.com/in/ecorsystems

Page 3: JS App Architecture

Agenda

NoSQL Overview SSJS Overview The Sencha Stack Simple Examples

Page 4: JS App Architecture

The Stack

UI: Sencha

Controller: SSJS

Persistence: NoSQL

The concept isn’t much different from traditional web architecture.

Page 5: JS App Architecture

What is NoSQL?

No defined relationships. No schemas or fixed types. NoACID?

Page 6: JS App Architecture

What NoSQL Is NOT

Hard & Fast RDBMS Replacement All Purpose Data Storage

Page 7: JS App Architecture

NoSQL vs SQL

NOSQL Goal Specific Non-relational Map/Reduce Known Data Structure! No NULLS

function(doc) {

if ( doc.date < Date() && typeof doc.somefield !== undefined ) {

var resultObject = {

id: doc.pk,

value: doc.somefield

};

emit(resultObject);

}

}

SQL Generic RDBMS ANSI SQL Predefined Data Structure NULLS

SELECT a.pk as id, a.somefield as value

FROM TblA a INNER JOIN TblB b

ON a.pk = b.fk

WHERE a.somevalue IN

(SELECT someval FROM TblC)

AND b.date < CURRENT_TIMESTAMP

AND a.somefield <> null

Page 8: JS App Architecture

Popular Choices

CouchDB Doc Store MongoDB Doc Store w/ Key/Value Redis Key/Value (In Memory) Riak Dynamo-like (Commercial) Hadoop Big Data Cassandra BigTable CONSTANTLY GROWING kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis

Page 9: JS App Architecture

Storage Types

Key/Value: Schemaless. Where is data stored?

Disk? Memory? Distributed?

Document: Like Key/Value, but semi-structured.

Graph: Based on graph theory. Focuses more

on relationships between objects than

the objects themselves.

Column/Wide: Key pointing to multiple columns

(like rows in an RDBMS)

Page 10: JS App Architecture

SSJS: Server Side JavaScript SSJS was first introduced via Netscape

LiveWire in 1996, but really didn’t become practical for many until 2009.

Gaining popularity because: Faster JS Engines like Google’s V8 (Chrome), Spidermonkey

(Firefox), & Rhino (Firefox). Maturity of JavaScript/ECMAScript. Standards like CommonJS.

Useful for event-driven apps.

Page 11: JS App Architecture

CommonJS

Aims to standardize JS outside the browser. Best Practices/Metadata/Specs. Cross-Compatibility. Supports concepts like modules, file system

references, exports, and other common requirements for serving applications.

Page 12: JS App Architecture

SSJS Platforms

Narwhal Most complete CommonJS

implementation. Based on

Rhino with JSGI Middleware.

NodeJS Non-blocking & single threaded

(fast). Implements some

CommonJS. Based on V8. Large

and growing community.

Others: Jaxer, Jack, 10gen App Server

Page 13: JS App Architecture

NodeJSFrom nodejs.org

Node.js is a server-side JavaScript environment that uses an asynchronous event-driven model. This allows Node.js to get excellent performance based on the architectures of many Internet applications.

Nutshell: Create apps, like web servers.

Page 14: JS App Architecture

Example Web Server//Require the HTTP module

var http = require('http'),

colors = require('colors'),

port = 80;

//Create the server

http.createServer(function (req, res) {

res.writeHead(200, {'Content-Type': 'text/plain'});

res.end('Hello World\n');

}).listen(port, "127.0.0.1");

//Indicate the server is running

console.log('Server running at http://127.0.0.1:'.green+port.toString().cyan+'/'.green);

Page 15: JS App Architecture

NodeJS Modules

Modules are plugins for Node. Lots of work already done for you. No governed quality control. Hundreds of Modules NPM is your friend.

Page 16: JS App Architecture

NPM: Node Package Manager http://npmjs.org Install/Publish Modules Manages dependencies. Extremely simple: npm install express

Page 17: JS App Architecture

Tying to Sencha

Connect Module is part of Sencha Labs Express Module is built on Connect.

Page 18: JS App Architecture

Examples With Sencha

Sencha NoSQL (CouchDB) REST Proxy

Sencha NodeJS MongoDB REST Proxy, Express, Mongoose

This Presentation Socket.IO

Page 19: JS App Architecture

Node Hotness

Socket.IO Web SocketsComparable to HTML5 SSE (Comet)Dnode, NowJS

Highly Concurrent Apps. Easy REST Development. Server-side headless browsers. Community & Momentum