SlideShare a Scribd company logo
John Culviner
GitHub: github.com/johnculviner
Blog: johnculviner.com
Twitter: @johnculviner
Email: john@johnculviner.com
+
About Me
 Independent Consultant @ BestBuy
 Backend
 DevOps (Docker, Ansible, Linux etc)
 Node.js
 NoSql (ElasticSearch, MongoDB)
 C# .NET
 Groovy/Spring/Java
 MS-SQL/MySQL
 Front End
 Manual, jQuery, Knockout.js, Durandal.js, Ember.js, Angular.js, Aurelia, React.js
 SPA development
 Open Source “Street Cred”
 AngularAgility
 jQuery File Download
 FluentKnockoutHelpers
Overview
 What is Node.js & what's it good for?
 vs .NET, Java etc.
 What is MongoDB & what's it good for?
 vs YOUR_FAV_SQL_DB_HERE
 Building a CMS from scratch
 Environment setup
 Simple API Endpoint
 Objective: What you should and shouldn't use this
stack for. To help you on your feet nice and easy!
What is ?
 Node.js is a JavaScript runtime built on Chrome's V8
JavaScript engine.
 It's like Chrome but it has framework modules that make
it useful on a server
Assertion
Testing
Buffer C/C++ Addons Child
Processes
Cluster Console
Crypto Debugger DNS Domain Errors Events
File System
Globals HTTP HTTPS Modules Net
OS Path Process Punycode Query Strings Readline
REPL Stream String Decoder Timers TLS/SSL TTY
UDP/Datagra
m
URL Utilities V8 VM ZLIB
 Node.js' package ecosystem, npm (node package
manager), is the largest ecosystem of open source
libraries in the world. modulecounts.com
What is ?
 Node.js uses an event-driven, non-blocking I/O model
that makes it lightweight and efficient.
 Single threaded event loop just like the browser
JavaScript you know and ¿love?
Event loop?
 EVERYTHING that is I/O bound blocking in Node.js is
async
 Node FORCES you to deal with I/O bound nature of
most of the apps we build* up front rather than
adding parallelization later on….
*by we I mean me and likely 90% of you
CPU bound?
 Don't block the single thread or else your app
will grind to a halt
 Think of times a website has locked up your
browser’s UI Classic while true
CPU intensive operations
Stack overflow
SUPER efficient with pipes
Actual entire node application
Why do I care ¯_(ツ)_/¯
 Allegedly (when
they aren’t using
Go)
--------------------------Big places in town you could work for ------------------------------
 Places with my
crappy Node code
in production 
Node.js - Good, Bad
 GOOD
 Web(like) applications that are limited
by I/O blocking (DB, backend service, file system, etc.
calls).
 Micro-services
 Moving data around/transforming data
 Rapid application development
 BAD
 Large, monolithic ‘enterprisey’
applications (strong typing *can* be nice)
 CPU intensive apps (you'll block the event loop and JS is
slow(er) than .NET, JVM, C++, etc.)
 You don’t think JavaScript is a “real” language
What is
 A “NoSQL” BSON (binary JSON) document DB
 Indexable, deep queryable, map-reduce aggregations
 Sharding – for data distribution “Scale out” on a shard key
(usually the document ID)
 Replication– for instance failure ‘safety’
Example
Shard Cluster (not required!)
Server A Server B
{ _id: ‘UUID’,
customerName: ‘Foo’
customerDomain ‘foo.com’
….}, {/*cust.*/},{/*cust.*/}
Collections
Pages
Cutomers
{ _id: ‘UUID’,
customerId: ‘UUID’
url: ‘/someurl’,
widgets: [
{name: ‘WidgetA’ /*settings*/},
{name: ‘WidgetB’, /*settings*/}
]
…..}, {/*page*/}, {/*page*/}…..
- Similar BSON documents
that end up here due to a
differing shard key from left
- BSON documents WITHIN
A COLLECTION can have
a varying schema! (but in
practice that might be a
bad idea)
Actual* email from MongoDB….
*minus the bro
part
Cutting through the BS…
 NoSQL works well for apps with few
“Aggregate Roots”
 “A group/cluster of objects that work together, are treated as
