A Beginner’s Guide to the Parse Platform on Back4App

A Beginner's Guide to the Parse Platform on Back4App

These days, it seems like the future of software developers is bleak with the rise of no-code platforms. Fortunately, there’s a way to make ourselves more efficient today by leveraging our existing skills to build new apps using low-code platforms. Unlike no-code, low-code platforms are more flexible and offer greater customizable features. You can write custom code snippets and install Node.js packages to give your app more advanced features.

In this article, I’ll present a high-level overview of Back4App, a Backend-as-a-Service(BaaS) platform that hosts Parse applications for developers. BaaS platforms allow developers to quickly develop and launch new back-end apps with minimum effort. They also eliminate the need to set up hosting and configuring autoscaling, which can be a time-consuming task for developers.

What is the Parse Platform

The Parse platform is a popular, open-source framework for building application back ends. It runs on Node.js and is written to work with Express.js. Simply put, it’s like an open-source version of Firebase that you can run on your machine and host on your own server.

The origins of the project date back to 2011, when Parse Inc was founded to provide a back-end tool for mobile developers. The startup raised $5.5 million in venture capital funding, which allowed it to grow its user base to 20,000 developers within a year.

The company became so successful that it was acquired two years later by Facebook for $85 million. By 2014, the platform was hosting about 500,000 mobile apps. Unfortunately, Facebook failed to invest in the development of the platform and decided to shut down the service by January 2017. In order to assist its customers, Facebook open-sourced the Parse platform so as to allow developers to migrate their apps to their own self-hosted Parse server.

Since then, the open-source community has continually worked on the project and has built a website, online documentation and community forum. Today, Parse provides a number of back-end features that include:

  • database management
  • file object storage
  • REST and GraphQL APIs
  • authentication
  • user permissions
  • live queries (real-time data)
  • push notifications
  • cloud functions
  • cloud jobs

The Parse platform is mainly made up of:

  • Parse Server: a headless server for building back-end apps.
  • Parse Dashboard: a front-end user interface built with React.
  • Parse Server Modules: a collection of modules and adapters that extends Parse Server’s features. For example, you can install an adapter to leverage Firebase’s authentication service.
  • Client SDKs: language libraries for connecting front-end apps to Parse Server. These libraries include JavaScript, Android, Objective C, Flutter, Unity and many others.

Note that there are several Parse projects that I haven’t mentioned here. For example, there are Android and IOS apps that provide front-end interfaces for Parse server.

Mongo vs PostgreSQL

Parse server currently supports Mongo and PostgreSQL databases, which are the leading databases in the NoSQL and SQL spaces respectively. Both databases are quite capable, which makes it difficult to choose which one to go with.

This detailed guide may be of assistance. In my opinion, if you’re a beginner, MongoDB is a better choice, as it’s more flexible and has a shallower learning curve. If you’re an experienced SQL developer, you’d be more productive with PostgreSQL. Below is a quick comparison for each database.

Mongo

Pros:

  • flexible schema: best for new projects whose requirements aren’t fully known
  • horizontal scalable: can easily server millions of users
  • supports realtime data updates and reads; great for analytical applications
  • sharding: can handle massive datasets easily

Cons:

  • Lacks referential integrity

Previous issues like ACID compliance and JOINS are now officially supported in the latest versions of MongoDB.

PostgreSQL

Pros:

  • rigid schema: best for projects with known requirements and strict data integrity
  • referential integrity/foreign key constraint support: requirement for defining table relations
  • out-of-the-box support for ACID transactions
  • uses SQL, the best query language for accessing and manipulating data

Cons:

  • longer learning curve
  • can only scale vertically; horizontal scaling is possible but not easy

If you’re still confused about which one to use, fortunately Back4App has an answer for you.

Back4App

Back4App is a cackend-as-a-service company that hosts Parse server apps for developers at an affordable rate. It greatly simplifies the development of Parse apps. All you need to do is to sign up for a free tier account (no credit card) to get started with 250MB of data storage and 25k requests.

Paid plans offer larger resource quotas and more features such as backups, data recovery, CDN, auto scaling and high request performance. The free plan only is only recommended for learning, while the paid plans are capable of handling thousands of requests per second. See the full pricing page for more details.

