MongoDB Presents an Evening With Eliot Horowitz and Stitch
May 8, 2018 | Updated: March 11, 2019
On April 19th, 2018, the MongoDB User Group (MUG) met at the MongoDB HQ in New York City for an evening of conversation, trivia, and a live coding session from MongoDB co-founder and CTO Eliot Horowitz.
Nearly 60 attendees packed into the main presentation area and were met with good food and drink as they networked and prepared for Eliot's session on using the MongoDB Backend as a Service, Stitch. There were some new faces, some familiar faces, and of course, some MongoDB engineers in the group.
Meetup groups bring together like-minded individuals united through interest in a particular topic. MongoDB User Meetup Groups, or MUGs as they’re called, are certainly no different. MUG attendees share a belief in the transformative power of data and MongoDB. MUGs are also a place where developers, engineers, DBAs and tech enthusiasts can feel comfortable discussing databases, development, programming at virtually any level of experience.
Those unable to make it to our NYC HQ were able to take part in the demonstrations via a high quality live video stream. The live stream, which you can now watch on YouTube, along with our Community Slack kept the audience engaged as Eliot presented Stitch features.
This evening, Developer Advocate Jay Gordon opened with a few announcements about MongoDB World 2018, some upcoming MUGs, and some additional information about courses offered by MongoDB University. The interactive portion of the evening then kicked off with a trivia session hosted by Developer Advocate Aydrian Howard.
For this section, Aydrian leveraged Kahoot.com to guide the audience through a fun, interactive trivia quiz with questions about MongoDB. Participants were tested on their knowledge of MongoDB history and some of the technology using on-screen questions. Points earned were based on correctness and time to answer. Questions ranged from “What was the origin of the name MongoDB?” to “What command is used to drop a collection from the MongoDB Shell?” In the end, the top 2 scoring participants were awarded Amazon gift cards —Congratulations to Eric Pedregosa and Hardik Ginwala!
With trivia done, it was time for the main event. Eliot took to the podium and began his presentation on MongoDB Stitch.
Eliot dove into the talk with an explanation of exactly what Stitch is and where it fits into the database and surrounding landscapes. Currently in beta, Stitch is part backend as a service (BaaS), or Mobile Backend as a Service (MBaaS), part Functions as a Service (FaaS), part API Platform, and part Serverless platform. Stitch fits into a number of interesting spaces because of its flexibility. But before we get too deep into the technology, let’s take a look at some history to see how we got here.
In 2007, AWS released a massively impactful and innovative product to the world in its Elastic Computing platform called EC2. EC2 made it really easy for businesses to increase agility and speed to market without investing in on-premise server hardware.
In 2014, containers came along, further increasing agility and reducing dependence upon physical infrastructure. And most recently, in 2017, serverless computing became popular, with AWS Lambda as one of the most widely used options. Lambda gives users the ability to write code without having to manage app servers or containers. Developers write code and deploy this code to a cloud-based server and its just ready when it’s needed for execution.
The value proposition for serverless computing is extremely compelling. The critical logic required for an application becomes freed from the traditional vehicle required for its successful execution. However, when you leverage most serverless platforms you still need to design and write the logic responsible for handling integrations with services — effectively, you’re still required to build a RESTful API.
Stitch is different from serverless in many respects. Stitch provides you the freedom to concentrate on execution of methods and functions containing the vital logic of your application without having to build the entire interface and without having to build integration to 3rd party services.
Eliot provided several demonstrations of this power and flexibility, the first of which took the audience on a journey through what it might be like to add commenting capabilities to a blog, using MongoDB Stitch to handle the database interactions.
To assemble the components of this demonstration, Eliot first launched a cluster of MongoDB database servers using MongoDB’s database as a service offering, Atlas. With the cluster in place, Eliot created a new Stitch application, and leveraged an example code snippet to enable Stitch inside his web application. To accomplish this, he first created a section in the web page where the comments would appear dynamically. The text of these comments are be populated from the MongoDB database. Next, he imported the Stitch Library in the HEAD section of the web page.
The source for this particular demonstration is available on Github and can be leveraged to create your own very similar blog system leveraging Stitch. Take a look at the source repository README for specific instructions on setting this up on your own.
Next, Eliot moved on to another demonstration he created leveraging interconnected smart-home devices assembled to create a facial recognition security system.
Today, more and more products are becoming smart or internet-connected. The Internet of Things (IoT) has taken shape and now more than ever we’re able to embrace the power of technology and integration to accomplish things that would have been impossible a few short years ago. But connecting all these smart devices requires integration. Many have Application Programming Interfaces (APIs) but these often require hundreds of lines of integration code. This code is typically standard, boilerplate, or templated code and while non-differentiating, in many cases necessary to connect the various APIs to one another.
To demonstrate the power of IoT and the power of Stitch to alleviate the need to write all of the integration code to enable these devices to communicate, Eliot assembled a few relatively common components such as a camera, a deadbolt, and a simple switch.
Eliot showed how to utilize functions and the simplicity of using MongoDB Stitch to create an IoT Security system that is completely open source and ready for you to start playing with.
The components of this security system included:
- MongoDB Atlas, for storing data:
- User profiles
- Authorized user images, used for facial recognition
- Audit logs
- MongoDB Stitch
- A D-Link Connected Home Camera
- A Lockitron Bolt with WiFi bridge
- A Logitech Pop SmartButton with WiFi bridge
- Face++ a face-recognition service
- A React Web App, running on node.js, which manages the authorized users and configures the IFTTT webhook URLs
- A Google Cloud Platform App, which we use for authentication of security system administrators
- IFTTT, which handles all the message routing between the devices and Stitch
The system leverages these off the shelf Smart-Home components and turns them into a facial recognition security system with a total of 200 lines of code (including some JSON configuration).
The system stores photographs (base64 encoded) of visitors that are allowed entry in MongoDB. When a potential visitor attempts to gain entry (unlocking the deadbolt) using the system, they press a button, which triggers the camera to take a photo of the visitor. This photo is then programmatically compared with stores photos of authorized visitors and if there’s a match, the system sends a command to the deadbolt to tell it to unlock.
The project demonstrates how easy it is to use Stitch to orchestrate the complex interaction between multiple components, without having to spin up an application server. It is both a starting point for hobbyists or professionals who want to develop smart home solutions, and a tutorial for those looking to see Stitch in action.
The system is comprised of two major parts. The Stitch backend, which orchestrates the interaction of all the devices, is about 50 lines of code. The web-based admin UI is a single-page React application, which, at 150 lines of code, is 3x the size of the backend.
The power and potential of MongoDB Stitch to automate and offload integration is exciting. Whether you’re building something from scratch, a mobile, or web app, or even an IoT app. Stitch can save you hours of development time alleviating the need to:
- Build boilerplate integration code between your app and the database
- Build integration code between your app and essential third party services for things like authentication, authorization, sms text integration and many others.
To review the code Eliot presented in this talk, you can find the code in this GitHub repository. If you are interested in getting started building applications without application servers and without the need to build complex API’s and Backend Integrations, check out the MongoDB Stitch Beta and consider cloning Eliot’s repo and importing it into your own Stitch application to try it out for yourself.
You can view the entire presentation here:
Have you considered speaking, presenting at a MongoDB User Group? Join us in NYC, Philadelphia, or any one of the hundreds of MongoDB User Groups around the World!
Check out the MongoDB NYC User Group Call for Paper form. We'd love to hear about your current project, use of MongoDB or how you solved a problem.