a unit that must remain consistent together”
Martin Fowler
likes aggregate
roots
Good use case
Pages
have Sections
have Widgets
have Settings
- settings might contain
nested object graphs etc.
• Only operate on a page
(read/write) as an atomic unit
• Duplication of data is small if
not non existent
Bad use case
Customers
Orders
LineItems
Products
Customer
Categories
Merchant
Categories
Vendors
• “Spiderweb” of relationships that
duplicate in a JOIN
• Care about operating on various “entities”
individually or within the bounds of an
atomic transaction
Random DB observations
 Why not BOTH relational and Document?
 Stores JSON natively and is querable/indexable!

 queries get slow in the millions of objects in a collection (w/o
index)
 Server side joins just added in version 3.2 (latest)
 ElasticSearch
 Built on Apache Lucene (just like Solr)
 Insanely fast search, data retrieval and full text queries
 Insanely fast n-levels deep aggregations and custom Groovy
scripts
 Very easy clustering/sharding/replication. Scale out!
Before we code…
 Tooling we are using:
 JetBrains IntelliJ/Webstorm
 NodeJS 6.3
 MongoDB 3.x
 iTerm + oh-my-zsh (z-shell)
 RoboMongo (the Mongo GUI)
 Install on *NIX
 [brew|apt-get|yum|etc..] install [mongodb|nodejs]
 Install on Windows
 Download MSIs/EXEs from respective websites
Node REPL
V8 JavaScript engine in
Node.js 4+ and Chrome
45+ supports string
templating and
LAMBDAS (w00t)
Okay seriously code now…
Questions/Comments?
John Culviner
GitHub: github.com/johnculviner
Blog: johnculviner.com
Twitter: @johnculviner
Email: john@johnculviner.com

More Related Content

What's hot (20)

PPTX
Introduction to dockerfile, SF Peninsula Software Development Meetup @Guidewire
dotCloud
 
PDF
Shipping Applications to Production in Containers with Docker
Jérôme Petazzoni
 
PDF
From Zero Docker to Hackathon Winner - Marcos Lilljedahl and Jimena Tapia
Docker, Inc.
 
PDF
Docker Continuous Delivery Workshop
Jirayut Nimsaeng
 
PDF
Docker by Example - Basics
Ganesh Samarthyam
 
PDF
Docker on Google App Engine
Docker, Inc.
 
PPTX
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
dotCloud
 
PPTX
Docker and java, at Montréal JUG
Anthony Dahanne
 
PPT
Amazon Web Services and Docker
Paolo latella
 
PDF
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
dotCloud
 
PDF
Dockerizing your applications - Docker workshop @Twitter
dotCloud
 
PDF
Docker presentation | Paris Docker Meetup
dotCloud
 
PDF
Using Containers for Continuous Integration and Continuous Delivery. KubeCon ...
Carlos Sanchez
 
PDF
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
Docker, Inc.
 
PPTX
Docker Basics
DuckDuckGo
 
PDF
Docker and Containers for Development and Deployment — SCALE12X
Jérôme Petazzoni
 
PDF
Using Kubernetes for Continuous Integration and Continuous Delivery
Carlos Sanchez
 
PDF
Luciano Fiandesio - Docker 101 | Codemotion Milan 2015
Codemotion
 
PPTX
Dockerize the World - presentation from Hradec Kralove
damovsky
 
PDF
Docker worshop @Twitter - How to use your own private registry
dotCloud
 
Introduction to dockerfile, SF Peninsula Software Development Meetup @Guidewire
dotCloud
 
Shipping Applications to Production in Containers with Docker
Jérôme Petazzoni
 
From Zero Docker to Hackathon Winner - Marcos Lilljedahl and Jimena Tapia
Docker, Inc.
 
Docker Continuous Delivery Workshop
Jirayut Nimsaeng
 
Docker by Example - Basics
Ganesh Samarthyam
 
Docker on Google App Engine
Docker, Inc.
 
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
dotCloud
 
Docker and java, at Montréal JUG
Anthony Dahanne
 
Amazon Web Services and Docker
Paolo latella
 
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
dotCloud
 
Dockerizing your applications - Docker workshop @Twitter
dotCloud
 
Docker presentation | Paris Docker Meetup
dotCloud
 
Using Containers for Continuous Integration and Continuous Delivery. KubeCon ...
Carlos Sanchez
 
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
Docker, Inc.
 
Docker Basics
DuckDuckGo
 
Docker and Containers for Development and Deployment — SCALE12X
Jérôme Petazzoni
 
