starting from scratch with the mean stack

76
1 Starting from Scratch with the MEAN Stack

Upload: mongodb

Post on 16-Apr-2017

756 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Starting from Scratch with the MEAN Stack

1

Starting from Scratch with the MEAN Stack

Page 2: Starting from Scratch with the MEAN Stack

2

Who We Are

Sruti Cheedalla:Senior Developer

Kat Styons: Senior Developer

Matt Cwalinski: Lead Developer

Page 3: Starting from Scratch with the MEAN Stack

3

Diverse Experience

Page 4: Starting from Scratch with the MEAN Stack

4

AgendaIntroductionSruti Cheedalla

Building with the MEAN StackKat Styons

What Now and What’s Next?Matt Cwalinski

Page 5: Starting from Scratch with the MEAN Stack

5

Introduction

Page 6: Starting from Scratch with the MEAN Stack

6

The Problem

Page 7: Starting from Scratch with the MEAN Stack

7

Travel Photo Contest 2014

Page 8: Starting from Scratch with the MEAN Stack

8

Page 9: Starting from Scratch with the MEAN Stack

9

Dynamic form builder that lets you collect and manage user submissions of text, images and other data

Page 10: Starting from Scratch with the MEAN Stack

10

Page 11: Starting from Scratch with the MEAN Stack

11

ADMIN TOOL

Page 12: Starting from Scratch with the MEAN Stack

12

ADMIN TOOL

Page 13: Starting from Scratch with the MEAN Stack

13

Successful Adoption

100 + Forms

Page 14: Starting from Scratch with the MEAN Stack

14

Successful Adoption

170 + Users

Page 15: Starting from Scratch with the MEAN Stack

15

Successful Adoption

50,000 + Submissio

ns

Page 16: Starting from Scratch with the MEAN Stack

16

Successful Adoption

7,000 + Media Files

Page 17: Starting from Scratch with the MEAN Stack

17

Page 18: Starting from Scratch with the MEAN Stack

18

MongoDB

Page 19: Starting from Scratch with the MEAN Stack

19

MongoDB ExpressJS

Page 20: Starting from Scratch with the MEAN Stack

20

MongoDB ExpressJS AngularJS

Page 21: Starting from Scratch with the MEAN Stack

21

MongoDB ExpressJS AngularJS NodeJS

Page 22: Starting from Scratch with the MEAN Stack

22

The MEAN Stack

Client

Server

Database

SEND JSON

POST TO DB

SEND JSON AJAX

Page 23: Starting from Scratch with the MEAN Stack

23

The MEAN Stack

Database

SEND JSON

POST TO DB

Page 24: Starting from Scratch with the MEAN Stack

24

The MEAN Stack

Server POST TO DB

SEND JSON AJAX

SEND JSON

Page 25: Starting from Scratch with the MEAN Stack

25

The MEAN Stack

ClientSEND JSON AJAX

Page 26: Starting from Scratch with the MEAN Stack

26

The MEAN Stack

Client

Server

Database

SEND JSON

POST TO DB

SEND JSON AJAX

Page 27: Starting from Scratch with the MEAN Stack

27

● Universal end-to-end Workflow

● Focus on speed of development

● Flexible pieces

Value of the MEAN Stack

Page 28: Starting from Scratch with the MEAN Stack

28

● Universal end-to-end Workflow

Value of the MEAN Stack

Page 29: Starting from Scratch with the MEAN Stack

29

● Universal end-to-end Workflow

● Focus on speed of development

Value of the MEAN Stack

Page 30: Starting from Scratch with the MEAN Stack

30

● Universal end-to-end Workflow

● Focus on speed of development

● Flexible pieces

Value of the MEAN Stack

R

Page 31: Starting from Scratch with the MEAN Stack

31

=Front End

Database Infrastructure

Back End

Full Stack

Page 32: Starting from Scratch with the MEAN Stack

32

Why we chose MongoDB

Page 33: Starting from Scratch with the MEAN Stack

33

???

Put graphic transition here

Page 34: Starting from Scratch with the MEAN Stack

34

Structure your data with the app in mind

Page 35: Starting from Scratch with the MEAN Stack

35

MongoDB vs Relational DB: Viewing a single submission would have required pulling data from 6 tables if we had use a relational DB:

- Submissions for each app have different form fields

- To make up for lack of flexibility this becomes a complex schema

Page 36: Starting from Scratch with the MEAN Stack

36

MongoDB vs. Relational DBWith mongo we can store our submissions in a single collection

- All data for a submission resides in one document

- This fits with the way we use submissions in our app.

Page 37: Starting from Scratch with the MEAN Stack

37

Building with the MEAN Stack

Page 38: Starting from Scratch with the MEAN Stack

38

What we’ll cover

• Using MongoDB in our project– NodeJS and MongooseJS

• Life of a submission: See the whole stack• Custom Mongoose Plugin:

– ElMongoose: Mongoose >> Elastic Search

Page 39: Starting from Scratch with the MEAN Stack

39

Using Node and Mongoose

Submission Schema

Page 40: Starting from Scratch with the MEAN Stack

40

Using Mongoose ModelsSubmission Schema from previous slide (Submit.js):

Using the schema in server.js (node runs this on start up):

Page 41: Starting from Scratch with the MEAN Stack

41

Mongoose vs. Mongo Java Driver

• Mongoose

• Mongo Java Driver

Page 42: Starting from Scratch with the MEAN Stack

42

Life of a submission

Page 43: Starting from Scratch with the MEAN Stack

43

Life of a Submission

User fills out a form• Angular has a data model

called $scope• Each form field is bound

