Get Started - MyFriendBen/benefits-api GitHub Wiki
Get Started
The following are instructions on how to set up the development environment.
Backend
Clone
cdinto the directory that you want to have the project in- Run:
git clone https://github.com/Gary-Community-Ventures/benefits-api.git cdinto the cloned repo
Install Dependencies
- Run:
python -m venv venv - Activate the virtual environment. It differs by operating system, so instructions are: https://python.land/virtual-environments/virtualenv
- Run:
pip install -r requirements.txt- You may have to set up your database first (see steps below) in order for all of the dependencies to install successfully
Set Up Database
- Download PostgreSQL: https://www.postgresql.org/download/
- Download the GUI tool pgAdmin and create an account / log in
- Create a New Server (with Host 'localhost')
- Create a new user and password: https://www.guru99.com/postgresql-create-alter-add-user.html
- Create a database and give the user permissions.
Environment Variables
- Create a
.envfile - Add the following environment variables (see: "Backend ENV Vars" in our 1Password Engineering vault)
SECRET_KEY: A random string that is used for hashingDB_NAME: The name that you gave the databaseDB_USER: The name of the user that has access to the databaseDB_PASS: The password of the user that has access to the databaseDJANGO_DEBUG: Turns the backend into debug mode. Set toTruewhile developingGOOGLE_APPLICATION_CREDENTIALS: A Google service account with access to spreadsheets and translateALLOW_TRANSLATION_IMPORT: Set toTrue. This is to prevent you from importing translations into prod from another environmentFRONTEND_DOMAIN: The domain of the frontend that the API is serving (probably http://localhost:3000 while developing)POLICY_ENGINE_CLIENT_ID: The client ID for the Policy Engine APIPOLICY_ENGINE_CLIENT_SECRET: The Policy Engine API tokenSENDGRID[OPTIONAL]: A SendGrid API key if you want to send emailsEMAIL_FROM[OPTIONAL]: The email you want to send emails fromTWILIO_SID[OPTIONAL]: The Twilio SID if you want to send textsTWILIO_TOKEN[OPTIONAL]: The Twilio token if you want to send textsTWILIO_PHONE_NUMBER[OPTIONAL]: The Twilio phone number if you want to send textsHUBSPOT[OPTIONAL]: The HubSpot token if you want to send contacts to HubSpotBREVO_API_KEY[OPTIONAL]: The Brevo token if you want to send contacts to Brevo
Run Some Commands
- Run:
python manage.py migrate - Run:
python manage.py createsuperuserand create an admin account. - Run:
python manage.py runserver
Some Admin Stuff
- Go to http://localhost:8000/admin/authtoken/tokenproxy/
- Click the
+in the top right - Select the user that you just created
- Copy the API key for later use as the
REACT_APP_API_KEYin the Frontend benefits-calculate .env file - Go to http://localhost:8000/admin/screener/whitelabel/
- Click on the
+ - Add a white label with the name
Defaultand the code_default
More Commands
- Go to https://github.com/Gary-Community-Ventures/mfb-translations/tree/main/translations
- Download the most recent json file, or clone the repo
- Run:
python manage.py bulk_import < path/to/the/file/that/you/just/downloaded.json - If the above command throws an error than run it again. IDK why, but it worked for me the second time
- Run:
python manage.py add_config --all - Run:
python manage.py runserveragain if you stopped the server
Frontend
See benefits-calculator README