This is the backend API for the Pathways application, built with Express. It contains the API for retrieving human services data, and will be used in the Pathways frontend.
This project uses ExpressJS as the web framework for creating the API endpoints. It also attempts to adhere to the OpenReferral standards. This means two things:
- Providing an API that is compliant with the Human Services Data Specification API (HSDS API)
- Allowing data that meets the OpenReferral modelling specification to be imported.
To implement the HSDS API, Swagger is used to generate the endpoints, using the OpenAPI file provided through the OpenReferral effort. Through Swagger, the API endpoints are validated automatically to ensure the API returns compliant responses.
Make sure you have the following Environment vars set:
PATHWAYS_MONGO_HOST
- the host of the MongoDB storing Services records (ds159112.mlab.com)PATHWAYS_MONGO_PORT
- the port of the MongoDB storing Services records. (59112)PATHWAYS_MONGO_USER
- the user with access tothe MongoDB storing Services records. (peacegeeks)PATHWAYS_MONGO_PASS
- (ask a developer)PATHWAYS_MONGO_DB
- the name of the DB storing Services records. (bc211)
npm install
swagger project start
You can also run the entire backend stack through Docker if you prefer. There is a docker compose file that brings up the backend and the MongoDB in a single stack with:
docker-compose up
Add the Heroku remote
git remote add heroku https://git.heroku.com/pathways-backend.git
Deploy changes to Heroku
git push heroku master
Set environment variables with:
heroku config:set <ENV_NAME>=<value>
For example:
heroku config:set PATHWAYS_MONGO_DB=bc211
Run the script:
node data/seed_database.js PATH_TO_211_OPEN_REFERRAL MODE PATH_TO_211_XML
The backend is built to work on Human Services data stored in the BC211 datasets. BC211 uses iCarol as their storage solution, so the data we seed the database is exported from here. It is intended that we will receive periodic data dumps from BC211, and sync to these, so that we do not have to maintain the integrity of the data ourselves.
In order to get started on a new deployment (local or otherwise), you must seed the database with the BC211 dataset.
The first thing you must seed is the BC211 data. This application supports importing this data in an OpenReferral format. iCarol supports exporting the data like this, so one must request the data from them. Contact a team member to get a data set.
BC211 uses their own custom taxonomy set to categorize their data for maximum utility. Unfortunately, OpenReferral exporting does not export these additional taxonomy terms, so we must seed them manually, by parsing the XML-formatted version of the data.
You can use the standard MongoDB migration tools to perform database migrations.
mongodump --uri <database uri> -o ~/data/bc211bk
mongorestore -u peacegeeks -p <password> --host ds159112.mlab.com --port 59112 -d bc211 ~/data/bc211bk/bc211/