Firebase Integration

Adding user Data to the Firebase Database

Firebase is a popular choice for Authentication and Data Storage. To get started with Firebase refer to the doc here Firebase Integration.

Databutton offers built-in storage within its workspace, supported by Databutton's own SDK. This storage is ideal for small-scale production apps and quick testing purposes. Read more here

To store data over Firestore Database:

  1. Set up the Firestore Client.

  2. Create API (backend) to handle the data storage

Read more about creating API in Databutton here.

Setting up the Firestore Client

  • Start with creating a new project and register the app using the "Web" option ( follow the instructions in details as mentioned earlier here Setting up the Firestore Client)

  • On the left-hand side tab, under the "Build" dropdown -> Select the "Firestore Database" option

  • Select the "Create database" option

Firestore Database Integration
The left hand side Build drop down menu shows the "Firestore Database" option.
  • In the "Select a location" step, choose the nearest Google Cloud region to your application's users, then click the "Next" button ( this step can't be reverted back once created )

  • Select "Production" or "Test" mode (based on the usage).

  • Generate Service Account Key ( follow the step below )

    • Go to the Firebase Console.

    • Click on the gear icon next to "Project Overview" and select "Project settings".

    • Navigate to the "Service accounts" tab.

    • Click "Generate new private key" and download the JSON file.

  • Copy the credentials from the downloaded JSON file.

Download credential json file by clicking the "Generate new private key" button.

Creating an API (Python backend) to handle the data storage

  • Ask Databutton on how to store the Service account key credetials

Example prompt ( while doing via the Databutton's Agent )

  • Alternatively, you can manually store the Service account key details ( recommended and quick )

    • Go to the config section in the menu ( Top menu bar in Databutton's workspace -> Select Config ⚙️ )

    • Hover down to the Secrets section and add it with a secret name and the value ( here value is basically the copied credentials which was downloaded)

  • Next, prompting the architecture of the firestore database. This step is cruical and varies based on the app in mind. Here's an example of a simpler use case :

Note, this step can be iterative, and it's very important to reciprocate the database architecture concisely. It is also recommended to test and iterate further!

  • Once, the architecture looks ideal, Databutton Agent takes care of the next steps for creating a functional API

Here's an example code snippet based on the database architecure discussed :

Last updated

Was this helpful?