How I created GitWit as a cloud app
*I recently figured out myself how to use Firebase with Terraform*
with
document store
multiple users
authentication
billingMaking a serverless document-based application#
I’m not a devops guy. I’m a dev guy. So when I decided to use Firebase as the platform to build my last product, I thought it could be a gentle way to transition into cloud architecture.
Was it really easy? Let’s see.
The product I’m building is a document based web app. (Imagine something like Google Docs or Draw.io) It needs all the following functionality:
- Users can register and log in with OAuth
- Users can save and switch between multiple documents (each with a unique URL)
- Users can purchase a monthly subscription to access Pro features
I decided for this app to make it 1) a single page web application, for ease of prototyping and 2) serverless on the backend, so I can use infrastructure-as-code.
With these requirements, I set out pondering how it would all fit together!
Where I am now: I’ve met requirements 1 and 2 by building the app with a combination of ReactJS, Clerk, Firebase and Terraform. I’m still working on adding billing, (requirement 3) so that will be for a future post.
I ended up figuring out how to do all the above (#1 and #2 fully complete and working on #3) and I’ll go into .
This is a hacker’s journey, meaning the goal is to find an acceptable solution and ship as fast as possible. So let’s start
Part 1: Authentication
THis good place to start. I recently had a pretty ugly experience where I wanted to use BlitzJS (a fork of NextJS) with Supabase Auth—and realized I might be the first person in existence (link) trying to make this work. Still recovering from that, I wanted to really explore my options.
First off, Supabase Auth was actually great when I used it. It integrated easily with React on the frontend, offered all the auth providers, and from what I can tell also works well on the backend with traditional NextJS apps.
Also looked at Kinde!
But for this project, I was leaning away from using a relational database. A friend of mine suggested I could serialize the projects and throw them in . That’s true, but
Aside from Supabase Auth, what else do we have? Clerk and Firebase Auth are both fairly popular.
But what would be really nice would be a hosted solution that can handle both auth and payment screens for me, and store the data for me. I’m not doing anything out of the ordinary with auth or billing, so why not? It turns out a few things like this do exist—but nothing with enough users to
So how about Clerk vs Firebase Auth?
Part 2: Serverless document storage and retrieval
As mentioned above, I was strongly leaning towards a NoSQL solution, since I hold lots of
I was pretty keen to check out MongoDB Atlas. Already thinking ahead, I knew I might need a web hook to integrate with the payments provider, so I made sure I could do that with Atlas, and I could. But while setting up Clerk, I had noticed it integrates with Firebase. What kind of integration? After uploading Firebase account credentials to Clerk, Clerk generates . So Firebase knows who is an authenticated user and who isn’t, without me writing any backend code. I will take any way to save time, so I chose Firebase.
My experience so far with using cloud providers such as AWS and GCP is that you basically follow tutorials online to get your services set up (database, lambda functions, etc.) and then once they’re set up, you forget how you did it. Not anymore—I’m going to use Terraform to set up my Firebase project.
I started working on
Step 1 for me was to get documents working without any ownership, and step 2 was to gate them by the currently signed in user.