Get Started - Gary-Community-Ventures/benefits-api GitHub Wiki
Get Started
The following are instructions on how to set up the development environment.
Backend
Clone
cd
into the directory that you want to have the project in- Run:
git clone https://github.com/Gary-Community-Ventures/benefits-api.git
cd
into 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
Set Up Database
- Download PostgreSQL: https://www.postgresql.org/download/
- Login to pgadmin
- 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
.env
file - Add the following environment variables:
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 toTrue
while 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 createsuperuser
and 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
- Go to http://localhost:8000/admin/screener/whitelabel/
- Click on the
+
- Add a white label with the name
Default
and 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 runserver
again if you stopped the server
Frontend
Clone
- Run:
cd ..
- Run:
git clone https://github.com/Gary-Community-Ventures/benefits-calculator.git
cd
into the cloned repo
Dependencies
- Run:
npm i
Environment Variables
- Create a
.env
file - Add the following environment variables:
REACT_APP_API_KEY
: The backend API key. Make this the API key that I told you to copy earlier. It should be the API key looking text at http://localhost:8000/admin/authtoken/tokenproxy/REACT_APP_DOMAIN_URL
: The domain of the backend. Should behttp://localhost:8000
(no trailing slash)REACT_APP_GOOGLE_ANALYTICS_ID
[OPTIONAL]: The Google Analytics id if you want Google AnalyticsREACT_APP_MUI_LICENSE_KEY
[SUPER OPTIONAL]: The React MUI key for the pro version of React MUI. I don't think that we use any of the pro version components anymore so I don't think that you need it
URL
- Go to http://localhost:3000/step-1
- Add something awesome 🚀