Skip to content

nonissue/headway

Repository files navigation

headway

(formerly next-departures)

  • Shows upcoming departure times based on ETS GTFS Schedule data for geographically closest LRT station.
  • View the app online at:
  • Relies heavily on node-gtfs to parse and import GTFS CSV data into an sqlite database.
  • Analytics powered by Umami (free cloud plan)

Note to self (as of 25-10-10)

# npm run db:update performs the following:
# npx gtfs-import --configPath ./import-config.json
# sqlite3 db/gtfs.db < scripts/build_lrt_only_db.sql
npm run db:update

# npm run deploy
#   ↳ npm run build && fly deploy
# `npm run build` consists of:
#   ↳ npm run build:client
#   ↳ npm run build:server
npm run deploy

Other useful package.json scripts:

Build and serve the build locally for evaluting:

npm run preview

Warning: GTFS data not updated automatically

The GTFS Schedule data will have to be manually updated periodically — once a week should suffice.

I have not automated this process yet.

See "How to build and deploy" for instructions on how this is accomplished.

How to get started with development

  1. Fill out import-config.json and app-config.json
  2. Run npm run db:update (note: this can take a minute or two)
  3. Run npm run dev

How to build and deploy

Important: For fast deployment, build locally first rather than letting Fly.io build remotely.

  1. Fill out import-config.json and app-config.json
  2. Run npm run db:update (note: this can take a minute or two)
    • fetches gtfs data and imports it into db/gtfs.db
    • creates new slim database from db/gtfs.db at data/gtfs_lrt_only.db
  3. Run npm run build:all (builds locally for faster deployment)
  4. Run fly deploy (uses pre-built artifacts, much faster than remote build)

Quick Deploy Command

npm run deploy

This runs npm run build:all && fly deploy - builds everything locally then deploys.

Project Initialization Commands

Project DB Setup

See also package.json script npm run db:update described below.

# imports gtfs data into sqlite db './db/gtfs.db'
# you can also run:
# npm run db:import
npx gtfs-import --configPath import-config.json

# creates a slim version of our `./db/gtfs.db` at `./db/gtfs_lrt_only.db`
# you can also run:
# npm run db:slim
sqlite3 db/gtfs.db < scripts/build_lrt_only_db.sql

Alternative Database Scripts

run this as of 25-09-19

For creating the slim database with operational stop filtering (recommended):

# Creates filtered slim database excluding operational/maintenance stops
# Outputs to ./data/gtfs_lrt_only.db
npm run db:slim-filtered

Or run the SQL script directly:

sqlite3 db/gtfs.db < scripts/build_lrt_only_filtered.sql

The original (unfiltered) SQL script is also available but not recommended for production:

# creates a slim version of our `./db/gtfs.db` at `./db/gtfs_lrt_only.db`
# *should* leave original alone...
sqlite3 -batch db/gtfs.db < scripts/build_lrt_only.sql

Deployment

# Builds and deploys our app to fly.io so it is live
# https://headway.andy.ws (primary)
# https://next-departures.fly.dev (fly.io)
fly deploy

Custom Domain Setup: The app is accessible via both:

  • headway.andy.ws - Custom domain with SSL certificate managed by Fly.io
  • next-departures.fly.dev - Original Fly.io domain

DNS is configured with CNAME records pointing to Fly.io infrastructure. SSL certificates auto-renew via Let's Encrypt.

Analytics: Privacy-friendly analytics powered by Umami (free cloud plan). Tracking script is loaded client-side from cloud.umami.is. No server configuration required.

Package.json scripts

# 1. Fetches latest ETS transit data
# 2. Parses it into SQLite database initial Sqlite DB
# 3. Runs sql script to create our "slim" DB which is what our app uses
# and is what we deploy to production
npm run db:update

# Starts our express api server & vite ui at the same time
npm run dev

# Builds front end and API
npm run build:all

# Builds are project and runs our static entrypoint with node
npm run preview

Firefox spoof Geolocation for testing

about:config -> geo.provider.testing -> true about:config -> geo.provider.network.url -> data:application/json,{"location": {"lat": 53.50584, "lng": -113.52845}, "accuracy": 27000.0} about:config -> geo.wifi.uri -> data:application/json,{"location": {"lat": 53.50584, "lng": -113.52845}, "accuracy": 27000.0}

https://security.stackexchange.com/questions/147166/how-can-you-fake-geolocation-in-firefox

About

upcoming LRT departures for Edmonton Transit using GTFS

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published