teamship-studios / ozark-river-tracker

A web application for tracking information about rivers in the Ozark mountains of southern Missouri and northern Arkansas.
GNU General Public License v3.0
0 stars 0 forks source link

Overview

An application which periodically reads and stores gauge data for rivers via the United States Geological Survey Instantaneous Values Web Service.

The gauge data is served via a read only REST API.

The API is intended to be consumed by a front end application aimed at providing easy to read river information for paddlers.

Endpoints

/api/rivers - Returns a list of all tracked rivers

/api/rivers/:id - Returns a single river

/api/rivers/:id/gauges - Returns a list of gauges for a single river

/api/gauges - Returns a list of all tracked gauges

/api/gauges/:id - Returns a single gauge

/api/gauges/:id/metrics - Returns metrics for a single gauge

Running a Local Instance

A local instance can be created in docker using the docker compose in the root directory of the repo.

This will spin up an instance running the latest master.

docker-compose up

Seeding the Database

The database can be seeded by running the seeder program in the ort_api container passing the directory of the seed files as a parameter.

docker exec -it ort_api /bin/bash

./seeder rivers/

Reading Gauges

By default gauges are read, and their values stored every 15 minutes. TODO make this configurable with an env var.

Database

The project makes use of a PostgreSQL 12 database.

Migrations are handled via golang-migrate

Creating a New Migration

migrate create -dir=db/migrations/ -ext=.sql <migration_name>

Running Migrations

Migrations run automatically when starting the main Go API.

However, they can also be run manually if need be.

migrate -path=db/migrations/ -database <postgres_connection_string> up

Tests

Tests are written using test suites

Running Tests

go test ./... -cover