How to create social networking app based on Firebase?

Maintaining server while building even a simple application, was always a big headache for mobile developers. If we add authentication with OAuth 2 tokens and SSO services, we would have twice work as at the beginning. That’s why Firebase became so popular, but is it really able to handle more complicated applications than traditional user’s to-do list?

Part 1: Data modeling

Most of data management is performed on client’s side, which is for sure one of the Firebase drawbacks (unless you use Cloud Functions, which are still in beta), that’s why you have to model data properly before writing any code. Firebase Realtime Database keeps data in JSON format, so it would suggest us to denormalize data everywhere, which is very common practice in non-relational databases. However, when you work with Firebase sometimes you have to normalize your data and it will happen very soon while you build social networking application. Let’s make an example of app which allows users to create posts. Every post has text and his author, the author has additional properties like username and URL of photo. Imagine that you want change user’s photo URL, would you change it in every path where user’s data are placed or rather only in “users” path?

Normalized data

Part 2: Android and iOS SDK

Social networking apps have a way of demanding complex data access. Probably you have to use all kinds of saving data and Firebase gives you ability to save data remotely and locally. Personally, I don’t recommend you the second way, because it’s hard to decide which shared data paths should remain synced and which not. As the result, you’ll get unexpected data when user is offline. Back to remote access, you have to abstract the Firebase layer as much as possible, because Firebase SDK uses callbacks everywhere. This results callback hell sooner than you expect while building social networking application, especially when you normalize data like mentioned before.

You’ll experience callback hell sooner than you expect

Part 3: Authentication

Building fast and safe authentication methods takes a lot of time, especially when you something like Facebook or Twitter SSO. Signing in with Facebook is fast for the user, but not for developer. Fortunately, Firebase Authentication speeds up building process a lot. First of all, we can choose from a large variety of authentication methods (e-mail, Google, Facebook, Twitter, Github, even phone number) and secondly, the process of tokens management is very simple.

Example of sing-in methods

Does Firebase really speed up development process of social networking app?

Of course it depends how large is your app. If you abstract implementation of Firebase SDK fast enough, you’ll be always able to migrate to your own server.

If you want to check how the social networking app is working on Firebase, check out one of our apps here and download Android or iOS version.