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

  1. cd into the directory that you want to have the project in
  2. Run: git clone https://github.com/Gary-Community-Ventures/benefits-api.git
  3. cd into the cloned repo

Install Dependencies

  1. Run: python -m venv venv
  2. Activate the virtual environment. It differs by operating system, so instructions are: https://python.land/virtual-environments/virtualenv
  3. Run: pip install -r requirements.txt

Set Up Database

  1. Download PostgreSQL: https://www.postgresql.org/download/
  2. Login to pgadmin
  3. Create a new user and password: https://www.guru99.com/postgresql-create-alter-add-user.html
  4. Create a database and give the user permissions.

Environment Variables

  1. Create a .env file
  2. Add the following environment variables:
    • SECRET_KEY: A random string that is used for hashing
    • DB_NAME: The name that you gave the database
    • DB_USER: The name of the user that has access to the database
    • DB_PASS: The password of the user that has access to the database
    • DJANGO_DEBUG: Turns the backend into debug mode. Set to True while developing
    • GOOGLE_APPLICATION_CREDENTIALS: A Google service account with access to spreadsheets and translate
    • ALLOW_TRANSLATION_IMPORT: Set to True. This is to prevent you from importing translations into prod from another environment
    • FRONTEND_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 API
    • POLICY_ENGINE_CLIENT_SECRET: The Policy Engine API token
    • SENDGRID [OPTIONAL]: A SendGrid API key if you want to send emails
    • EMAIL_FROM [OPTIONAL]: The email you want to send emails from
    • TWILIO_SID [OPTIONAL]: The Twilio SID if you want to send texts
    • TWILIO_TOKEN [OPTIONAL]: The Twilio token if you want to send texts
    • TWILIO_PHONE_NUMBER [OPTIONAL]: The Twilio phone number if you want to send texts
    • HUBSPOT [OPTIONAL]: The HubSpot token if you want to send contacts to HubSpot
    • BREVO_API_KEY [OPTIONAL]: The Brevo token if you want to send contacts to Brevo

Run Some Commands

  1. Run: python manage.py migrate
  2. Run: python manage.py createsuperuser and create an admin account.
  3. Run: python manage.py runserver

Some Admin Stuff

  1. Go to http://localhost:8000/admin/authtoken/tokenproxy/
  2. Click the + in the top right
  3. Select the user that you just created
  4. Copy the API key for later
  5. Go to http://localhost:8000/admin/screener/whitelabel/
  6. Click on the +
  7. Add a white label with the name Default and the code _default

More Commands

  1. Go to https://github.com/Gary-Community-Ventures/mfb-translations/tree/main/translations
  2. Download the most recent json file, or clone the repo
  3. Run: python manage.py bulk_import < path/to/the/file/that/you/just/downloaded.json
  4. If the above command throws an error than run it again. IDK why, but it worked for me the second time
  5. Run: python manage.py add_config --all
  6. Run: python manage.py runserver again if you stopped the server

Frontend

Clone

  1. Run: cd ..
  2. Run: git clone https://github.com/Gary-Community-Ventures/benefits-calculator.git
  3. cd into the cloned repo

Dependencies

  1. Run: npm i

Environment Variables

  1. Create a .env file
  2. 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 be http://localhost:8000 (no trailing slash)
    • REACT_APP_GOOGLE_ANALYTICS_ID [OPTIONAL]: The Google Analytics id if you want Google Analytics
    • REACT_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

  1. Go to http://localhost:3000/step-1
  2. Add something awesome 🚀