For developing, we suggest running the Flask app locally. Assuming that you are on a UNIX-like OS, the following commands should get you up and running:
cd webapp/
# Install Python dependencies
pipenv install
# Install client-side dependencies
cd client/ && yarn install && yarn prepare && npm install && cd ..
# Ensure required environment variables are set
cp .flaskenv.example .flaskenv
# Initialize local database
pipenv run flask db upgrade
pipenv run flask populate-database
# Generate translation files
./scripts/babel_run.sh
To develop the app, you need to run two process: 1) the Flask app and 2) a dev server for client-side components.
cd webapp/
pipenv run flask run
cd webapp/client/
yarn start
You can now interact with the website on http://localhost:3000.
See here for more detailed information about developing client-side components.
After every translation change (new strings, updated .po file) and also during first-time setup, run:
cd webapp/
./scripts/babel_run.sh
A large amount of functionality in the app also requires a local erica service to be running.
If you do not want to run erica at the same time, you can set USE_MOCK_API = True
in the DevelopmentConfig
in the webapp's config.py
.
You can run tests as follows:
cd webapp/
pipenv run invoke test
For database migration and upgrades, we use Flask-Migrate. Make sure that you are in the pipenv shell and then do:
cd webapp/
# After model has been changed
flask db migrate # Creates a new migration script in migrate/versions
flask db upgrade # Updates the database using the migration script