to a key in the object stored at $scope.submission

Page 44: Starting from Scratch with the MEAN Stack

44

Life of a Submission User Submits the form

• Left: submission json generated by the form in the previous slide

• Below: Angular POSTs submission json to /submitForm

$scope.submission

hostedController.js

Page 45: Starting from Scratch with the MEAN Stack

45

Life of a Submission User Submits the form

• Left: submission json generated by the form in the previous slide

• Below: Angular POSTs submission json to /submitForm

$scope.submission

hostedController.js

Page 46: Starting from Scratch with the MEAN Stack

46

Life of a Submission

Request is received by ExpressJS• Express is listening at port 3000 for all requests• It’s easy to define routes in express

Page 47: Starting from Scratch with the MEAN Stack

47

Submission is saved to Mongo• Left: the json object has not

changed• Below: submission saved to

Mongo through the Mongoose Model Sub

Life of a Submissionreq.body

Page 48: Starting from Scratch with the MEAN Stack

48

Let’s do some customization

Page 49: Starting from Scratch with the MEAN Stack

49

Search and analytics engine

Hook into your Mongoose Models: Elastic Search

Fuzzy Matching, Relationships, Complex Aggregations

Page 50: Starting from Scratch with the MEAN Stack

50

Try ElMongoose

https://www.npmjs.com/package/elmongoose

El

Page 51: Starting from Scratch with the MEAN Stack

51

ElMongoose: Plugin for syncing data with elastic search through mongoose.

Hook into your Mongoose Models: Elastic Search

Page 52: Starting from Scratch with the MEAN Stack

52

ElMongoose: Plugin for syncing data with elastic search through mongoose.

Hook into your Mongoose Models: Elastic Search

Page 53: Starting from Scratch with the MEAN Stack

53

Hook into your Mongoose Models: Custom Plugin

You can add methods and hooks to that schema

Page 54: Starting from Scratch with the MEAN Stack

54

Hook into your Mongoose Models: Custom Plugin

You can add methods and hooks to that schema

Page 55: Starting from Scratch with the MEAN Stack

55

Ok... What Now and What’s Next?

Page 56: Starting from Scratch with the MEAN Stack

56

MEANingful Success?

MongoDB ExpressJS AngularJS NodeJS

Page 57: Starting from Scratch with the MEAN Stack

57

New Opportunities

SaaS

Modular Development

Page 58: Starting from Scratch with the MEAN Stack

58

Modular Development - What is it?

Modular Development

Page 59: Starting from Scratch with the MEAN Stack

59

Modular Example

Rolodex Module(Handles End User Management)

ModuleRoutes Controllers Assets

Page 60: Starting from Scratch with the MEAN Stack

60

How Modular Development?

CORE PROJECT

Login Rolodex Email

Features

ModuleRoutes Controllers Assets

Page 61: Starting from Scratch with the MEAN Stack

61

How Modular Development?

Routes Assets

Page 62: Starting from Scratch with the MEAN Stack

62

How Modular Development?

ModuleRoutes Controllers Assets

CORE Project

ModuleRoutes Controllers Assets

SUB Module

Page 63: Starting from Scratch with the MEAN Stack

63

How Modular Development?

Page 64: Starting from Scratch with the MEAN Stack

64

Custom Version of SUB

SUB Application

Login User Management Email

Page 65: Starting from Scratch with the MEAN Stack

65

What do we build with these?

Page 66: Starting from Scratch with the MEAN Stack

66

SAAS(Software as a Service)

SaaS

• Modular Feature Design• White Label Best Practices

• Single and Multi Tenant Options

Page 67: Starting from Scratch with the MEAN Stack

67

Single Tenant Application(Software as a Service)

Application

Database SecurityStorage

Page 68: Starting from Scratch with the MEAN Stack

68

Single Tenant Application(Software as a Service)

Application

Database

LOGIN

Storage Security

Page 69: Starting from Scratch with the MEAN Stack

69

Multi Tenant Application(Software as a Service)

Application

DatabaseCollection Collection CollectionCollection

Page 70: Starting from Scratch with the MEAN Stack

70

Multi Tenant Application(Software as a Service)

Application

DatabaseNewspaper ID Not For Profit ID School ID

Newspaper Not For Profit School

Page 71: Starting from Scratch with the MEAN Stack

71

Multi Tenant Application(Software as a Service)

Application

Newspaper Not For Profit School

Newspaper Not For Profit School

Config Service

Page 72: Starting from Scratch with the MEAN Stack

72

Integration

Page 73: Starting from Scratch with the MEAN Stack

73

Why We (heart) The MEAN Stack

Page 74: Starting from Scratch with the MEAN Stack

74

Questions?

Page 75: Starting from Scratch with the MEAN Stack

75

Contact

Matt CwalinskiLinkedIn: https://www.linkedin.com/in/mcwalinski

Twitter: @mcwalinski

Kat StyonsLinkedIn:https://www.linkedin.com/pub/kat-styons/48/3a4/604Twitter: @HappyKatTweets

Sruti CheedallaLinkedIn:https://www.linkedin.com/in/sruticheedallaTwitter: @shrootyc

Follow us on Twitter, @SubPlatform!

Page 76: Starting from Scratch with the MEAN Stack

76

Resources• MongoDB• Mongoose.js• Elasticsearch• Express.js• AngularJS• Node.js• https://www.npmjs.com/package/elmongoose• https://www.mongodb.com/webinar/get-started-with-the-

mean-stack?jmp=twt• http://coenraets.org/blog/• https://www.mongodb.com/blog/post/building-your-first-

application-mongodb-creating-rest-api-using-mean-stack-part-1