# Development

Get started with local development.

Note: These steps have been verified on Apple Silicon.

# Requirements

# System

Install all system requirements at once

$ chmod +x ./_script/install.sh
$ ./_script/install.sh

# Optional

# Accounts

You don't need these unless you want to test Email/SMS services, or infrastructure.

# Getting Started

# Get .env values from @drewalth
cp .env.example .env

# Start data
docker compose up -d db elasticsearch

# Apply database migrations and seed fake data 
go run database/migrate/migrate.go
go run database/seed/seed.go

# primary api
go run api/main.go

# forecast api
cd forecast/
python3 -m flask run --host=0.0.0.0 --port=3002

# notification service (requires twilio + mailgun creds)
go run notify/main.go

### functions/
# 
# These are serverless functions + k8s CronJobs 
#
# usgs gage reading fetcher
go run functions/usgs/main.go

# canadian gage reading fetcher
go run functions/canada/main.go

# new zealand gage reading fetcher
go run functions/auckland/main.go

# chilean gage reading fetcher
go run functions/chile/main.go

# data clean up (requires aws creds)
go run functions/data/main.go

Now start up the frontend

# Web

From the wh2o-web project root:


# Set env variables
cp .env.example .env

# if working with local k8s set in the .env
# REACT_APP_API_BASE_URL=http://<microk8s_vm_ip>
# else
# REACT_APP_API_BASE_URL=http://localhost:3000

# Install dependencies
npm ci

# Start webpack dev server
npm start

# The frontend will be available at:
# http:localhost:8081

# Native

Setup instructions for Mac OSX.

Requirements:

  1. Setup database (see Setup step above)
  2. Start primary API
  3. Point wh2o-native at your local machine.
    1. Get your machines IP Address. System Preferences > Network
    2. Update wh2o-native/app.json with the IP
{
  "development": {
    "API_BASE_URL": "http://<your_machines_ip_address>:3000"
  }
}
  1. Start Expo development server and follow on-screen prompts
expo start --clear

# Git Branching

We more or less follow this strategy: A Successful Git Branching Model (opens new window).

The main branch is used for production.

The develop branch is used for staging/QA. All new branches made should be based on develop. Once your PR is merged into develop and passes testing, then we can create a new PR to merge develop into main and release to production.

# Tests

Run unit tests with:

go test -v ./...