DreamFactory — let there be (mobile) API for everyone!

Since the advent of Web 2.0, social interaction is king. Now, almost every single mobile app works in the environment of its users exchanging ideas through content authoring, comments, likes and shares. Even the simplest and most “personal” of them, like personal planners, address books and to-do lists, enable users to put their data in the cloud, share them with others and access them using a myriad of devices and interfaces. The bottom line is that every one of them needs a back-end and an API to talk to. All projects are executed through tight cooperation between back-end and front-end/mobile developers. Even in Lean Development reality, when you start to implement anything, you need to engage a bunch of people in a concerted effort, and a neat concept of a Minimal Viable Product often boils down to hundreds of work hours on several fronts.

Run, Lola, run!

Let’s assume you’re a mobile developer with an idea of that awesome one-of-a-kind app. With a help of your friend artist you came up with a fancy UX/UI, but you still need a server to store the data and let users exchange information. With no background in back-end programming, you need to start looking for yet another friend who will set up a server, create a database with a few tables in it and code a simple access API with authentication and user roles. Then you kick in with your mobile piece and keep asking the server guy to implement changes that occur with every iteration (by the way, they always do). And after a few weeks or months of „work for equity” you have your MVP ready just to check if it catches. And really, do you still think this is lean?

I’m a big fan of simple, quick and intuitive solutions to everyday problems. Having to learn two more languages and master several programming environments just to store basic to-do records of your users has nothing to do with simplicity. Having to write hundreds of lines of code to serve simple data sets doesn’t hold to the definition of „quick”.

Meet my new friend — DreamFactory

Technically speaking, DreamFactory is nothing revolutionary. It’s a neat open-source package binding together several existing tools and frameworks plus a decent admin panel with automatically generated API docs and live testing environment. What you get out of the box is:

  • An SQL database
  • File storage
  • User management engine
  • REST API endpoints and documentation
  • API access libraries for the Web and leading mobile platforms
  • Admin console
  • E-mail utility access

It comes in handy installation bundles for all major operating systems (Windows, Linux, OS X) and cloud providers (Heroku, Amazon Web Services, Google Cloud Platform and Windows Azure to name a few). You can choose to install it as a whole LAMP/WAMP stack or as a separate module. And if you want to get started right away and get a taste of it, register in the DreamFactory site and use a slightly limited version of the platform hosted on their servers.

DreamFactory is extendable — it can call external Web services and return the results through its API. But the real values of DreamFactory from the mobile developer’s perspective are twofold: ease of use and quick prototyping.

Build your API in 15 minutes

Believe it or not, but using DreamFactory you can create a simple REST API in 15 minutes without having to write a single line of code. In the course of the Android Mobile Development classes I run at the University of Gdansk, I gave my students an assignment of creating a simple cookbook app with basic social features, like sharing recipes, posting photos, commenting and rating them. I was the one to do all the back-end work.

So I began with creating necessary tables. In DreamFactory, creating a table is as simple as giving it a name and defining its columns using a functional GUI:

2015-01-26 16_03_53

If you want to use advanced platform features, you can create primary and foreign keys, build relations between tables, constrain the data and set default values, but beginners will want to start with simple text and number fields.

Then, I defined user roles. I created a „guest” role for public read-only access that doesn’t require logging in, and an authenticated „author” role for creating/updating records. In DreamFactory there are Advanced Filters that e.g. enable limiting write access to a person who created a given record. With a few more clicks I enabled open registration so that anyone could register their account and log in to create content.

To store binary objects (like pictures in my example), you can either use the embedded file storage API or save Base64-encoded binary objects as strings directly in the database (with the obvious drawbacks of such an approach).

With a few more clicks I created an app profile, gave permissions to generated resources and tested my API. I could even fill out my tables with initial data, set up test user accounts and add user confirmation email templates. When I was done, I created an application package to have a backup of my work. Then I stopped the count-down clock. A quarter of an hour. No kidding.

But what if I want to…

DreamFactory is not a swiss-army knife and I don’t think it was ever meant to serve as a replacement for huge and complex back-end services. Though you can enhance existing services and create your own endpoints using server-side scripts written in JavaScript, the solution falls short when it comes to highly customized scenarios and sophisticated user structure models. But the major advantage of DreamFactory is the sheer fact that you can have a working API with a database, file storage and user infrastructure for your MVP or Proof-of-Concept in a matter of minutes with no server-side coding experience required.

If you know other tools and frameworks that take the time needed to create simple API services from days to minutes, I’d be glad to hear from you. After all, the real heroes out there are the ones who leave office earlier because they manage to do their work faster.

Tags: