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/.
Recruitment platform for Monash University student teams
- Onboarder
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.
You need to create these three files in your project to be able to develop. Do not add these files to Git.
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
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.
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:
{
"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": ""
}
}
{
// 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": ""
}
}
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 asEMAIL_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.
SUPABASE_URL
: Your Supabase project URL.SUPABASE_KEY
: Your Supabase project API key.
These can be found in your Supabase project settings.
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.
The WEBSITE_URL
is used in controller.py
For development, it is the local URL given by VITE when you run npm run dev
These come from the set up of google calendar API
This is used for deployment. Having it blank means that the codebase will use a different implenentation with python for testing.
-
Install NodeJS (v20.6.1 if the latest version doesn't work).
-
Ensure the second
.env
file is in frontend folder -
Open a terminal in the front-end folder:
cd frontend
-
Install dependencies:
npm install
-
If any packages have security issues, run:
npm audit fix
(Note: Use discretion as this might introduce breaking changes)
-
Start the development server:
npm run dev
-
Install Docker, AWS CLI, AWS SAM CLI, and Python 3.12.
-
Add the
env.json
file to the root folder (see configuration details below). -
Keep Docker running in the background.
-
Open a terminal in the root folder and execute:
sam build
-
After completion, run:
sam local start-api --warm-containers EAGER --env-vars env.json
-
Add the
.env
file to the root folder (see configuration details below). -
Install Supabase CLI
-
Keep Docker running in the background.
-
Ensure Docker is configured for your OS according to the screenshot in this page: Supabase Docs: Supabase CLI
-
Open a terminal in the root folder and execute:
python pre-process-seed.py
you might have to use
python3
instead ofpython
then
supabase start
ornpx supabase start
NOTE: If you need to add npx for this to work, you will need to use
npx
before allsupabase
commands you do This may take a while the first time. -
After completion, run:
supabase db reset
This will populate your local instance of Supabase with testing data
-
You can access the supabase dashboard for your local setup by pasting this into your browser:
If you would like to try run the algorithm, you will need a python virtual environment.
-
Navigate to backend/lambda
-
Create a virtual environment by running:
python -m venv venv
You may need to use
python3
instead ofpython
-
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)
-
Then install the requirements:
pip install -r requirements.txt
- Navigate to
http://127.0.0.1:5173/
in your browser. (NOT localhost:5173) - Sign in with your Monash account.
- You are now good to start developing.
Source: Supabase Docs: Local Development
- Only do steps 1 and 2 if your team does not have a Supabase project yet.
- Sign up for a Supabase account.
- Create a new project.
- We will upload migrations to this project from local supabase instances (later steps)
-
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
- 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
- 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 runseed.sql
- To upload the local migrations to prod Supabase, first:
-
Login to your Supabase account with:
supabase login
-
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>
-
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.
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
- 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.
TODO
- 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.
- Follow above steps, ensuring both .env files and the env.json file are correct and in the right place
- Ensure that default Docker Socket is enabled.
- Sometimes you may need to disable this in Docker Advanced Settings, restart and the enable it again.
- 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
- Main branch: Stable, deployment-ready code
- Development branches: Isolated for active development
- 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
- 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)
- 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
- 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!