Skip to content
Luke Repasky edited this page Jun 30, 2023 · 12 revisions

Setup Guide

Assuming access to the CAASI notion, use this setup for a more in depth guide. This covers the same content, but has an image walkthrough to assist in the process.

To setup this application you need to have the following preinstalled on your system:

(optional, but recommended) Setup a virtual environment for the Python libraries:

pip3 install virtualenv
virtualenv venv

Then activate the virtual environment:
Windows
./venv/Scripts/Activate
Mac/Linux
source venv/bin/activate

Then navigate to the root directory of the project source code (ex: /g2a-website/PPUC) and install the necessary Python libraries:

pip3 install -r requirements.txt (or pip install -r requirements.txt for Windows)

Next run the application setup code:

python3 manage.py runscript -v3 setup_app

Then change to the frontend code directory (ex: /g2a-website/PPUC/frontend) and install the necessary NodeJS modules (If you run into "npm ERR! code 1" at this step, try downloading an earlier version of node JS):

npm install

Then build the React application assets with:

npm run build

NOTE: If you're modifying the React application you can use npm run watch to have the application be built after you make a change to a file instead of building manually each time

You can now change back to the main source code directory and start the backend/Django REST API with:

python3 manage.py runserver

Now navigate your browser to:

http://127.0.0.1:8000/PxPUC

Making Changes

After you're done making any necessary changes when you commit (ie: after running git commit -m "my message..." Husky will be started and run the following process (assuming you installed all necessary dependencies in the frontend directory above with npm install):

  1. Code formatting on frontend/backend code with Prettier/Black respectively
  2. Run test cases for frontend/backend code with Jest/Django respectively
  3. Generate production frontend assets (JS+CSS) in frontend/dist (this is done to limit amount of necessary space on the production account)
  4. Finalizes commit process and adds any files generated from the above process

Common Issues

  • If you are running into errors frequently throughout the setup process, double and triple check your versions for everything (Django, NPM/node.js, Python, React). For a reference as to what the versions should be, look at PPUC/requirements.txt, PPUC/frontend/package.json, and PPUC/frontend/package-lock.json.
  • Version issues are the main problem in all setup troubles and will cover the majority of cases. The trickier one tends to be getting Node.js. The version of NPM used is v14.21.2 as of June 2023, the version of Python is Python 3.8.2, the version of Django is 3.1.3 (though this has been updated on the main branch), and the version of React is 17.0.2. This may vary across branches but will at least give a baseline of where to start looking.
  • If you run into this issue after doing npm run build: "webpack is not recognized as an internal or external command" do the following: npm install -g webpack
  • Other issues may appear or be added to the Github issue tracker, but ultimately, even if after Googling an error message that points to something else, the issue tends to be versions.
Clone this wiki locally