TNRIS / api.tnris.org

Django RESTful API and PostgreSQL backend database management system for maintaining and serving Texas GIO's available data and content.
https://api.tnris.org
MIT License
7 stars 0 forks source link
api aws backend carto content-management-system data django lambda postgres python s3 tnris

api.tnris.org

Django RESTful API and PostgreSQL backend database management system for maintaining and serving Texas GIO's available data and content.

API and content management system for Texas GIO data!

Setup

Built with:

Django App Setup

  1. Requires jq package to be installed on local os to startup with env variables from SecretsManager: apt-get update && apt-get install -y jq
  2. Enable your virtual environment. Example: . {path to venv}/bin/activate (for venv)
  3. Upgrade pip using pip install --upgrade pip
  4. Install python dependencies:
    • cd ~/api.tnris.org/src
    • pip install -r requirements.txt
  5. 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.

Local Development

  1. 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.
  2. 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
  3. cd ~/api.tnris.org/src/data_hub/
  4. python manage.py runserver to run the app; it will be available at localhost:8000. if you get a DB_PASSWORD env variable error then you need to re-run the env variable command in the previous step.

Deployment Prep

  1. cd ~/api.tnris.org/src
  2. pip freeze > requirements.txt to save dependencies
  3. save and commit all changes.
  4. 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

Tests

deployment tests located in the ./tests/ directory

Notes

Order Data retention Policies

To be implemented future procedures for handling order deletions for the API. Jun 18 2024