Skip to content

✨ Route all rail data through the Better Rail server (GTFS migration)#631

Open
planecore wants to merge 4 commits into
mainfrom
gtfs-migration
Open

✨ Route all rail data through the Better Rail server (GTFS migration)#631
planecore wants to merge 4 commits into
mainfrom
gtfs-migration

Conversation

@planecore

Copy link
Copy Markdown
Collaborator

What & why

Companion to the server's GTFS migration (better-rail/server#28). The app no longer talks to the Israel Railways API (rail-api.rail.co.il) directly — all rail data now flows through the Better Rail server, including the calls we didn't migrate (announcements, popup messages, station info), which the server proxies upstream.

Because the server emulates the legacy searchTrainForMobile JSON shape, this is mostly a base-URL change plus dropping the Ocp-Apim-Subscription-Key header and the 403→proxy fallback. The canonical 3700-style station IDs are unchanged, so decoders and Better Rail Live stay as-is.

Changes

  • JS app: config/api-config.ts points the timetable + rail-api at the server and drops the API key and the direct/proxy split; services/api/route-api.ts and services/api/rail-api.ts updated to match.
  • iOS (Swift): the home-screen widget, Watch app, and Watch widget RouteModel.swift, plus the Watch CriticalAlertsModel.swift, now hit the server and drop the subscription-key header (decoders unchanged thanks to shape emulation).
  • Android (Kotlin): plugins/withBetterRailAndroid/withAndroidGradle.js timetable URLs point at the server; RailApiService.kt drops the key header and the 403→proxy fallback.
  • Better Rail Live: structurally unchanged (still 3700-style IDs); the route JSON is now ultimately GTFS-sourced via the server. Delays show 0 until SIRI lands.

Depends on

  • better-rail/server#28 (GTFS over Postgres) must be deployed for these endpoints to work.

Test plan

  • Build & run the JS app, iOS widget + Watch, and Android widget; verify routes render and that no requests hit rail-api.rail.co.il (network inspector) — only the Better Rail server.

🤖 Generated with Claude Code

- Point the JS client, iOS widget/watch/watch-widget, and the Android widget at
  the server's /rail-api endpoint instead of calling rail.co.il directly; drop
  the API key and the direct→proxy 403 fallback.
- Timetable is served by the server's GTFS-backed searchTrainForMobile (same
  response shape); announcements / popup messages / station info are proxied
  through the same server route.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request migrates the client to route all Israel Railways data through the Better Rail server, removing direct calls to rail.co.il and eliminating the embedded API key across Android, iOS, and web services. While these changes simplify the API client logic and remove the need for a 403 fallback mechanism, several improvements should be made: the hardcoded environment variable in the API configuration should be made dynamic to avoid dead code, the force-unwrapped dynamic URL in the watch model should be safely handled to prevent runtime crashes, and the redundant 403 fallback logic in the Android native service should be cleaned up.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/config/api-config.ts
Comment thread targets/watch/Models/CriticalAlertsModel.swift Outdated
Comment thread android-native/java/com/betterrail/widget/api/RailApiService.kt
- api-config: drop the dead non-production branch (single server URL)
- watch CriticalAlertsModel: guard let instead of force-unwrapping the URL
- Android RailApiService: remove the now-redundant 403→proxy fallback
  (both timetable URLs are identical) and the unused buildConfig field
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant