40
Shubhra Kar | Products & Education twitter:@shubhrakar Frameworks or a Design Pattern ?

Node.js Frameworks & Design Patterns Webinar

Embed Size (px)

Citation preview

Shubhra Kar | Products & Education twitter:@shubhrakar

Frameworks or a Design Pattern ?

About me

u  J2EE and SOA architect

u  Performance architect

u  Node, mBaaS & APIs

These guys sent me !

Bert Belder

Ben Noordhuis

Node/io Core

Raymond Feng

Ritchie Martori

LoopBack & Express Core

Sam Roberts

Miroslav Bajtos

Ryan Graham

Buzzwords

Websites

Smart Mobiles

Online Catalog

Social Media

Kiosks

Computers

Physical Store

Gaming Consoles

No IO bottlenecks Highly Concurrent

Very Fast JIT compiled

Node.js is emerging as the answer

Reduce infrastructure by 5X Scalable

Lightweight, JS back and front, Headless Full stack

Write and maintain 50% lesser code Simple

Suited for mobile and IoT Evented & JSON

Biggest OSS community on the planet Ecosystem

Evolution is inevitable !

Thick

Web SaaS Mobile IoT

Frameworks evolve as well !

•  Callback •  Reactor •  Observer

•  Express •  HAPI •  Restify •  Total •  Partial

•  Loopback •  Parse •  Meteor •  Feedhenry*

•  Loopback •  Sails •  Meteor •  Geddy

•  Loopback •  NodeRED •  Proprietary

KISS MVC

MBaaS ORM/ MEAN

Micro/ loT

Pattern 0: Natal patterns

Philosophy: KISS (Keep It Simple Stupid) u  small core u  small modules u  small surface area

Patterns u  reactor u  callback u  module u  observer

Pattern 1: Convention

HTTP Server Library REST HTTP Library

Simple MVC Structure

Pros and Cons

Express DIY HTTP Routing, Middleware, Templating Simple Web Apps Github Stars – 19K Commercial Support - StrongLoop CLI App Generator Export API definition with strong-remoting Connect/Express middleware extensions Vast Ecosystem and low learning curve StrongLoop DevOps tooling support Manual CRUD endpoints Manual recursive refactoring/testing No Data source Support No Client SDK No ACL (Fine Authorization)

Restify DIY Simplicity, Rest Routing Simple REST API Github Stars – 3K Commercial Support - Joyent Yeoman Generator SPDY Support Dtrace Support No export of API definition No Data source Support No Extensions of significance Manual CRUD endpoints Manual recursive refactoring/testing Limited Ecosystem No ACL (Fine Authorization)

Router in

Express

StrongLoop  Confiden.al  and  Proprietary  Informa.on  –  ©  2015  

Router in

Restify

StrongLoop  Confiden.al  and  Proprietary  Informa.on  –  ©  2015  

Pattern 2: Configuration

HTTP Server Framework

Hapi Opinionated Modularity, Security, HTTP Server control Complex Web Apps, APIs Github Stars – 4K Commercial Support - None Yeoman Generator No export of API definition Hapi Plugins – Joi, bell, bassmaster, etc Limited ecosystem as compared to Express; but does support templates with plugins Swagger support for API documentation Very limited Data source support – Mongo, Postgres, leveldb No Client SDK No ACL (Fine Authorization)

Router in

hapi

StrongLoop  Confiden.al  and  Proprietary  Informa.on  –  ©  2015  

Pattern 3 : Full Stack JS à lends into pattern 4

{“..”} JSON is the new first class citizen

Pattern 4: ORM & Isomorphic JS

u  Model Driven Development u  Any data source u  Isomorphic JS

u  Omni-Channel u  Share Models (Client/Server)

u  Loopback & Meteor u  Automatic REST API generation, routing, etc u  Common Weakness : Higher Learning Curve

Sails Opinionated Web MVC framework WebApps, API Rails familiarity, MVC Github Stars – 10 K (older) Commercial Support - None Yeoman Generator StrongLoop DevOps tooling support No export of API definition Limited data sources – MySQL, Mongo, Postgresql, memory/file No Extensions of significance Limited Ecosystem No ACL (Fine Authorization) No Client SDKs

Pros and Cons

Loopback Opinionated API framework Complex Web Apps and APIs Modularity, Scaffolding, Enterprise Connectivity Github Stars – 4 K (newer) Commercial Support - StrongLoop CLI Code Generator, Visual API composer, API explorer Export API definition Extensions like Push, File Storage, Passport, Oauth 2.0, Express Middleware Vast Connector ecosystem and extend express Auto CRUD Swagger UI and Code Generator DataSources like Mongo, mySQL, Oracle, SOAP, REST, SQLServer, Memory/File, Postgresql, Email, ATG, Couchbase, Apache Kafka, and many more Client SDK – Angular, Browser, IOS, Android, Node.js Mature ACL (Fine Authorization), API Gateway

Pros and Cons

Developer SDKs

ORM & Isomorphic JS – Loopback.io

JS client

JS Server

Remoting

JS client Replication

Pub Sub

Router & Swagger

in Loopback

StrongLoop  Confiden.al  and  Proprietary  Informa.on  –  ©  2015  

Router  using  Sails  

Sub-pattern : Schema Discovery

mobile/web clients

social & analytics

JSON API

API XML SQL

SOAP Etc.

mBaaS

Mobile API tier

Enterprise  

Pattern 5: mBaaS

mBaaS could be on cloud or premises

u  Closed Source / Commercial

u  Open Source Key API u  Push Notification u  Geo Location u  Offline Sync u  Storage u  User Management u  Metering, Analytics u  Native SDK u  Isomorphic JS

REST API

PUSH

GEO OFF SYNC

DEVICE

USER FILE

Relational Database Clustered Database Security Gateway Cloud Firewall SOA Bus ( not sure on this one)

Laptop ( not requested but useful)

Connections

Tablet Phone IoT SDK API SERVER Items for ACL

Quick Example of Use

App Server Add On

App Server

Storage

Relational Database Clustered Database Security Gateway Cloud Firewall SOA Bus ( not sure on this one)

Laptop ( not requested but useful)

Connections

Tablet Phone IoT SDK API SERVER Items for ACL

Quick Example of Use

App Server Add On

App Server

REST

API GATEWAY

Channel SDKs

API ENGINE

CONNECTORs

API

SDKs

Open Source ORM, mBaaS and API framework

REST API

Relational Database Clustered Database Security Gateway Cloud Firewall SOA Bus ( not sure on this one)

Laptop ( not requested but useful)

Connections

Tablet Phone IoT SDK API SERVER Items for ACL

Quick Example of Use

App Server Add On

App Server

API Explorer

GeoLocation in Loopback

Push Notification in Loopback

Wait …what is this API Gateway Thing then ?

Synchronous API “Re-Composition” is an anti-pattern

Security & Social Logins

Why not an node.js API Gateway pattern ? Pattern 6

API Clients API Gateway API Server

API

Internet of Everything

The devices are taking over !!!

Microsecond latencies are the norm

API “Decomposition” is the game changer

{JSON} {JSON}

{JSON}

<SOAP/XML>

<TABLE>

Web SaaS Mobile loT

HTML JSON

App Server API Server

Is micro services a pattern too ?

Not just infrastructure virtualization !

Pattern 7: Micro-services (Design Time)

Client SDK

REST Endpoints

Store Cache

API Micro Services

One URL Space

SL API PaaS REST/JSON

API Gateway

Router Remoting Model

API Orchestrator

Cloud Services

Model

Model

Connector

Connector

Connectors

Pattern 8: Micro-services (Run Time)

Now I know !!!

A Shameless Plug…

First there was Node

Thank you!

JUST WIN,BABY!