Using Kubernetes for Continuous Integration and Continuous Delivery
Carlos Sanchez
 
Luciano Fiandesio - Docker 101 | Codemotion Milan 2015
Codemotion
 
Dockerize the World - presentation from Hradec Kralove
damovsky
 
Docker worshop @Twitter - How to use your own private registry
dotCloud
 

Similar to Node.js and MongoDB from scratch, fully explained and tested (20)

PPTX
Intro to node and mongodb 1
Mohammad Qureshi
 
PDF
Node azure
Emanuele DelBono
 
PPTX
An overview of node.js
valuebound
 
KEY
Practical Use of MongoDB for Node.js
async_io
 
PPTX
Kalp Corporate Node JS Perfect Guide
Kalp Corporate
 
PPTX
What is Mean Stack Development ?
Balajihope
 
PDF
Node.js Enterprise Middleware
Behrad Zari
 
PPTX
Nodejs
Vinod Kumar Marupu
 
PPT
18_Node.js.ppt
MaulikShah516542
 
PPTX
Beginners Node.js
Khaled Mosharraf
 
PPT
18_Node.js.ppt
KhalilSalhi7
 
PDF
Building an E-commerce website in MEAN stack
divyapisces
 
PPTX
NodeJS - Server Side JS
Ganesh Kondal
 
PPTX
Don’t Let Your Businesses Get Hampered By Large Volume Codes: Nodejs Is Your ...
Techahead Software
 
ODP
Sfd hanoi2012 nguyen ha duong yang node.js-intro
Vu Hung Nguyen
 
ODP
Sfd2012Hanoi Nguyễn Hà Dương - Introduction to Node.js
Vu Hung Nguyen
 
PPTX
MEAN.js Workshop
Michael Haberman
 
PDF
Nodejs presentation
Arvind Devaraj
 
ODP
Introduce about Nodejs - duyetdev.com
Van-Duyet Le
 
PDF
All You Need to Know About Using Node.pdf
iDataScientists
 
Intro to node and mongodb 1
Mohammad Qureshi
 
Node azure
Emanuele DelBono
 
An overview of node.js
valuebound
 
Practical Use of MongoDB for Node.js
async_io
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate
 
What is Mean Stack Development ?
Balajihope
 
Node.js Enterprise Middleware
Behrad Zari
 
18_Node.js.ppt
MaulikShah516542
 
Beginners Node.js
Khaled Mosharraf
 
18_Node.js.ppt
KhalilSalhi7
 
Building an E-commerce website in MEAN stack
divyapisces
 
NodeJS - Server Side JS
Ganesh Kondal
 
Don’t Let Your Businesses Get Hampered By Large Volume Codes: Nodejs Is Your ...
Techahead Software
 
Sfd hanoi2012 nguyen ha duong yang node.js-intro
Vu Hung Nguyen
 
Sfd2012Hanoi Nguyễn Hà Dương - Introduction to Node.js
Vu Hung Nguyen
 
MEAN.js Workshop
Michael Haberman
 
Nodejs presentation
Arvind Devaraj
 
Introduce about Nodejs - duyetdev.com
Van-Duyet Le
 
All You Need to Know About Using Node.pdf
iDataScientists
 
Ad

Recently uploaded (20)

PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Digital Circuits, important subject in CS
contactparinay1
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
Ad

