Django RESTful API and PostgreSQL backend database management system for maintaining and serving Texas GIO's available data and content.
- Check out the wiki to learn about the data model and other curiosities
Built with:
- Python 3.8 (virtual environment (venv) suggested)
- PostgreSQL 10.7
- Amazon RDS Aurora Instance (
tnris-general-store
)
- Amazon RDS Aurora Instance (
- Django
- For data scripts, you probably want to use some form of python virtual env manager to maintain an isolated environment. A good run-down of the options can be found in The Hitchiker's Guide to Python. A recommended setup is virtualenv + virtualenvwrapper.
- Requires
jq
package to be installed on local os to startup with env variables from SecretsManager:apt-get update && apt-get install -y jq
- Enable your virtual environment. Example:
. {path to venv}/bin/activate
(for venv) - Upgrade pip using
pip install --upgrade pip
- Install python dependencies:
cd ~/api.tnris.org/src
pip install -r requirements.txt
- Setup secrets files:
./src/data_hub/set-env-secrets.sh
(for non Texas GIO employees only)./src/data_hub/gspread_config.json
- PREFERRED ::: Run the command
$(python configure.py)
from the root (for Texas GIO employees only) - ALTERNATIVE ::: A template copy of each secrets file exists in
./src/data_hub/
but with-example
in the filename. Make a copy of each file in the same directory, remove "-example" from the copy's name, and fill in the values for each secret manually.
- Set up a local development db instance or use local port forwarding to connect to a remote db instance
- Default settings are already setup if you're using local port forwarding to your port 9000 (skip to next step if you are doing this). If you're using a local development db, configure your database environment variables (
DB_NAME
,DB_USER
,DB_PASSWORD
,DB_HOST
,DB_PORT
) to point to it.
- Default settings are already setup if you're using local port forwarding to your port 9000 (skip to next step if you are doing this). If you're using a local development db, configure your database environment variables (
- Since the development of data.tnris.org v2, running the app local now requires installing GDAL/OGR on the host. See installation instructions for Debian-based Linux distros here: http://www.sarasafavi.com/installing-gdalogr-on-ubuntu.html
cd ~/api.tnris.org/src/data_hub/
python manage.py runserver
to run the app; it will be available atlocalhost:8000
. if you get a DB_PASSWORD env variable error then you need to re-run the env variable command in the previous step.
cd ~/api.tnris.org/src
pip freeze > requirements.txt
to save dependencies- save and commit all changes.
- push to github master branch to fire off the ci/cd pipeline which will automatically build and deploy to the staging env for review, and upon manual approval, then to the production env
deployment tests located in the ./tests/ directory
endpoint_tests.sh
runs within CodeBuild during deployment to validate api rest endpoints and landing pages are returning proper response codes before manual review & approval. must set variabledomain
when calling; example:domain=stagingapi.tnris.org . ./tests/endpoint_tests.sh
- The database API '/areas' endpoint is routinely accessed by a Lambda Function which pull the resource information and updates the mapserver database table 'areas_view' to join and host as a map service. This provides an efficient query capability for the Geography map filter to spatially identify collections.