Skip to content

Recruitment platform for Monash University student teams

License

Notifications You must be signed in to change notification settings

Monash-FIT3170/Onboarder

Repository files navigation

Onboarder - Student Team Recruitment Platform

Copyright (C) 2024 Team Sinked (FIT3170 Project 2, 2024)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Onboarder

All Contributors

Recruitment platform for Monash University student teams

Table of Contents

Team Members/Contributors

AbBaSaMo
AbBaSaMo

📆
Daniel
Daniel

đź’» đź“–
Fahad Assadi
Fahad Assadi

đź’» đź“–
Jesse Cruickshank
Jesse Cruickshank

đź’» đź“–
Jesse Cruickshank
Jesse Cruickshank

đź’» đź“–
Khang0018
Khang0018

đź’» đź“–
NgocDuy1234
NgocDuy1234

đź’» đź“–
Rahul-Saxena-1
Rahul-Saxena-1

đź’» đź“–
Rahuls525
Rahuls525

đź’» đź“–
Sai Ashish Ramishetty
Sai Ashish Ramishetty

đź’» đź“–
Saxena-Rahul
Saxena-Rahul

đź’» đź“–
Shubh Bajpai
Shubh Bajpai

đź’» đź“–
Tavishi11
Tavishi11

đź’» đź“–
TavishiSaxena
TavishiSaxena

đź’» đź“–
Umair Bin Mohammad
Umair Bin Mohammad

đź’» đź“–
ahmadhafiz17
ahmadhafiz17

đź’» đź“–
allcontributors[bot]
allcontributors[bot]

đź’» đź“–
arazzell
arazzell

đź’» đź“–
brendonPerera
brendonPerera

đź’» đź“–
hanifzafari
hanifzafari

đź’» đź“–
ranithsim
ranithsim

đź’» đź“–
sai-ramishetty
sai-ramishetty

đź’» đź“–
Add your contributions

Prerequisites

