Getting Started
This entire setup should setup should be done only by one person on the team It should take anywhere between 1-3 hours to complete. If it is taking any longer, PLEASE contact a tech lead for help!
if you are not the member of your team responsible for setting up the starter template, scroll to the bottom
Keeping track of Account Logins
-
Create a Google Drive for the team if one doesn't exist. Make sure to invite everyone.
-
Create a Google Doc to keep track of the accounts you create.
-
Keep this tab open for the next two steps.
Creating your Google Account
- You need to create your own Google account (unless one was provided to you from your client) if they don't already have one.
- Complete your Google profile setup.
- Save the login information to the Google Docs.
Creating Your GitHub Account
- You need to create your own GitHub account (unless one was provided to you from your client) at https://github.com/signup if they don't already have one
- Complete your GitHub profile setup and verify your email address.
- Save the login information to the Google Docs.
Forking the Template Repositories
Next, you need too:
- Navigate to the template repositories:
- Click the "Fork" button in the top-right corner of each repository
- Select your personal GitHub account as the destination for the fork
Prerequisites
Before you begin, make sure you have:
- Node.js version 18.0 or higher
- Git for version control
- A code editor (we recommend VS Code)
- Google account
- Firebase account (Will be linked to your google account)
Installation
- Setup directories
cd # whereever you want your code to live in, make sure you can easily access this in the future
mkdir disc-template
- Clone the repositories:
git clone https://github.com/bbrockbrown/js-frontend.git
git clone https://github.com/bbrockbrown/js-backend.git
- Install dependencies for the frontend:
cd js-frontend
npm i
- Create the
.envfile for the frontend
touch .env
- Copy this template for the frontend
.env
# Server Configuration
VITE_BACKEND_URL=http://localhost:5050
# Firebase Configuration (from Firebase Console > Project Settings > Your apps)
VITE_FIREBASE_API_KEY=your_api_key
VITE_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
VITE_FIREBASE_PROJECT_ID=your-project-id
VITE_FIREBASE_STORAGE_BUCKET=your-project.firebasestorage.app
VITE_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
VITE_FIREBASE_APP_ID=your_app_id
VITE_FIREBASE_MEASUREMENT_ID=G-XXXXXXXXXX
Instructions for finding these keys will be in the following Firebase section.
- Change directories into the backend
cd ..
cd js-backend
- Install dependencies for the backend
npm i
- Create
.envfile for the backend
touch .env
- Copt this template for the backend
.env
# Firebase Configuration
FIREBASE_SERVICE_ACCOUNT_KEY='{"type":"service_account","project_id":"your-project-id",...}' # Your Firebase service account JSON
# Database Configuration
# Supabase: found in supabase.com → project → Project Settings → Database → Connection string (URI)
DATABASE_URL=postgresql://postgres:[password]@db.[project-ref].supabase.co:5432/postgres
# Server Configuration
PORT=5050
FRONTEND_URL=https://your-production-url.com
API_URL=http://localhost:5050
FRONTEND_URL_DEV=http://localhost:5173
NODE_ENV=development
Firebase Setup
1. Create a Project
- Go to Firebase Dashboard
- Make sure you are not on the Northwestern email, it will get stuck at "select parent resources". You must be on the designated email account for the project.
- Create a new project (No AI Features)
- Fill in project details
2. Configure Authentication
-
Go to Build -> Authentication settings on the left sidebar:
-
Click "Get Started"
-
Under "Native Providers", select "email/password"
-
Enable the first option "Email/Password" but NOT "Email Link". Click Save.
3. Google OAuth Setup
Thankfully, Firebase comes with OAuth integrated.
-
Inside the Authentication tab, under "Sign-in method", click on Add new provider.
-
Select Google. Click enable.
-
Fill in "public-facing name" with something. I recommend client-name-disc
-
Choose your own email for support email.
4. Configure Frontend ENV variables
Now, we need to fill in the frontend env with the proper variables.
- Look under Project Overview
- Create a new "app" if you haven't already
- Click "web" and fill in the project name. You do not need to set up Firebase Hosting yet.
- Once you click continue, you will be shown the following keys to fill in your .env.
- To find the measurement ID, you must go to Project Settings -> Integrations and enable Google Analytics.
5. Configure Backend ENV variables
The backend also needs a special key called the service account key.
- Navigate to Project Settings -> Service Accounts
- Under Firebase Admin SDK, generate a new private key.
- Confirm and download the JSON file. This is your private key, do not upload it anywhere public.
- Copy and paste the content of the JSON file into FIREBASE_SERVICE_ACCOUNT_KEY. Note that the whole value needs to be wrapped in a quote.
Supabase Setup
To start off, we will use Supabase + PostgresSQL for the database. We have set up the codebase to migrating over to AWS is easy, more on that later.
- Go to Supabase
- Sign Up with the dedicated email for the team through Google OAuth.
- Create a new organization (name it whatever you want, preferably your client's company)
- Go into that org you just created
- Click "New Project"
- Fill in the details. REMEMBER YOUR DATABASE PASSWORD. Keep Data API enabled.
- Once you create the project, click on "connect" near the top of the screen.
- Under "Connection String", change method to "Transaction Pooler" and copy text provided to you. This is your DATABASE_URL.
- Now, go back to your backend .env and paste that string into DATABASE_URL. Replace [YOUR-PASSWORD] with the password you created earlier (no square brackets).
Now, we need to create the users table.
- In Supabase, navigate to SQL Editor.
- Paste in the following code and run:
CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
firebase_uid VARCHAR(128) NOT NULL UNIQUE,
username VARCHAR(50) NOT NULL UNIQUE,
email VARCHAR(255) NOT NULL UNIQUE,
firstname VARCHAR(100) DEFAULT NULL,
lastname VARCHAR(100) DEFAULT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
Verify Setup
For both the frontend and backend directories just do the following:
you will probably need to open two terminals for this!
npm run dev
Backend server will start at http://localhost:5050
Frontend server will start at http://localhost:5173
- Your authentication should now be configured for both email and Google login
- Test both methods in development:
- Run your frontend locally (
npm run dev) - Try creating an account with email
- Try signing in with Google
- If either fails, double-check all URLs and credentials
- Run your frontend locally (
After you have gone through all of these steps, you should be able to create users, see them populate on Supabase, and have them displayed on your web app after logging in.
You should also get emails from Supabase whenever you first sign-up and requests a password. All of the respective pages on the frontend should work with this as well.
Once you have verified that everything works, share the .env credentials with the rest of your team!!!
Development Tools
Recommended VS Code Extensions
Available Scripts
npm run dev- Start development servernpm run test- Run tests (if you have any)npm run lint- Format all files with Prettier
Instructions for Everyone Else
If you are not the member of your team who did all of the steps from above:
- Clone the forked repos from the github account that setup all of the accounts and projects for you
- Get the respective
envvariables. - Verify that everything is running locally