We want to invite the developer community to contribute to our mission of promoting a culture of evidence-based and transparent policymaking. Please read the following instructions to start contributing to this project.
git clone [email protected]:bayesimpact/encompass.git
Download and install Docker Community Edition (link).
In this project's root folder, add a file called .env
with the following info (replacing ???
with real values):
MAPBOX_TOKEN=???
POSTGRES_URL=???
API_ROOT=http://localhost:8080
ENV=LOCAL
IS_AWS=FALSE
MAPBOX_TOKEN
: API key provided by Mapbox for mapping.POSTGRES_URL
: URL for database used by the application. This might belocalhost
for development.
To use with an AWS RDS instance, the additional environment variables AWS_ACCESS_KEY
and AWS_SECRET_KEY
are required for using the AWS CLI. In addition, IS_AWS
should be set to TRUE
. This variable helps to initialize the database correctly when using an RDS instance. You will not need this environment variable if you are not using an RDS database.
All data required to initialize an RDS instance can be found in this S3 bucket.
In your terminal, run:
docker-compose -f docker-compose.yml -f docker-compose.local.yml up backend frontend
Three Docker containers are available for development:
- Frontend: React/TypeScript app to fetch and visualize network adequacies.
- Backend: Flask/uWSGI/Nginx-powered REST API to geocode providers and compute network adequacies.
- Explorer: A container running Jupyter notebooks for easy exploration and model testing.
- DB: A container running a Postgres server with the relevant GIS extensions.
docker-compose up backend
- The API will then be accessible at localhost:8080
- It provides the following REST routes (we document each route with its corresponding JSON-Schema definitions):
Method | Route | Request schema | Response schema | Description |
---|---|---|---|---|
GET | /api/available-service-areas/ | (none) | Schema | Fetches and returns all available service areas |
POST | /api/providers/ | Schema | Schema | Geocodes, saves to the database, and returns (or, reads from the database if already defined) the given providers |
POST | /api/representative_points/ | Schema | Schema | Computes representative points for the given service areas |
POST | /api/adequacies/ | Schema | Schema | Computes adequacies for the given service areas against the given providers |
docker-compose -f docker-compose.yml -f docker-compose.local.yml up frontend
See frontend/README.md for more documentation.
Read more on how to contribute to the frontend
docker-compose up db
This container will allow you to run a fully functioning local system with a POSTGRES_URL
at db.local
.
The database will be initialized but won't contain any data. There is some sample data for Los Angeles county included in this repository in the data/sample
directory as well as a script to initialize the database and load the sample data. Simply run:
make initialize-local-db
To pull the latest version and refresh the dockers, simply run make deploy
in the main directory.
A sample Terraform configuration is provided in the /terraform directory. Further information is available here.
Sample CircleCI configuration is provided in the /.circleci directory. The default configurations are set up to run all tests and coverage on any branch and to update remote environments on specific branches. You can modify this configuration to match your own remote environment schema.
To use these CircleCI jobs for deployment, you'll need to set up keys in CircleCI to allow SSH access to your application servers. You'll also need to set the relevant environment variables up containing the DNS names for your application servers.
To enforce HTTPS on remote environments (by redirecting HTTP requests) you can use the remote override docker-compose file. This will run an Nginx server inside the frontend container to act as reverse proxy, which uses the ROOT_DOMAIN
environment variable to determine where to redirect to.
Sample usage:
docker-compose -f docker-compose.yml -f docker-compose.remote.yml up -d frontend backend