SlideShare a Scribd company logo
MeetUp
MongoDB & Chirp
Antonio Di Motta
github.com/antdimot
Who am I?
I’m Antonio Di Motta e I’m Software Architect responsible for designing and
developing of complex projects based on platform mixing open source and
licensed products for the following markets: public transport, food and
beverage, industry and media.
http://creativecommons.org/licenses/by-nc-sa/3.0/”
https://github.com/antdimot/chirp/blob/master/README.md
http://creativecommons.org/licenses/by-nc-sa/3.0/”
MEAN, the fullstack javascript
http://creativecommons.org/licenses/by-nc-sa/3.0/”
MongoDB – Why?
Today’s solutions need to
accommodate tomorrow’s
needs
• End of “Requirements Complete”
• Ability to economically scale
• Shorter solutions lifecycles
http://creativecommons.org/licenses/by-nc-sa/3.0/”
RDBMS MongoDB
Database Database
Table Collection
Index Index
Row Document
Column Field
Join Embedding & Linking
MongoDB
http://creativecommons.org/licenses/by-nc-sa/3.0/”
MongoDB – What is a document ?
// chirp, post document example
{ "_ id": "5759416fc7d0ffbdd72a2e98",
"username": "dimotta",
"ownerid": "5759416fc7d0ffbdd72a2e95",
"displayname": "Antonio Di Motta",
"image": "dimotta.jpg ", "timestamp":
ISODate("2016-06-18")
" text": "My first post on Chirp."
}
// chirp, user document example
{
"_id": "5759416fc7d0ffbdd72a2e95", // ObjectId
"username": "dimotta",
"displayname": "Antonio Di Motta",
"password": "$2a$10$nn4S7KMtT8GzQhNBLnToJuBs",
"email": "antonio.dimotta@gmail.com",
"image": "dimotta.jpg",
"following":["5759416fc7d0ffbdd72a2e96","5759416fc7d0ffbdd72a2e97"],
"followers":["5759416fc7d0ffbdd72a2e96","5759416fc7d0ffbdd72a2e97"]
}
http://creativecommons.org/licenses/by-nc-sa/3.0/”
MongoDB – Installing
1) Downloading setup package from https://www.mongodb.com
2) Using DOCKER
docker pull mongo
docker run –d mongo
http://creativecommons.org/licenses/by-nc-sa/3.0/”
MongoDB – CLI
$ mongo
> show dbs
chirp
local
> use chirp
> show collections
posts
users
> db.users.find()
{
"_id": "5759416fc7d0ffbdd72a2e95",
- - - - - - - - - - - - - - - - - -
http://creativecommons.org/licenses/by-nc-sa/3.0/”
MongoDB – more with query
> myposts = db.posts.find( // create a function
{ “username”: “dimotta” }, // only my posts
{ “text”:1, “timestamp”:1 }, // only text and timestamp fields
)
> doSomethingWithPostList( myposts )
http://creativecommons.org/licenses/by-nc-sa/3.0/”
MongoDB – insert new document
> db.users.insert(
{
"_id": "1",
"username": "newusername",
"displayname": "I'm not a bot :)",
"password": password,
"email": "email@",
"image": "default.gif",
"summary": "Only for testing :)",
"following": [],
"followers": []
});
http://creativecommons.org/licenses/by-nc-sa/3.0/”
MongoDB – How to use it with app
BSON
Data
Format
Mobile App
Browser Desktop
REST API
Query
BSON
Driver
nodejs
.net
Java
…….
{ code }
MongoDB Application Consumers
http://creativecommons.org/licenses/by-nc-sa/3.0/”
Chirp architecture
http://creativecommons.org/licenses/by-nc-sa/3.0/”
How is organized the project
Front-end
Rest API
External packages
Misc script files
Chirp utility library
Static content files
Back-end configuration
Application entry point
http://creativecommons.org/licenses/by-nc-sa/3.0/”
app/package.json
http://creativecommons.org/licenses/by-nc-sa/3.0/”
app/libs/logger.js
http://creativecommons.org/licenses/by-nc-sa/3.0/”
app/libs/helper.js
http://creativecommons.org/licenses/by-nc-sa/3.0/”
app/config.js
http://creativecommons.org/licenses/by-nc-sa/3.0/”
app/main.js
http://creativecommons.org/licenses/by-nc-sa/3.0/”
APIs made simple
Basically each developer has his own standard and his own ideas on what an
API should look like. And that’s bad.
http://creativecommons.org/licenses/by-nc-sa/3.0/”
API best practices
´ Make it REST, keep it JSON. Everybody speaks JSON, no need to ruin lives with XML
´ Never break backwards compatibility. Version your API, nice and easy: /api/v1/user can
easily coexist with /api/v2/user and your customer has the freedom to update his API when
he is comfortable.
´ Never camelCase it
´ Never start a property name with a number
´ Pluralize arrays in naming
´ Booleans. Always true or false, never null or undefined
´ If a property has the value null then remove it
´ Send your dates in UTC, without any offsets. 2015–05–28T14:07:17Z is much friendlier than 2015–
05–28T14:07:17+00:00
´ Use lowercased, hyphen separated words in your URL. /store-order/1
´ Query params, as the field names should be snake-cased customer_name, order_id
´ Use the right status codes: 200 for success, 403 forbidden…
´ Return proper error messages, never return error stack
´ If the client does not need the entire resource he should be available to filter for only the
information interesting to him, in order to save bandwidth.
http://creativecommons.org/licenses/by-nc-sa/3.0/”
app/routes
app/routes/index.js
http://creativecommons.org/licenses/by-nc-sa/3.0/”
app/routes/post/home_timeline.js
http://creativecommons.org/licenses/by-nc-sa/3.0/”
Single Page lifecycle model
http://creativecommons.org/licenses/by-nc-sa/3.0/”
http://creativecommons.org/licenses/by-nc-sa/3.0/”
Remember WWW folder?
Do you need all this
files for one page
only?
http://creativecommons.org/licenses/by-nc-sa/3.0/”
app/www/index.html (only body)
http://creativecommons.org/licenses/by-nc-sa/3.0/”
app/www/js/config.js
http://creativecommons.org/licenses/by-nc-sa/3.0/”
app/www/js/services/dataservice.js
http://creativecommons.org/licenses/by-nc-sa/3.0/”
app/www/js/services/authservice.js
http://creativecommons.org/licenses/by-nc-sa/3.0/”
Socket.IO enables real-time bidirectional event-based communication.
It works on every platform, browser or device, focusing equally on reliability and speed.
RealtimeService.js
HomeController.js
http://creativecommons.org/licenses/by-nc-sa/3.0/”
PostDirective.js
post-directive-template.html
http://creativecommons.org/licenses/by-nc-sa/3.0/”
Chirp, to do:
´ searching (users and messages)
´ security enhancements (ie. add jwt)
´ hashtag support
´ api documentation
´ edit user information
´ customize user info (ie. image profile)
´ repost
http://creativecommons.org/licenses/by-nc-sa/3.0/”
Happy coding J

More Related Content

PPTX
INFA intern showcase for Summer Project
PDF
Docker and DevOps - Why it matters
PPTX
ASP.NET and Docker
PPTX
ACM Gazi Docker?
PPTX
20170321 docker with Visual Studio 2017
PPTX
A basic overview of Containers
PPTX
8 good reasons to learn docker
PDF
Demystifying Docker
INFA intern showcase for Summer Project
Docker and DevOps - Why it matters
ASP.NET and Docker
ACM Gazi Docker?
20170321 docker with Visual Studio 2017
A basic overview of Containers
8 good reasons to learn docker
Demystifying Docker

What's hot (20)

PPTX
PDF
Microservice Composition with Docker and Panamax
PPTX
Docker containers on Windows
PDF
Dockercon 2018 EU Updates
PPTX
Docker Deep Dive Understanding Docker Engine Docker for DevOps
PPTX
How to Dockerize Angular, Vue and React Web Apps
PDF
Bauen und Verteilen von Multi-Arch Docker Images für Linux und Windows
PPTX
Introduction Into Docker Ecosystem
PDF
Docker notes for newbies
PDF
Kubernetes buildpacks - from a source code to the running OCI container with ...
PDF
Living with microservices at Pipedrive
PDF
Canary deployment with Traefik and K3S
PDF
Docker Introduction
PPTX
Infrastrucutre as Code
PDF
My Journey to Becoming a Docker Captain
PDF
PPTX
K8s from Zero to ~Hero~ Seasoned Beginner
PPTX
Deploying Docker containers on Azure using Docker CLI
PDF
Introduction to Panamax from CenturyLink
PDF
Docker - Alem da virtualizaćão Tradicional
Microservice Composition with Docker and Panamax
Docker containers on Windows
Dockercon 2018 EU Updates
Docker Deep Dive Understanding Docker Engine Docker for DevOps
How to Dockerize Angular, Vue and React Web Apps
Bauen und Verteilen von Multi-Arch Docker Images für Linux und Windows
Introduction Into Docker Ecosystem
Docker notes for newbies
Kubernetes buildpacks - from a source code to the running OCI container with ...
Living with microservices at Pipedrive
Canary deployment with Traefik and K3S
Docker Introduction
Infrastrucutre as Code
My Journey to Becoming a Docker Captain
K8s from Zero to ~Hero~ Seasoned Beginner
Deploying Docker containers on Azure using Docker CLI
Introduction to Panamax from CenturyLink
Docker - Alem da virtualizaćão Tradicional
Ad

Viewers also liked (6)

PDF
Цифровые медиа в России и Украине
PPTX
монетизация. что и как продают современные медиа.
PPT
Non-ad monetization
PDF
Константин Чумаченко, NGENIX
PPTX
Encore Session - Motivate and Empower Globally-Competitive Teams of Content P...
PPTX
How to Motivate and Empower Globally-Competitive Teams of Content Professionals
Цифровые медиа в России и Украине
монетизация. что и как продают современные медиа.
Non-ad monetization
Константин Чумаченко, NGENIX
Encore Session - Motivate and Empower Globally-Competitive Teams of Content P...
How to Motivate and Empower Globally-Competitive Teams of Content Professionals
Ad

Similar to MongoDB & Chirp (20)

PDF
RefCard API Architecture Strategy
PDF
HTML Hypermedia APIs and Adaptive Web Design - jDays 2013
PPTX
API Workshop: Deep dive into REST APIs
PDF
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
PPTX
Decoupled Architecture and WordPress
PDF
Why You Should Be Doing Contract-First API Development
PDF
Continuous API Strategies for Integrated Platforms
DOCX
How backbone.js is different from ember.js?
PDF
Lessons from running AppSync in prod
PDF
7 network programmability concepts python-ansible
PDF
Unleashing the Future: Building a Scalable and Up-to-Date GenAI Chatbot with ...
PDF
Top 7 wrong common beliefs about Enterprise API implementation
PDF
Octo API-days 2015
DOCX
Over view of Technologies
PPTX
Architecting Microservices in .Net
PDF
Practical guide to building public APIs
PDF
APIdays Paris 2018 - Autonomous APIs, Zdenek Nemec, Founder, Good API
PDF
OpenFest 2016 - Open Microservice Architecture
PPTX
API Documentation -- Presentation to East Bay STC Chapter
PPTX
API Documentation presentation to East Bay STC Chapter
RefCard API Architecture Strategy
HTML Hypermedia APIs and Adaptive Web Design - jDays 2013
API Workshop: Deep dive into REST APIs
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
Decoupled Architecture and WordPress
Why You Should Be Doing Contract-First API Development
Continuous API Strategies for Integrated Platforms
How backbone.js is different from ember.js?
Lessons from running AppSync in prod
7 network programmability concepts python-ansible
Unleashing the Future: Building a Scalable and Up-to-Date GenAI Chatbot with ...
Top 7 wrong common beliefs about Enterprise API implementation
Octo API-days 2015
Over view of Technologies
Architecting Microservices in .Net
Practical guide to building public APIs
APIdays Paris 2018 - Autonomous APIs, Zdenek Nemec, Founder, Good API
OpenFest 2016 - Open Microservice Architecture
API Documentation -- Presentation to East Bay STC Chapter
API Documentation presentation to East Bay STC Chapter

Recently uploaded (20)

PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPTX
1. Introduction to Computer Programming.pptx
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
Mushroom cultivation and it's methods.pdf
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
project resource management chapter-09.pdf
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
August Patch Tuesday
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
DP Operators-handbook-extract for the Mautical Institute
Group 1 Presentation -Planning and Decision Making .pptx
1. Introduction to Computer Programming.pptx
OMC Textile Division Presentation 2021.pptx
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Mushroom cultivation and it's methods.pdf
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
A comparative study of natural language inference in Swahili using monolingua...
Enhancing emotion recognition model for a student engagement use case through...
Building Integrated photovoltaic BIPV_UPV.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
A novel scalable deep ensemble learning framework for big data classification...
1 - Historical Antecedents, Social Consideration.pdf
project resource management chapter-09.pdf
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
TLE Review Electricity (Electricity).pptx
Univ-Connecticut-ChatGPT-Presentaion.pdf
August Patch Tuesday
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Unlocking AI with Model Context Protocol (MCP)
DP Operators-handbook-extract for the Mautical Institute

MongoDB & Chirp