With the MongoDB Atlas developer data platform, you not only get the MongoDB document database, but also a host of other services, like GraphQL, authentication, triggers, serverless functions, Realm device sync and schema generation. All these together are known as Atlas App Services.
What does the MongoDB Atlas developer data platform contain?
The MongoDB data platform for developers is a one stop place for your application backend services. Whether it is directly querying the database from the client, calling serverless functions, performing search or creating triggers, Atlas has it all. MongoDB Atlas is also secure by default, scales up and out automatically, and helps reduce the overhead of maintenance tasks from the developers, thus boosting productivity and speed of project completion.
The MongoDB developer data platform consists of the MongoDB document database, static hosting, Atlas app services, and Atlas search, all within a single package.
Atlas app services provide out-of-box services that would otherwise have to be written by developers. All these services are available on the MongoDB Atlas GUI, which means there is no need to write any code at all. In the background, MongoDB creates a json file for each of the services created, so that you can perform any specific customizations required for a particular use case. You can also use the generated files for building the application, automating certain tasks or for scripting purposes.
To use Atlas App Services, you should have an Atlas account. Once you are logged in, you can view all the services on the left menu, as well as the App Services tab on the top.
Features of MongoDB Atlas App Services
MongoDB Atlas App services are a set of services that help developers build backend services directly from the Atlas UI. These services can act in real-time based on changes in the data, and can easily connect to external (third-party) systems too. API services take care of authentication, data validation and a lot of other things in the transactions between the server and the front-end client application.
App Services manages the backend infrastructure and has the following features:
Serverless: ‘App Services’ is serverless, which means you only use them on demand, and do not have to set up or manage the infrastructure. The service takes care of backup, web server, provisioning, deployment and much more.
Secure: Authentication services, including custom authentications are built into the app services, so developers do not have to write them. The custom access control includes role-based permissions, even at a field-level.
Real-time: You can sync data from multiple devices and sources in real-time using the Atlas Device sync app service.
Dynamic: You can use HTTP endpoints to process data, or execute Atlas functions and triggers as required. Atlas also takes care of scaling the application, and you only pay for what you are using.
MongoDB Atlas App Services
Depending on your application requirements, you may use one or more of the Atlas App Services that come packaged with the MongoDB Atlas data platform. For example, if your application needs data from multiple sources in real-time, you would use Atlas Device sync, or if your application wants an email to be sent when some change happens in the database, you can use Atlas triggers and write custom functions for the required actions.
Schema and rules
MongoDB is a flexible database that doesn’t have a fixed schema. However, if you want your application to have specific validations for the data, and want to define rules for data types and access control, MongoDB App services provides this option through the schema validation and access rules. MongoDB generates a JSON file using the JSON schema standard and maps your collection data to the application data, all using the Atlas UI. The UI also indicates validation errors in the schema.
Also, you can define how a user should be able to access the data. For example, an admin can read, write or delete all the data, a manager can access only a few collections, and a junior employee might be able to view only specific fields of a collection.
You can also set rules and filters for any collection. You could use the preset roles, or create custom roles from scratch.
User authentication
Generally, user authentication needs a lot of code to be written, particularly in websites where you need to use more complex authentication, like API keys or third-party authentication providers. App Services provides this out-of-the-box. Once you enable the authentication from your Atlas UI, you can use the authentication in any client application using a Realm SDK.
Atlas Device Sync
MongoDB Realm is a lightweight database used for building mobile applications. You can sync data across all devices from your mobile app in real-time using the Realm SDKs. For example, you are working on a mobile app like google drive document. You want your document to be accessible from other devices, like laptops as well. However, your mobile data is on and off, so you choose to write locally (offline) and then sync the data using a background process. That’s exactly how Atlas device sync works. It also automatically resolves conflicts arising out of simultaneous writes to the same document.
Triggers and Functions
Many applications use server-side functions for data transformation and validation. For example, suppose you have a credit card field to be filled on the front-end by the user. The client-side javascript will validate whether the number of digits are correct or if the user entered any gibberish. However, to verify whether it is a valid card number, you need a server-side validation. MongoDB Atlas provides an easy platform to write these javascript functions on the Atlas UI itself. MongoDB also provides a console to test the functions.
Similarly, if there are any events to be triggered when an action happens in the database, for example, if a new user record is inserted in a collection, an email should be sent to welcome the user. For this, we can create a trigger. This can be done in the Atlas UI itself. Triggers call Atlas functions to perform a particular task, like a database operation, authentication, running a scheduled routine.
GraphQL is an API query language with which developers get a single API endpoint to access the right data. GraphQL can get data from multiple sources, like a microservice, REST API or database, in a single request, and the application need not know about those sources. For the front end (UI) developers, GraphQL is the single source of truth and they do not have to depend on multiple backend APIs to get the data they want.
MongoDB Atlas App Services automatically creates a GraphQL type for linked collections that have a defined JSON schema. For the data you want to expose to GraphQL, App Services also creates the resolvers and types.
Conclusion
In this article, we have outlined how MongoDB Atlas is not just a simple database, but provides a host of other services, like a fully managed cloud data platform with default scaling and security features, UI for creating triggers, serverless functions and authentication, and many other services.