#! Dev's Bytes
Random programming stuff
#! Dev's Bytes

Full Stack Development: from the backend to the app

Share Tweet Share

Recently, I have worked on the entire stack to develop a SaaS, web client and Android app included. Thoughts, tips, and tricks on the process and the software.

This week, I have had a lot of things to do. I ended the work on mg the Pelican theme that powered this blog, and I have started to learn Erlang, so I didn't have enough time to write a technical tutorial, but I want to share some thoughts on a project on which I have worked from July of the last year, Clochera.

Clochera should have been an app to help both restaurants owners and customers, providing a better service to the formers and a way to optimize management costs and times to the latters. Unfortunately, the project seems to have reached a standoff, mostly for the lack of a developer that help me with software manteinance after the app shipment.

But every cloud has a silver lining. I have learnt a lot from it. I tried new programming languages, new tools, datebases, and development platforms. Now I know better how to manage my time between tasks and what are the weak spot where I need to improve.

However, this is "Dev's Bytes", not "Thoughts on the Life, the Universe and Everything", so here are some tips for you and your future project or startup.

The Golden Rule

The most important thing that I have learnt is keep it simple. I don't come up with this stuff, every process tends toward the maximum disorder. You can call it Murphy's Law, or thermodynamics. So as the natural entropy is constanly raising, the same is true for the "entropy" of your code. Not so well documented hotfixes, new features required by customers, and, of course, incoming deadlines are all stuffs that make your code grow larger and messier. If you start with a simple design, simple interfaces, and easy to use software, you can, at least in part, deal with those things and assure to you a better working and coding manteinance experience.

You should built your team first

Some months ago, when I started to code, I was pretty sure that I didn't need other developers for quite a while. I was wrong. Currently, the main issue with my project is the lack of someone that will help me after the public release. So, as soon as your API is stable enough, start to built your team. Before that, it is useless. What could the front end and the app guys do if they do not know how to "talk" with the back end? But after the API is ready, you can parallelize these tasks and, naturally, spend a fraction of the time required if you do all the work alone.

The programming language for the back end

My language of choice was Python. Python is a good programming language that lets you archieve a huge productivity. I had built a couple of toy projects in Python before that, and it had always prove its good skills.

Therefore, I started to built the back end with Django, and I found that, with it everything is as plesurable as a form in triplicate. Furthermore, some parts of my work required real-time capabilities, and Python is not very good at it. I could have tried Flask, but the real-time problem would have last. This is the point were I had a look at Go. Go proved to be really good, it handled the concurrent stuff in an easy way with goroutines. The only weak spot that I have found in the language is the error handling system, but I recognize that is mostly a matter of taste.

So, for your next app, have a look at Go. The language is simple, the standard library and sub-repositories are very rich, with everything you may need, from JSON marshaller to WebSocket, from cryptography to image manipulation. I used it even to built the push notification system for Android.

The database(s)

With Django, the natural choice was PostgreSQL, but later on, I found that my data were not really relationals and that I needed something more flexible than a RDMS, so my final choice was RethinkDB for the data that does not vary often and Redis for all the rest. Both are really simple and straightforward to use. RethinkDB uses JSON for storing data and is built to scale really well. It can use secondary indexes and do nearly everything SQL can do. Oh, and it has even map/reduce functionalities. Redis is the true Swiss Army knife of your stack. It can work as a cache, as a queue system, as a messaging system, and, of course, it can store your data.

Don't use AngularJS

At a first glance, AngularJS seemed to me as a valid choice for the front end. It wasn't. AngularJS is, in many ways, the Java of the front end development. Don't use AngularJS because Angular 2 will probably break compatibility with the current Angular and because it is still not mature enough. And yes, you can replace all of its functionalities. Better yet, if you can, avoid client side javascript if not for augmentation or particular requirements (e.g. WebSocket).

On the mobile app

Again keep it simple and if you can, avoid early app development. You should develop a better web interface and work on responsive design and mobile compatibility of your pages. Only after that the public will begin to use your service, you can start with mobile apps.

If for some reason you need the app from the start, you should develop for iOS first. Android development, even after the release of Android Studio, is still a (sigh!) painful process. You should brace yourself to writing XML layout by hand, deal with all of the Java stuff, and fight with a slow and buggy IDE. Android Studio requires more than 1 minute to start and be usable on my desktop, with an AMD FX-6300 and 8 GiB RAM. Furthermore, it crashes more often than not. Oh, and the emulator does not work, it will never work, or, if you are lucky, it will be as slow as hell. End of rant.

Tips on Android development

Are you so proud, fool, or desperate to go on with the Android app development? Well, there is still something that you can do to make it a little less awful. Use good libraries. I'm referring to GSON, the Square ones, Eventbus, and Butter Knife, these really simplify my life a lot.

Server setup and other utilities

NGINX was my choice as load balancer and server, I guess that you already know it. I used Supervisor to spawn and demonize processes (the Go back end, notifications for Android, ecc...), and Monit for system monitoring and error recovery. System stats were collected with collectd.

All those things ran on a machine with Ubuntu 14.04LTS. Ubuntu is not my favourite distro, but it is likely the one with the best support from sofware publisher, so it has every program needed for the job.

A final note

During my work, I gave myself a rule of thumb:

If you can't get how to make something work in half a day, replace it with something that you can put to work in half a day.

This is the best thing that I could do. Again, the secret is keep it simple.

So, what do you think about it? What's your stack? Please, leave a comment and let me know it!


Receive Updates

ATOM

Contacts