MyFriendBen was created by Gary Community Ventures, a Denver-based organization. We co-designed MyFriendBen with a group of Colorado families who are participating in a direct cash assistance program. Families told us it was difficult and time-consuming to know what benefits they were entitled to. We are defining “benefits” as public benefits (includes city, county, state and federal), tax credits, financial assistance, nonprofit supports and services. MyFriendBen only includes benefits and tax credits with an annual value of at least $300 or more a year.
Taking inspiration from AccessNYC, and connecting with PolicyEngine's API for benefits calculation, we built out a universal benefits screener with the goal to increase benefit participation rates by making key information - like dollar value and time to apply - more transparent, accessible, and accurate. The platform is currently live in Colorado and has been tested with over 40 benefits.
This is the repository for the backend Python/Django rules engine that takes household demographic data and returns benefits eligibility and estimated values. The frontend repository can be accessed here.
Clone the project: git clone https://github.com/Gary-Community-Ventures/benefits-api.git
Create virtual environment: python -m venv venv
Install dependencies: pip install -r requirements.txt
Download PostgreSQL:
Windows: https://www.postgresql.org/download/windows/
Mac: https://www.postgresql.org/download/windows/
Login to pgadmin
Create a new user and password.
Create a database and give the user permissions.
https://www.guru99.com/postgresql-create-alter-add-user.html
Create a .env
file in the backend root directory
SECRET_KEY
DB_NAME
DB_USER
DB_PASS
DJANGO_DEBUG
GOOGLE_APPLICATION_CREDENTIALS
SENDGRID
TWILIO_SID
TWILIO_TOKEN
TWILIO_PHONE_NUMBER
FRONTEND_DOMAIN
HUBSPOT [optional]
ALLOW_TRANSLATION_IMPORT
Migrate python manage.py migrate
Create super user: python manage.py createsuperuser
. Then fill out fields as prompted.
Run server: python manage.py runserver
MyFriendBen programs are stored in the database. The quick_start command will create the initial programs. These generated programs are not fully accurate to the actual programs. For example, the quick start command will mark every program as having no legal status requirements.
python manage.py quick_start
MyFriendBen uses google translate to translate MyFriendBen into other languages. If a translation is incorrect, it is possible to manually edit the translations.
Download: Translations
python manage.py bulk_import < [PATH TO FILE]
An API key is needed for the front end to connect to the backend.
Go to http://localhost:8000/admin/auth/group/
Create a group with:
Go to http://localhost:8000/admin/authentication/user/
Create a new user and add the group that was just created.
Go to http://localhost:8000/admin/authtoken/tokenproxy/
Create a token and add the user that was just created.
The API currently uses 2 google cloud services: Cloud Translation API & Google Sheets API
Visit the google cloud services sign up page and click on “TRY FOR FREE”
The next step is to go the google services APIs library page and add and enable the required services:
Go to the “Credentials” tab and add a new “Service account”
After adding the service account, select it and go to its page. And from the “KEYS” tab press the “ADD KEY” and “Create new key” and select the type of key to be JSON.
The generated JSON is going to be something like so:
{
"type":"service_account",
"project_id":"[YOUR_PROJECT_ID]",
"private_key_id":"[PRIVATE_KEY_ID]",
"private_key":"[PRIVATE_KEY]",
"client_email":"[CLIENT_EMAIL]",
"client_id":"[CLIENT_ID]",
"auth_uri":"[AUTH_URI]",
"token_uri":"[TOKEN_URI]",
"auth_provider_x509_cert_url":"[AUTH_PROVIDER_URL]",
"client_x509_cert_url":"[CLIENT_CERT_URL]",
"universe_domain":"[UNIVERSE_DOMAIN]"
}
Though in order for the .env file to make use of this JSON object properly it needs to be formatted so that everything is in one line, like so:
{"type": "service_account", "project_id": "[YOUR_PROJECT_ID]"}
A tool like this can be used to make the json into the correct format: https://www.text-utils.com/json-formatter/