a rust tui to view amtrak train status
Rust 100.0%
9 1 0

Clone this repository

https://tangled.org/aparker.io/amtracker-tui https://tangled.org/did:plc:gttrfs4hfmrclyxvwkwcgpj7/amtracker-tui
git@tangled.org:aparker.io/amtracker-tui git@tangled.org:did:plc:gttrfs4hfmrclyxvwkwcgpj7/amtracker-tui

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

amtracker#

A terminal-based real-time Amtrak train tracker with a zoomable braille-rendered map.

Rust License

Features#

  • Live map of all active Amtrak trains rendered with Unicode braille characters
  • US state boundaries and Amtrak route lines as base layers
  • Color-coded train markers: green (on time), yellow (unknown), red (delayed)
  • Zoom and pan with keyboard controls
  • Search/filter trains by number, route name, or station code
  • Jump-to-train: center the map on any selected train
  • Train detail view with per-station delay status
  • Auto-refresh every 60 seconds

Install#

cargo install --path .

Or run directly:

cargo run --release

Controls#

Key Action
←↑↓→ Pan the map
+ / - Zoom in / out
Tab / Shift-Tab Cycle through trains
Enter Jump to selected train
/ Open search (filter by train #, route, station)
Esc Clear selection / exit search
0 Reset to full US view
r Manual refresh
q Quit

How it works#

Amtrak's Track Your Train page fetches real-time GPS data from an internal API (maps.amtrak.com/services/MapDataService/trains/getTrainsData). The response is AES-128-CBC encrypted with keys derived via PBKDF2-SHA1. amtracker reverse-engineered the decryption pipeline from Amtrak's client-side JavaScript and reimplemented it in Rust.

The decrypted data is GeoJSON containing coordinates, speed, heading, route, and per-station schedule/delay information for every active train.

Architecture#

src/
  crypto.rs   - AES decryption pipeline (PBKDF2, key extraction, decrypt)
  model.rs    - Train, StationStop, delay status types
  api.rs      - Async HTTP client for Amtrak endpoints
  geo.rs      - Embedded state boundary + route line data
  app.rs      - Application state (viewport, selection, search)
  ui.rs       - Ratatui rendering (map canvas, sidebar, search bar)
  main.rs     - Event loop and terminal setup
data/
  us-states.json  - Simplified US state boundaries (Natural Earth, public domain)
  routes.json     - Simplified Amtrak route geometry

Tests#

cargo test

41 tests covering crypto roundtrips, GeoJSON parsing, viewport math, search filtering, and UI rendering (via ratatui's TestBackend).

License#

MIT