Installation
Installation guide for your application.
To get your project ready to go we'll need to set up a few accounts so let's take a
look at what we have on the .env
file.
# Firebase Service account keys
TYPE="service_account"
PROJECT_ID=
PRIVATE_KEY_ID=
PRIVATE_KEY=
CLIENT_EMAIL=
CLIENT_ID=
AUTH_URI=
TOKEN_URI=
AUTH_PROVIDER_X509_CERT_URL=
CLIENT_X509_CERT_URL=
UNIVERSE_DOMAIN=
# Firebase Auth and Storage keys
API_KEY=
AUTH_DOMAIN=
STORAGE_BUCKET=
MESSAGING_SENDER_ID=
APP_ID=
MEASUREMENT_ID=
# Google keys
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT_URL=
GOOGLE_API_KEY=
TIMEZONE=
GOOGLE_APP_PASSWORD=
GOOGLE_EMAIL=
# Frontend URL
FE_URL=
#OpenAI key and model
GPT_MODEL=
OPENAI_KEY=
Now let's go step by step.
Installation Steps
Firebase Service account keys
TYPE=
PROJECT_ID=
PRIVATE_KEY_ID=
PRIVATE_KEY=
CLIENT_EMAIL=
CLIENT_ID=
AUTH_URI=
TOKEN_URI=
AUTH_PROVIDER_X509_CERT_URL=
CLIENT_X509_CERT_URL=
UNIVERSE_DOMAIN=
To get those values is very simple! You need to head over to Firebase Console and create a new project.
Then on Project Overview
open Project settings
and select the Service accounts
tab.
Click on Generate New Private Key
, this will download a JSON
file that contains all those keys you need here.
Save this file in safe place and paste all those in the repective match in the .env
file.
And here we're done for the service account part!
Firebase Auth and Storage keys
API_KEY=
AUTH_DOMAIN=
STORAGE_BUCKET=
MESSAGING_SENDER_ID=
APP_ID=
MEASUREMENT_ID=
Still inside Project settings
in the Firebase Console
select the General
tab, it's the first one.
You should have a panel called Your apps
if you haven't that yet now it's the time for you to create a web app.
So hit the Add app
button and create a web app at the end of the creation process now in the same panel you should
have the instructions that will contain a snippet with a constant called firebaseConfig
, here we have all the keys
you need here, just paste them in the respective matches on the .env
file in the last step.
Note:
In the previus step we already copied the PROJECT_ID
so you don't to copy it again.
Lastly, enable the Authentication
feature on Firebase. On the left under build
menu select Authentication
then hit the button Get Started
.
On Sign-in method
tab select Email/Password
as native provider and toggle to enable it. Done!
Google keys
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT_URL=
GOOGLE_API_KEY=
TIMEZONE=
GOOGLE_APP_PASSWORD=
GOOGLE_EMAIL=
Time to set up Google keys, this one is not that straighforward like the last ones but it's also very simple.
For the first 2 GOOGLE_CLIENT_ID
and GOOGLE_CLIENT_SECRET
you'll need to head over to credentials tab on
Google Cloud Console under APIs & Services
.
Select your project(the same one you already created on firebase console). Here you should already see the Firebase related keys under
API Keys
and Service Accounts
but now you'll need to create the keys under OAuth 2.0 Client IDs
.
Hit the button + CREATE CREDENTIALS
-> OAuth client ID
.
The application type should be Web Application
, input an name and go down to Authorized redirect URIs
, for now use http://localhost:8383/google/redirect
.
Then hit CREATE
button. Now you should see Client ID and Client Secret created for you that will fill the GOOGLE_CLIENT_ID
and GOOGLE_CLIENT_SECRET
respectively.
Now on Credentials
you should have all three sections filled: API Keys
(Created by Firebase), OAuth 2.0 Client IDs
and Service Accounts
(Created by Firebase).
Remember that you don't need to enable billing at this point yet.
Note:
You don't need to publish the app yet.
But fist you'll need to set up the the OAuth consent screen
, it's another tab on the left after setting up everything you should
have those 2 keys.
GOOGLE_REDIRECT_URL
key will have this same value: http://localhost:8383/google/redirect
GOOGLE_API_KEY
will receive the same value you API_KEY
you set before,
we decided separate them because they're used in different contexts.
TIMEZONE
is the value of the timezone you want your app to run (e.g. "America/Los_Angeles", "Europe/Rome").
For GOOGLE_APP_PASSWORD
you'll need to sign in into Google Account
and create an app password, this will allow the application to handle your calendar through Google Calendar API.
Note:
It's important to note that it is required to have 2-Step Verification
in order to create an App Password
. So make
sure you have it set up first. Once created remember to remove the spaces between the characters.
And finally GOOGLE_EMAIL
is the email you used to create the App Password
and is the one that will be used to
send communications to the uers.
Frontend URL
FE_URL=
This one is easy, for now set it as "http://localhost:3000"
which the address our frontend is gonna run,
later on you can update it when you go to production.
OpenAI key and model
GPT_MODEL=
OPENAI_KEY=
GPT_MODEL
is the model is gonna be used to call the OpenAI API, we recommend you to use gpt-4o
,
just keep in mind that better trained is the model, better will be the results!
In order to get the OPENAI_KEY
you'll need to an OpenAI account created, so head over to their website on
API Login. If it's the first time you're doing it you'll probably
get a few dollars in credit to try it, nice han?
On the dashboard go to the API keys section and create a new secret key. That is the key you're paste here, remember to save it somewhere safe.
Set up Firestore Database
Now let's create the Firestore databse on Firebase.
First, go back to Enable APIs & Services
tab on Google Cloud Console under APIs & Services
.
Click on + ENABLE APIS AND SERVICES
button, search for firestore api
and select the option Google Cloud Firestore API
and hit the button ENABLE
.
Then you should have something like this:
Back on Firebase Console
on the left side find the option Build
-> Firestore Database
and click on Create Databse
.
On the first step you can leave the default options, but on the second one, Secure rules
, please select the second option Start in test mode
.
Click on Create
. It's done, you don't need to botter creatinf tables, the backend will do it for you!
Note:
If you are having any issues connecting to your database please use the folling access rules, but please remember to change them once you decide to go to production environment. Because your database is more vunerable this way, but it's for testing.
All done!
Now that it's all set! We're ready to get it up and running!