scripts/
├── bahn.mjs ← thin CLI dispatcher (~60 lines)
├── lib/
│ ├── commands/ ← one module per mode
│ │ ├── search.mjs ← --search: station lookup
│ │ ├── departures.mjs ← --departures: live departure board
│ │ ├── parse.mjs ← --parse: connection parsing + enrichment
│ │ ├── journey.mjs ← --journey: route search
│ │ ├── live.mjs ← --live: real-time transfer check
│ │ └── track.mjs ← --track: train tracking
│ ├── helpers.mjs ← shared helpers (envelope, transfers, assessment)
│ ├── data.mjs ← source router (IRIS/Vendo/bahn.expert)
│ ├── predict.mjs ← probability model (opt-in via --predict)
│ ├── stats.mjs ← delay profiles + historical stats (opt-in via --stats)
│ ├── parse.mjs ← connection text parser
│ ├── format.mjs ← output formatter
│ ├── messageLookup.mjs ← IRIS delay code lookup
│ └── sources/
│ ├── bahn-expert.mjs ← bahn.expert tRPC source
│ ├── iris.mjs ← IRIS XML source
│ └── vendo.mjs ← db-vendo-client source
{
"mode": "string",
"timestamp": "ISO8601",
"connection": { "date", "from", "to", "legs", "transfers" },
"journeyOptions": { "from", "to", "date", "options" },
"departures": { "station", "entries" },
"stations": { "query", "results" },
"liveStatus": { "currentLeg", "nextTransfer", "zugbindungStatus", "recommendation", "remainingTransfers" },
"trackStatus": { "train", "from", "to", "stops", "maxDelay", "zugbindungStatus" },
"assessment": null,
"errors": [],
"warnings": []
}
Long-distance (ICE/IC/EC), regional (RE/RB), S-Bahn, buses, and international trains to neighboring countries.