Node.js and MongoDB from scratch, fully explained and tested

  • 1. John Culviner GitHub: github.com/johnculviner Blog: johnculviner.com Twitter: @johnculviner Email: [email protected] +
  • 2. About Me  Independent Consultant @ BestBuy  Backend  DevOps (Docker, Ansible, Linux etc)  Node.js  NoSql (ElasticSearch, MongoDB)  C# .NET  Groovy/Spring/Java  MS-SQL/MySQL  Front End  Manual, jQuery, Knockout.js, Durandal.js, Ember.js, Angular.js, Aurelia, React.js  SPA development  Open Source “Street Cred”  AngularAgility  jQuery File Download  FluentKnockoutHelpers
  • 3. Overview  What is Node.js & what's it good for?  vs .NET, Java etc.  What is MongoDB & what's it good for?  vs YOUR_FAV_SQL_DB_HERE  Building a CMS from scratch  Environment setup  Simple API Endpoint  Objective: What you should and shouldn't use this stack for. To help you on your feet nice and easy!
  • 4. What is ?  Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine.  It's like Chrome but it has framework modules that make it useful on a server Assertion Testing Buffer C/C++ Addons Child Processes Cluster Console Crypto Debugger DNS Domain Errors Events File System Globals HTTP HTTPS Modules Net OS Path Process Punycode Query Strings Readline REPL Stream String Decoder Timers TLS/SSL TTY UDP/Datagra m URL Utilities V8 VM ZLIB
  • 5.  Node.js' package ecosystem, npm (node package manager), is the largest ecosystem of open source libraries in the world. modulecounts.com
  • 6. What is ?  Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient.  Single threaded event loop just like the browser JavaScript you know and ¿love?
  • 7. Event loop?  EVERYTHING that is I/O bound blocking in Node.js is async  Node FORCES you to deal with I/O bound nature of most of the apps we build* up front rather than adding parallelization later on…. *by we I mean me and likely 90% of you
  • 8. CPU bound?  Don't block the single thread or else your app will grind to a halt  Think of times a website has locked up your browser’s UI Classic while true CPU intensive operations Stack overflow
  • 9. SUPER efficient with pipes Actual entire node application
  • 10. Why do I care ¯_(ツ)_/¯  Allegedly (when they aren’t using Go) --------------------------Big places in town you could work for ------------------------------  Places with my crappy Node code in production 
  • 11. Node.js - Good, Bad  GOOD  Web(like) applications that are limited by I/O blocking (DB, backend service, file system, etc. calls).  Micro-services  Moving data around/transforming data  Rapid application development  BAD  Large, monolithic ‘enterprisey’ applications (strong typing *can* be nice)  CPU intensive apps (you'll block the event loop and JS is slow(er) than .NET, JVM, C++, etc.)  You don’t think JavaScript is a “real” language
  • 12. What is  A “NoSQL” BSON (binary JSON) document DB  Indexable, deep queryable, map-reduce aggregations  Sharding – for data distribution “Scale out” on a shard key (usually the document ID)  Replication– for instance failure ‘safety’
  • 13. Example Shard Cluster (not required!) Server A Server B { _id: ‘UUID’, customerName: ‘Foo’ customerDomain ‘foo.com’ ….}, {/*cust.*/},{/*cust.*/} Collections Pages Cutomers { _id: ‘UUID’, customerId: ‘UUID’ url: ‘/someurl’, widgets: [ {name: ‘WidgetA’ /*settings*/}, {name: ‘WidgetB’, /*settings*/} ] …..}, {/*page*/}, {/*page*/}….. - Similar BSON documents that end up here due to a differing shard key from left - BSON documents WITHIN A COLLECTION can have a varying schema! (but in practice that might be a bad idea)
  • 14. Actual* email from MongoDB…. *minus the bro part
  • 15. Cutting through the BS…  NoSQL works well for apps with few “Aggregate Roots”  “A group/cluster of objects that work together, are treated as a unit that must remain consistent together” Martin Fowler likes aggregate roots Good use case Pages have Sections have Widgets have Settings - settings might contain nested object graphs etc. • Only operate on a page (read/write) as an atomic unit • Duplication of data is small if not non existent Bad use case Customers Orders LineItems Products Customer Categories Merchant Categories Vendors • “Spiderweb” of relationships that duplicate in a JOIN • Care about operating on various “entities” individually or within the bounds of an atomic transaction
  • 16. Random DB observations  Why not BOTH relational and Document?  Stores JSON natively and is querable/indexable!   queries get slow in the millions of objects in a collection (w/o index)  Server side joins just added in version 3.2 (latest)  ElasticSearch  Built on Apache Lucene (just like Solr)  Insanely fast search, data retrieval and full text queries  Insanely fast n-levels deep aggregations and custom Groovy scripts  Very easy clustering/sharding/replication. Scale out!
  • 17. Before we code…  Tooling we are using:  JetBrains IntelliJ/Webstorm  NodeJS 6.3  MongoDB 3.x  iTerm + oh-my-zsh (z-shell)  RoboMongo (the Mongo GUI)  Install on *NIX  [brew|apt-get|yum|etc..] install [mongodb|nodejs]  Install on Windows  Download MSIs/EXEs from respective websites
  • 18. Node REPL V8 JavaScript engine in Node.js 4+ and Chrome 45+ supports string templating and LAMBDAS (w00t)