Stationboard for Swiss public transport
  • TypeScript 41.8%
  • Go 30.4%
  • CSS 13.6%
  • HTML 12.8%
  • JavaScript 1.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Ralph Schaer a44040d162 upgrade
2026-10-04 10:09:02 +02:00
backend upgrade 2026-10-04 10:09:02 +02:00
frontend upgrade 2026-10-04 10:09:02 +02:00
importer upgrade 2026-10-04 10:09:02 +02:00
.gitignore upgrade 2026-09-27 09:09:49 +02:00
Caddyfile upgrade 2026-05-01 09:49:59 +02:00
README.md Upgrade 2026-06-21 07:21:43 +02:00
Taskfile.yml upgrade 2026-09-03 20:40:49 +02:00
TODO.txt upgrade 2026-05-01 09:50:20 +02:00

Swiss public transport stationboard

https://transit-ch.rasc.ch

Transit CH is an Angular 22 PWA for Swiss public transport stationboards. The frontend calls the public transport.opendata.ch API for station search and departure/arrival boards, supports English, German, French, and Italian via Transloco, and includes service-worker update prompts.

The Go backend is a small companion API for traffic-point coordinates backed by a read-only Pebble database generated by the importer.

Frontend

Run from the frontend directory:

npm install
npm start

Useful commands:

npm run lint
npm run build
npm run check
npm run format

The production build writes to frontend/dist/transit-ch/browser and the postbuild step precompresses assets with gzip, Brotli, and zstd for Caddy.

Backend

The Go backend listens on port 34341 by default.

Run it from the backend directory:

go run .

Set a custom port either with a flag or a positional argument:

go run . -port 8080
go run . 8080

At startup the backend opens ./traffic-points as a read-only Pebble database, so the traffic-points directory must exist in the current working directory.

Available endpoints:

GET /traffic-point-v2/{number}
GET /traffic-point-v2/{number}/{designation}

Successful responses are JSON objects with numeric lat and lng fields.

Importer

Run the importer from the importer directory:

go run .

It reuses 71ea6819-e128-4fda-8ea7-332283309351.csv when already present, otherwise it downloads the CSV from Open Transport Data Switzerland. The import creates importer/traffic-points, a Pebble database keyed by number. Each value is JSON with an entries array containing designation, lat (from wgs84North), and lng (from wgs84East) as strings.

Copy or move the generated traffic-points directory into the backend working directory before starting the backend.

Repository Tasks

From the repository root, Taskfile commands are available:

task format
task lint
task test
task build-frontend

task test runs the Go tests for backend and importer. Frontend verification is covered by npm run check or task build-frontend.

Deployment

Caddyfile serves the Angular build from /opt/transit-ch/dist/transit-ch/browser, enables precompressed assets, applies security headers, routes SPA fallback requests to index.html, and reverse-proxies /traffic-point-v2/* to the Go backend on port 34341.