2. AGENDA
➔ Learn a bit about Node.js and Express
➔ Learn some MongoDB basics
➔ Build a location aware Job search application
➔ Go live with a Node.js MongoDB powered app in
~ 45 mins
3. Write an application and host it on internet
http://localjobsdemo-shekhargulati.rhcloud.com/
GOAL
9. Node.js goal is to provide an easy way to
build scalable network applications.
Some ex. Web servers , TCP servers,
Streaming server , Realtime apps, etc.
NODE.JS GOAL
10. Node.js is Server Side JavaScript.
● It provides runtime environment
● It provides a library
NODE.JS IS
11. ● Non Blocking I/O
● Based on Google's Chrome V8 engine
● 40k + modules
● Active community
● Multi platform – Windows , Mac , and Linux
● Use single language for both client and
server.
● JavaScript is language of Web.
WHY NODE.JS
12. ● Go to http://nodejs.org/ and click install.
● Install the downloaded package.
INSTALLING NODE.JS
18. 18
Open Source NoSQL document datastore
– JSON style documents
Schema-less
– Each document is heterogeneous, and may have completely
unique structure compared to other documents
Fast and horizontally scalable
Rich query language
Rich documents
Easy to get running
Geospatial indexing
WHAT IS MONGODB
21. 21
What is it for?
Find all the MongoDB jobs near me – Proximity Queries
Find all the MongoDB jobs within Bangalore – Bounded
Queries
Find all the MongoDB job at this location – Exact Queries
●
Supports only two dimensional indexes.
You can only have one geospatial index per collection.
By default, 2d geospatial indexes assume longitude
and latitude have boundaries of -180 inclusive and 180
non-inclusive (i.e. [-180, 180))
GEOSPATIAL INDEXING
BASICS
22. 22
1) Put your coordinates into an array
{ loc : [ 50 , 30 ] } //SUGGESTED OPTION
{ loc : { x : 50 , y : 30 } }
{ loc : { foo : 50 , y : 30 } }
1) { loc : { lon : 40.739037, lat: 73.992964 } }
2) Make a 2d index
db.places.ensureIndex( { loc : "2d" } )
3) If you use latitude and longitude as your coordinate system,
always store longitude first. MongoDB’s 2d spherical index
operators only recognize [ longitude, latitude] ordering.
HOW TO MAKE IT WORK
24. LocalJobs : Location Aware Job Search App
Functionalities or User stories or Features
1. As an Employer , I should be able to register my
company
2. As an Employer, I should be able to post jobs
3. As a Job seeker , I should be able to register myself with
application
4. As a Job seeker , I should be able to search jobs near to
my current location.
5. As a Job seeker , I should be able to apply a job
6. Etc...
APP -- USER STORIES
25. Prioritize the functionalities or user stories or features
– As an Employer, I should be able to post jobs
– As a Job seeker , I should be able to search jobs near
to my current location.
– As a Job seeker , I should be able to see all the jobs
PRIORITIZE
37. PaaS == Platform as a Service
A Cloud Application Platform
Code Deploy Enjoy
Save Time and Money
Code your app
Push-button
Deploy, and
your App is
running in
the Cloud!
38. 38
OpenShift
is
PaaS by Red Hat
Multi-language,
Auto-Scaling,
Self-service,
Elastic,
Cloud Application
Platform
41. ● Free! No time limit
● 3 gears (like servers) - each 512 Mb RAM, 1 Gb disk
● Auto-scaling
● Simple pricing
BUT WAIT – THERE's MORE
42. 42
rhc create-app localjobs nodejs mongodb-2.2 --from-code=
https://github.com/shekhargulati/localjobs-nodejs.git
Lot of other tasks you can do with rhc – tail log, app management,
cartridge management , ssh management , namespace
management, etc. Run rhc -h for details
DEMO : LOCALJOBS APP
RHC is only required for infrastructure tasks
44. IN CASE YOU CARE
•
Shekhar Gulati – Works at Red Hat
•
Principal OpenShift Developer Evangelist
•
Java / Python/ JavaScript / NoSQL / Cloud Guy
•
Twitter Handle : shekhargulati
•
Github https://github.com/shekhargulati
•
Slides https://speakerdeck.com/shekhargulati