Multi-tenant dashboard

Back4App allows you to create and manage multiple Parse apps on the same dashboard. This is a huge time saver compared to manually installing, configuring and hosting each parse server yourself. The difference is minutes vs hours.

multi tenant dashboard

Database browser

Back4App uses Mongo for the database. However, it behaves as if it’s running PostgreSQL. This is great, since you get the advantages of SQL databases while using a non-SQL one — such as referential integrity, foreign key constraints and schema validation. This implementation is done in code and runs between the database and the dashboard.

The database browser organizes tables (collections) as classes and data is laid out in a spreadsheet format. You can add/edit/delete/reorder columns, specify data types, and import/export data in CSV or JSON formats.

database browser

The spreadsheet interface allows you to create and edit rows of data easily. You can also upload binary files such as images or PDFs into columns that have the File data type. This is another huge time saver, as you don’t need to configure a file storage service to handle binary data. With Parse, it’s already built-in and configurable to support external file storage services.

Authentication

Parse provides a built-in email/password authentication service. Users and roles are stored in the database and can be viewed and created via the database browser. Users can also be created programmatically via SDK, REST or GraphQL API endpoints.

Here’s an example of a sign-up function implemented on the front end using the Parse JavaScript SDK:

function signUp() { let user = new Parse.User(); user.set("username", "alex"); user.set("password", "abc123"); user.set("email", "a@abcd.com"); try { user.signUp(); // Everything worked and the user signed in } catch (error) { alert("Error: " + error.code + " " + error.message); // Oops.. something wrong happened } } 

Back4App allows developers to enable email verification and password recovery features for their Parse apps. These are essential account management features that users expect when using any secure application.

In addition to the default authentication method, you can enable your Parse app to authenticate using any of the following sign in methods:

  • Apple
  • Facebook
  • GitHub
  • Google
  • Twitter
  • LinkedIn
  • and many more

Authorization

Authorization determines if an authenticated user has access to information stored on the database. Permissions are defined with the use of Roles and Access Controls. There are two levels of access controls:

  • Class-level permissions (CLP) : this type of permission protects all the data in a class(table). You can define different read and write policies for each role using CLP.
  • Object-level access control: This type of permission protects individual rows. This allows one user’s data to remain separate from another user within the same class (table). Parse also supports separating data for anonymous users using sessions.

Parse uses access control lists (ACL) to protect private data from being publicly accessible. However, if the user has some data that needs to be shared publicly, a second ACL needs to be created in order to grant public access. Do note that class-level permissions will always override ACL permissions.

Blockchain database

This is a new feature that allows storing data in a private Ethereum blockchain network. Blockchain differs from a traditional database in that, once records are inserted and verified, they can’t be updated or deleted. This has many practical implementations where trust between parties is critical in a business transaction.

blockchain database

At the time of writing, this feature is still in the alpha stage.

Public Datasets

Often when building user interfaces, you’ll need to populate certain input elements with data such as list of countries, cities, zip codes, vehicle models, colors, and so on. Back4App solves this problem by providing the Database Hub, a list of public databases that you can freely access and use for your app.

A dataset example of all the cities of the world is pictured below:

public datasets

There are three ways of accessing a public database:

  • You can connect a public database to your app. Once the connection is successful, you can query the database via REST or GraphQL via your app. This method allows your app to receive any new updates to the schema and data.
  • You can clone the public database to your dashboard in a new app.
  • You can export a public database into CSV or JSON format, and then import it into your app.

The last two methods allow you to modify the public datasets as you like.

Live query

When building real-time applications, you may be forced to fetch new data every one or so seconds in order to check if there’s been any new update. This technique is known as polling, and it’s problematic, because it causes high network and server usage. Imagine if your app is being used by tens of thousands of users.

Parse has a built-in protocol known as LiveQuery that allows clients to subscribe/unsubscribe to a LiveQuery server. When the relevant data is updated, the LiveQuery server pushes the new data to all clients that have subscribed to it.

With Back4App, activating the LiveQuery server is as simple as going to your App’s Server settings > Server URL and Live Query and activating it.

activate live query

Continue reading A Beginner’s Guide to the Parse Platform on Back4App on SitePoint.