- Clone this repo and the frontend repo (cdc-frontend)
- Grab the secrets
- Follow steps below in Python setup section if you haven't done so before
- Follow steps below in Running the backend repo section
The Distress Centre Calgary (DCC) is an organization dedicated towards providing crisis support for Calgary and southern Alberta residents. DCC provides various programs to reach all population segments who are in need of help, including a 24 hour crisis line and counselling. The organization has also provided several services for teenagers given the increasing prevalence of mental health issues among this population demographic.
FYDP: Jay Dhulia, Dhruvin Balar, Amolik Singh, Ahmed Hamodi
Project Lead: Ahmed Hamodi
Product Manager: Aaron Abraham
Designers: Jack Zhang, Kouthar Waled
Developers: Jay Dhulia, Dhruvin Balar, Amolik Singh, Vivian Liu, Kevin Hu
See cdc-frontend for frontend setup.
- Ensure that you have Python 3.9.1 on your system by running
python3 --version
. If you don't, please upgrade your Python. - If you don't have an environment setup already within the repo:
python3 -m venv env
- Note: you will only need to do the above command once.
- Activate the virtual environment.
- On a mac operating system, use:
. ./env/bin/activate
- On a windows operating system, use:
source ./env/Scripts/activate
- On a mac operating system, use:
- Install
Postgres
- Version 12. Choose user "Postgres" with blank password for local development.- On Mac, the recommended tool for managing your Postgres installation is Postgres App
- On Windows, download Postgres from here and then use the script in
scripts/PSQL Server Management.bat
to start/stop your Postgres Server
- Once Postgres is installed, create a database with the name:
postgres_cdc_dev
- Install the requirements, and setup Postgres:
make install
Note: Every time you run git commit
in this repo, it will run some lint checks. It won't let you commit unless the lint checks pass. Note that this means you may have to run git commit
multiple times, as each git commit
will attempt to fix the files! Some files may fail to auto-fix, in which case, you will have to ensure you fix them.
Once you have the requirements installed, you should be able to develop by just activating the environment (step 2).
- Update the file
requirements.in
with the name of the library that you want to add. - Install pip-compile if you don't have it already -
pip install pip-tools
. - Run
pip-compile requirements.in
- Download the updated packages
pip install -r requirements.txt
- Check locally to ensure that you haven't broken anything
- The run configurations should automatically be loaded and working, select the
dev
environment and hit the play button. Contact Jay if you have trouble setting this up.
- Ensure you are in the root directory, and your virtual env is activated. Also make sure your Postgres is running.
- Run
export PYTHONPATH=.
- Run
export CONFIG_PATH=configs/dev-config.yaml
if running locally, orexport CONFIG_PATH=configs/dev-aws-config.yaml
if running with AWS (S3) backend. - If you have not done so recently, run
make install
as it will update any schema changes. - Run
python app/__main__.py
- You should see a
SERVER STARTED
message along with configuration details
Note, if you get a "port 5432 in use" error on the postgres app, do the following:
- Find the pid of the process using that port:
sudo lsof -n -i :5432
- Kill the process by using the PID from above result:
sudo kill -9 <PID>
If that does not work, you can run sudo pkill -u postgres
to clear the port and then restart postgres.
- Ensure you are in the root directory, and your virtual env is activated. Also make sure your Postgres is running.
- Run
set PYTHONPATH=.
. Note: if you are using bash on Windows you will have to useexport
instead ofset
- Run
set CONFIG_PATH=configs/dev-config.yaml
, if running locally, orset CONFIG_PATH=configs/dev-aws-config.yaml
if running with AWS (S3) backend. Note: if you are using bash on Windows you will have to useexport
instead ofset
- If you have not done so recently, run the scripts to create and populate the database:
python scripts/create-tables.py python scripts/insert_data.py
- Run
python app/__main__.py
- You should see a
SERVER STARTED
message along with configuration details
To call any APIs that require authentication without the frontend running (ex. using curl or Postman), you'll need an access token. You can generate a token for your account this with the command:
todo
This script will output a JSON object – you can use the idToken
value and provide it as a bearer token to your API calls. This token expires every hour, and you can rerun this script to generate a new one.
- Open https://jscompress.com/
- Go to the
Upload Javascript Files
tab - Upload all the files under
app/public/static/js/components/
- Upload
app/public/static/js/libraries/TransformControls.js
- Check the box in the top right corner for
ECMAScript 2021 (via babel-minify)
- Hit
Compress
- Download the file as
component.min.js
and place it inapp/public/static/js/
- Update the repo https://github.com/jaydhulia/blueprint-cdc-static
todo