uwbaddev / baddie-match

Web app to track our badminton matches
2 stars 2 forks source link

๐Ÿธ baddie-match

๐Ÿ’ป Website | โœ๏ธ Design | ๐Ÿ“ Brainstorm Doc

Score and stats tracker for the Waterloo Warriors badminton team.

Developing

Docker

Setting Up the Dev Env

  1. Make a Copy of .env.sample, name it .env and move it the root dir.

  2. From the root dir, run ./devops/init.sh

  3. When the script finishes, verify that it has been setup properly by visiting localhost:8000.

Info:

Other scripts:

Troubleshooting and Common errors:

Q: I get a db error at the end of the init.sh script A: Go the terminal of the app container, and run python3 app/scripts/createTables.py, and python3 -m app.scripts.add_prod_data

If all else fails, run ./devops/nuke.sh from the root, and re-run init.sh.

OLD

Frontend

The frontend is built using React.js. You will need npm to get started. After downloading, you can get the frontend server working locally by running:

cd front-end
npm install
npm start

Note: The frontend queries the production backend APIs and data. To change this, you must edit the DomainName in API.js to point to your local server (usually https://localhost:5000)

Backend

1. PostgreSQL

Our application uses PostgreSQL to store the backend data. Setting up the database can be done as follows:

Mac

brew install postgresql
pg_ctl -D /usr/local/var/postgres/ start
createdb <name>
psql <name>

Windows

Download postgresql from https://www.postgresql.org/
Run installation, with all defaults
Open psql command line, from start menu
CREATE DATABASE <name>;

2. Setting up the environment variables

To ensure that the applicattion reads from the database correctly, you will need to set up environment variables. Make a copy of .env.sample and rename it to .env in the root directory. Set the database to the you just created. Then run scripts/createTables.py to create the required tables. For now, you will need to populate the data manually.

3. Running the backend server

The backend is created using Flask. You will need Python3 to get started. Afterwards, the application can be run as follows:

Mac

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
FLASK_APP=app.main flask run

Windows

python3 -m venv venv
venv\scripts\activate
venv\scripts\pip.exe install -r requirements.txt
setx FLASK_APP "app.main"
flask run

4. Using docker

Several scripts were created to help set up the local environment using Docker