DEV Community

Alejandro
Alejandro

Posted on

How to use Firebase?

I have been reading about Firebase and watching a few "getting started" videos but I still don't get it.

On the videos I see I frequently find things like "how to connect firebase with [Vue|Angular|React]" but then I get with the doubt does firebase is just the database layer or is also the backend layer?

For example:

I have an ecommerce site and the user want's to purchase a product. On Vue I'll do all the frontend stuff.
On Net Core I'll do all the backend stuff like checking that the product is in the inventory.

If I add Firebase then the architecture will become something like this?

  1. Vue connects to Firebase to retrieve the products.
  2. Vue connects to Net Core which connects to Firebase to know the inventory if the inventory is not available then Net Core responds to Vue that the purchase can not be done.

In that case:

A. What is the point on connecting to Vue -> Firebase?
B. If you are connecting Vue -> Net Core -> Firebase? What exactly are you benefiting from using Firebase? I read that having a real time app is one of the selling points of firebase but I think that this will be lost by connecting to Net Core
C. Or is it suppose to be some hybrid architecture maybe having Vue -> Firebase (notifications database) and then having Vue -> Net Core -> Firebase (products database)?

Thanks for your help.

Top comments (2)

Collapse
 
jaakidup profile image
Jaaki • Edited

Yes, one of the selling points of Firebase is the realtime database, think of a chat server here. But there are many other uses for it.

Also storing data in firebase is obviously Nosql and you don't have to define anything on the server side to store data. This makes it a nice tool to test an app idea because you don't have to write server side code to CRUD data.

If your inventory is also stored in Firebase, then you could also use Firebase Cloud Functions to check if the item is in stock.
Cloud functions run on the firebase server side and the code is thus hidden from the client.

With the right design, you could just use vue to check whether the item is in stock in firebase and because it is realtime, the product should disappear out of available stock.

Hope this helps a little and happy coding!

Collapse
 
levivm profile image
Levi Velázquez

I created a tutorial for implementing a rest api using firebase. So, after having the API you can use it by any JS framework. Here you can check it out

But, Firebase has a lot of services, it has Push Notifications(Google Cloud Messaging), Analytics, Authentication, Serverless infrastructure, etc.