To run this project, you'll need the following software and hardware:

  • Docker
  • AWS CLI
  • AWS SAM CLI
  • Python 3.12
  • NodeJS (v20.6.1 recommended if the latest version doesn't work)
  • .env files and env.json file (details below)
  • Supabase account (If you plan on working with Prod)

We use Supabase for the database and the Supabase JavaScript SDK for frontend authentication and sign-in with Google. For development, team members work on local Supabase instances.

Configuration Files

You need to create these three files in your project to be able to develop. Do not add these files to Git.

.env (Front-end)

Create .env file in /frontend

VITE_SUPABASE_URL=http://127.0.0.1:54321
VITE_SUPABASE_KEY=YeyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0

These are the default keys for local Supabase

.env (Root)

Create .env file in root folder

SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID=<your projects client id>
SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET=<your projects secret>
DEV_EMAIL=<your monash email>

Replace <your monash email> with your student email.

If this has been done, ask your team for these keys, otherwise complete "Google Sign-In Setup" later in this document.

env.json (Root)

The env.json file in the root folder contains crucial configuration settings for the back-end, including email settings, database connections, and encryption keys. Here's a breakdown of its structure and how to set it up:

Sinked FIT3170 Template

{
  "RouterLambda": {
    "EMAIL_SENDER": "[email protected]",
    "SMTP_HOST": "smtp.gmail.com",
    "SMTP_PORT": 465,
    "SMTP_USERNAME": "[email protected]",
    "SMTP_PASSWORD": "YOUR_SMTP_PASSWORD",
    "SUPABASE_URL": "http://host.docker.internal:54321",
    "SUPABASE_KEY": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0",
    "ENCRYPTION_KEY": "YOUR_ENCRYPTION_KEY", // Add your encryption key
    "WEBSITE_URL": "http://127.0.0.1:5173",
    "GOOGLE_CALENDAR_TOKEN": "",
    "GOOGLE_CALENDAR_REFRESH_TOKEN": "",
    "GOOGLE_CALENDAR_TOKEN_URI": "",
    "GOOGLE_CALENDAR_CLIENT_ID": "",
    "GOOGLE_CALENDAR_CLIENT_SECRET": "",
    "GOOGLE_CALENDAR_EXPIRY": "",
    "INTERVIEW_SCHEDULER_QUEUE_URL": ""
  }
}

Here is a more general version of the template

{
  // For future developers
  "RouterLambda": {
    "EMAIL_SENDER": "[email protected]",
    "SMTP_HOST": "smtp.gmail.com",
    "SMTP_PORT": 465,
    "SMTP_USERNAME": "[email protected]",
    "SMTP_PASSWORD": "YOUR_SMTP_PASSWORD",
    "SUPABASE_URL": "YOUR_SUPABASE_URL",
    "SUPABASE_KEY": "YOUR_SUPABASE_KEY",
    "ENCRYPTION_KEY": "YOUR_ENCRYPTION_KEY",
    "WEBSITE_URL": "YOUR_WEBSITE_URL",
    "GOOGLE_CALENDAR_TOKEN": "",
    "GOOGLE_CALENDAR_REFRESH_TOKEN": "",
    "GOOGLE_CALENDAR_TOKEN_URI": "",
    "GOOGLE_CALENDAR_CLIENT_ID": "",
    "GOOGLE_CALENDAR_CLIENT_SECRET": "",
    "GOOGLE_CALENDAR_EXPIRY": "",
    "INTERVIEW_SCHEDULER_QUEUE_URL": ""
  }
}

env.json Email Configuration

  • EMAIL_SENDER: The email address used to send notifications.
  • SMTP_HOST, SMTP_PORT: SMTP server settings (example shows Gmail's settings).
  • SMTP_USERNAME: Usually the same as EMAIL_SENDER.
  • SMTP_PASSWORD: For Gmail, use an App Password. This video guide explains how to generate one.

Note: While we use Gmail as an example, you can configure any SMTP provider by updating these values accordingly.

env.json Supabase Configuration

  • SUPABASE_URL: Your Supabase project URL.
  • SUPABASE_KEY: Your Supabase project API key.

These can be found in your Supabase project settings.

env.json Encryption Key

The ENCRYPTION_KEY is used to encrypt sensitive data, such as application IDs in emails. Generate it once using the Fernet library in Python:

from cryptography.fernet import Fernet

# Generate a key (do this only once and store it securely)
key = Fernet.generate_key()
print(key.decode())  # This prints the key as a string

Run this script once, save the output, and use it as your ENCRYPTION_KEY in the env.json file.

Important: Keep your env.json file and especially the ENCRYPTION_KEY secure. Never commit them to version control or share them publicly.

env.json Website URL

The WEBSITE_URL is used in controller.py For development, it is the local URL given by VITE when you run npm run dev

Google Calendar variables

These come from the set up of google calendar API

Scheduler Queue URL

This is used for deployment. Having it blank means that the codebase will use a different implenentation with python for testing.

Setup Instructions

Front-end Setup

  1. Install NodeJS (v20.6.1 if the latest version doesn't work).

  2. Ensure the second .env file is in frontend folder

  3. Open a terminal in the front-end folder:

    cd frontend
  4. Install dependencies:

    npm install
  5. If any packages have security issues, run:

    npm audit fix

    (Note: Use discretion as this might introduce breaking changes)

  6. Start the development server:

    npm run dev

Back-end Setup

Sam

  1. Install Docker, AWS CLI, AWS SAM CLI, and Python 3.12.

  2. Add the env.json file to the root folder (see configuration details below).

  3. Keep Docker running in the background.

  4. Open a terminal in the root folder and execute:

    sam build
  5. After completion, run:

    sam local start-api --warm-containers EAGER --env-vars env.json

Supabase Local Development

  1. Add the .env file to the root folder (see configuration details below).

  2. Install Supabase CLI

  3. Keep Docker running in the background.

  4. Ensure Docker is configured for your OS according to the screenshot in this page: Supabase Docs: Supabase CLI

  5. Open a terminal in the root folder and execute:

    python pre-process-seed.py

    you might have to use python3 instead of python

    then

    supabase start or npx supabase start

    NOTE: If you need to add npx for this to work, you will need to use npx before all supabase commands you do This may take a while the first time.

  6. After completion, run:

    supabase db reset

    This will populate your local instance of Supabase with testing data

  7. You can access the supabase dashboard for your local setup by pasting this into your browser:

    http://127.0.0.1:54323

Optional: Setting up local testing

If you would like to try run the algorithm, you will need a python virtual environment.

  1. Navigate to backend/lambda

  2. Create a virtual environment by running:

    python -m venv venv

    You may need to use python3 instead of python

  3. Then activate it:

    source venv/bin/activate
    # On Windows, use `venv\Scripts\activate`
    # If these don't work, refer to (https://docs.python.org/3/library/venv.html)
  4. Then install the requirements:

    pip install -r requirements.txt

Opening Website in Browser

  1. Navigate to http://127.0.0.1:5173/ in your browser. (NOT localhost:5173)
  2. Sign in with your Monash account.
  3. You are now good to start developing.

Editing the Database

Source: Supabase Docs: Local Development

Project Setup

  1. Only do steps 1 and 2 if your team does not have a Supabase project yet.
  2. Sign up for a Supabase account.
  3. Create a new project.
  4. We will upload migrations to this project from local supabase instances (later steps)

Adding to the Local Database

  • To make changes to the local database, create a new migration and add necessary sql to update or add to the schema. Do not edit existing migrations.

  • Generate a migration:

    supabase migration new migration_name
  • You can find this migration in /supabase/migrations

Dummy Data

  • You can edit the SQL for creating dummy data in /supabase/seed.sql
  • If this is empty, it will be filled after running python pre-process-seed.py

Initialising Tables and Data

  • Whenever you run supabase db reset it will clear your local database (including auth) and then run your migrations (in the order they were created) and finally run seed.sql

Adding to the Prod Database

  • To upload the local migrations to prod Supabase, first:
  1. Login to your Supabase account with:

    supabase login
  2. Associate your project with your remote project

    supabase link --project-ref <project-id>

    You can get <project-id> from your project's dashboard URL: https://supabase.com/dashboard/project/ <project-id>

  3. To deploy migrations to prod, run:

    supabase db push

    If you want to add seed.sql data to db, run:

    supabase db push linked

NOTE: This will overwrite your prod data.

Google Sign-In Setup

To enable sign-in with Google follow the steps outlined in this Youtube Video In addition to this, in the Authorised JavaScript origins section for your OAuth Client setup you will need to add:

http://localhost:5173
http://127.0.0.1:5173
http://localhost:3000
http://127.0.0.1:3000

To the Authorised Redirect URIs section you will need to add:

YOUR_SUPABASE_URL/auth/v1/callback
http://127.0.0.1:54321/auth/v1/callback
http://localhost:54321/auth/v1/callback

Additional Notes

  • Ensure all configuration files (.env and env.json) are properly set up before running the project.
  • If you encounter issues with the latest NodeJS version, try using v20.6.1.
  • For any SMTP provider other than Gmail, update the SMTP settings in env.json accordingly.

Prod Deployment Instructions

TODO

Common Issues

CORS Error

  • This may sometimes occur when trying to make API requests to backend
  • To resolve this, ensure you have followed the correct steps above regarding configuration files.
  • If this does not work, make sure to have an HTTP Options method alongside every POST request method in the code.

Front End Crash (Blank Screen)

  • Follow above steps, ensuring both .env files and the env.json file are correct and in the right place

SAM cannot find Docker

  • Ensure that default Docker Socket is enabled.
  • Sometimes you may need to disable this in Docker Advanced Settings, restart and the enable it again.

NPM Dependency error (node modules not found)

  • You might get this error: The file does not exist at "Your_Directory/Onboarder/frontend/node_modules/.vite/deps/some_dependency" which is in the optimize deps directory. The dependency might be incompatible with the dep optimizer. Try adding it to 'optimizeDeps.exclude'.

Fix: Delete node_module/.vite and then rerun npm install and npm run dev

Git Management

Git Strategy Illustrated

Repository Structure

  • Main branch: Stable, deployment-ready code
  • Development branches: Isolated for active development

Commit Guidelines

  • Refer to: Conventional Commits
  • Frequent commits to prevent data loss
  • Clear, concise commit messages with descriptive keywords
  • Important commits tagged and tied to milestones
  • Semantic versioning system for version tags

Branch Management

  • Locked main branch to enforce code standards
  • Branch naming conventions:
    • Feature branches: 'feature/[description]'
    • Fix branches: 'fix/[description]'
    • Test branches: 'test/[description]'
  • Maximum two levels of branching from main
  • Temporary branches allowed for experimentation (to be cleaned up)

Merge Requests

  • Required for merging into main branch
  • Approval needed from at least two team members (one from each other agile team)
  • CI/CD pipeline runs automated tests post-approval
  • Merge only possible after passing all pipeline checks

Database Updates (Migrations)

  • Process for Approving and Pushing Migrations
  • Ideally there would be a GitHub Action that runs migrations when a PR is merged.
  • At the moment, it is done at the discretion of the team.

This project follows the all-contributors specification. Contributions of any kind welcome!

About

Recruitment platform for Monash University student teams

Resources

License

Stars

Watchers

Forks

Packages

No packages published