I recently was contracted to build an MVP of a product for a new app. The app is called Nexus, feel free to check it out here. Nexus is a contact sharing app where users can share information fast and effectively. My main goal when building this project was focusing on scalability, cost, and maximizing speed as much as possible.

The Stack

Due to the constraints of time and wanting to create an identical experience for both iOS and Android it made total sense to chose React Native, which if you are unfamiliar allows you to write Javascript and React to build stateful interfaces that get transposed into native code.

Frontend

Where the project gets interesting is the backend. To optimize for the constraints of this project I wanted to chose a platform that I had experience with and would allow us to be flexible. I fell on Firebase. Firebase is powerful and jam-packed with tools for backends.

How did you keep cost down?

I used Firestore, which is a NoSQL database where you are charged majorly for your read and writes to the database. Because of this, I built data structures that were extremely easy to maintain and required limited fetching. I used caching methods to store “stale” data but refreshed the cache on the main document on an as-needed use case.

One fear I had using a NoSQL database was security. Because of this, I wanted to use Firebase Cloud Functions (Serverless functions) to ensure document integrity. My security rules are really quite simple.

If a user owns a document, he was permission to create or update that document. Otherwise only our functions can delete or update a user’s document.

Because of this simplified logic, all relations in our database are enforced and then cached by our cloud functions!! 🔥

I was extremely happy with how this turned out. And after running the numbers on an average use case of a user using the app 1 time a day 6 days a week, I was able to show that the average cost per user would be below $0.00005. This number is greatly impacted by the caching tactic.

This was a brief over view of the architecture of a freelance application I made. This was really informal as it was my first post. But I expect to get better and write more often!

Leave a Reply

Your email address will not be published. Required fields are marked *