Also available in Italian: Versione in italiano.
Regional trains in Lombardy are a hard place for a phone app. The train goes through cuttings and tunnels where GNSS and mobile data drop out, it changes cell towers every few minutes, and many passengers get motion sick when they read on board.
Trenord Infotainment (GitHub repository(opens in a new tab)) was our final project for the Design and Implementation of Mobile Applications (DIMA) course of the M.Sc. in Computer Science and Engineering at Politecnico di Milano. We built it with Trenord(opens in a new tab), the largest regional rail operator in Lombardy. The team was Tommaso Morganti, Luca Suzani and me. The goal was an offline-first app that shows where the train is, helps with motion sickness, and keeps passengers busy when the network is gone.

The problems
Most mobile apps assume they are always online. On a regional train that assumption fails all the time:
- Tunnels and dead zones. An app that waits on a network request before it responds freezes as soon as the train enters a tunnel.
- Motion sickness. The inner ear feels the carriage sway and accelerate, while the eyes see a phone that does not move. The mismatch makes people sick.
- Scattered information. Delays, platform changes, weather at the destination and connections live on different sites or in station announcements you can barely hear.
- Different screens. Passengers use small phones, large phones and tablets on the seat tray. A phone layout stretched to a tablet wastes the space.
We answered each one in turn: everything the trip needs is cached on the device, motion cues run on the UI thread, and the layout switches to two columns on wide screens.
Starting a trip
The passenger either scans the 2D barcode or PNR code on the ticket, or types the train number (for example 24869).

The app then calls the Trenord timetable service and downloads:
- the stations in order, with scheduled and estimated arrival times;
- dwell times, platforms and planned connections;
- the track coordinates, to draw the route on the map.
The app saves this journey on the device. If the connection drops a few seconds later, the trip is still there.
Tracking the train, also in tunnels
When the sky is visible, the app reads GNSS fixes from a high-frequency location stream.

GPS inside a train is noisy: the metal carriage blocks part of the signal and the rest bounces around. To keep the speedometer from jumping, we pass each speed reading through an exponential moving average (EMA):
with .
Dead reckoning
In a tunnel, GNSS fixes stop. Many transit apps then show a frozen position or a spinner. We added a small state machine instead:
- Detect the loss. If no new fix arrives within 5 seconds, the app leaves satellite mode and enters dead-reckoning mode.
- Estimate from the timetable. The app takes the cached timetable and the time elapsed since the last departure, and places the train at the matching point on the route between the two stations.
- Switch back. When the train leaves the tunnel and the fixes are good again, the position moves back to the GNSS reading without a jump or a reset of the screen.
Motion cues against motion sickness
On a curve the inner ear feels the train lean, but the eyes see a phone that stays still in your hands. That conflict causes motion sickness (kinetosis).
We added an overlay of motion cues.

The overlay draws 40 small particles along the edges of the screen. When the train sways, accelerates or takes a curve, the particles drift opposite to the acceleration. Peripheral vision sees the movement the inner ear feels, like an artificial horizon.
Running on the UI thread
Doing this math on the JavaScript thread would drop frames. The motion code runs on the native UI thread as React Native Reanimated worklets:

useAnimatedSensor(SensorType.ACCELEROMETER)samples the accelerometer at the display refresh rate (about 60 Hz or 120 Hz).- A low-pass filter () separates gravity () from the acceleration of the train.
- The remaining linear acceleration moves the particles, which wrap around the screen edges and fade with depth.
- The worklet never touches the JavaScript event loop, so the overlay holds 60 FPS.
We also added shake to report. If the phone detects a strong shake or a sudden deceleration (, ), the app opens the incident report sheet, so a passenger can report a delay, a fault or a medical emergency right away.
Offline games and media
Streaming video over train Wi-Fi or patchy LTE rarely works. The entertainment part of the app runs without the network.

The media hub has news, regional culture and entertainment:
- Background audio built on
expo-audio, with lock screen controls (MediaSession), playback speed from 1x to 2x, and chapter seeking that keeps working when you switch apps. - Commuter Sudoku, a 9x9 Sudoku with difficulty levels, pencil notes, error highlighting, a timer, and a board that is saved automatically.
- Trenord Hop, a pixel art endless runner at 60 FPS: you cross tracks, collect coins, and feel each hit through
expo-haptics.

Both games run on the device and make no network requests.
Arriving at the destination
Near the end of the trip, the app shows information about the arrival city:

- Weather and air quality: temperature, rain forecast and the European Air Quality Index (AQI 1 to 500).
- Points of interest: a map of landmarks, museums and historic buildings within walking distance of the station.
- Local news: a grid of municipal, regional and cultural articles about the destination.
- Alerts: notifications for upcoming connections, platform changes and the arrival countdown.

Tablets
Many commuters travel with a tablet. We did not want to stretch phone lists across a wide screen or keep a second codebase, so the layout changes at render time:

When the window is at least wide:
- The journey screen splits into two columns. The OpenStreetMap route stays on the left, and the stop list with delays and carriage occupancy is on the right.
- The home screen shows the gauges and the discovery carousels side by side.
- Dialogs are at most wide, so lines stay readable and buttons stay within reach.

Only the layout changes. App state, audio and running games are not interrupted when you rotate the device or resize the window.
Architecture and tests
The app is split into the containers shown in this C4 diagram:

- Navigation: Expo Router v5 with file-based routes. Route guards block the journey screens until a ticket is loaded.
- State: 11 Zustand 5 stores, one per domain (journey, weather, news, media, audio, games, settings and so on), persisted as JSON in AsyncStorage.
- End of trip: a single
rootResetaction clears every store at the end of a trip. It drops the trip data and keeps the passenger’s preferences and theme. - Security: an edge proxy only forwards requests to allowlisted hosts, which blocks SSRF. Requests to the Trenord B2B API authenticate with RS256 private key JWT assertions that tolerate clock skew.
Stack
| Area | Technology | What it does |
|---|---|---|
| Runtime | React Native 0.83.10 / Expo SDK 55 | Runs the app on the React Native New Architecture |
| Language | TypeScript 5.9 | Strict types for models, API payloads, stores and component props |
| State | Zustand 5 + AsyncStorage | 11 domain stores, saved as JSON and cleared at the end of a trip |
| Navigation | Expo Router v5 | File-based routes, tab bars and bottom sheets |
| Animation | React Native Reanimated 3 | Runs the motion cue particles on the UI thread at 60 FPS |
| Sensors | expo-sensors + expo-location | Reads the 3-axis accelerometer and frequent GPS fixes for the speedometer |
| Audio | expo-audio | Background playback with lock screen controls |
| Device access | expo-camera, expo-haptics, expo-notifications | Ticket scanning, vibration feedback and arrival alerts |
| Tests | Jest 29 + React Native Testing Library + fast-check | 142 suites, 921 tests, property-based EMA tests and accessibility checks |
| APIs | Edge proxy + OAuth 2.0 (RS256 JWT) | Trenord B2B, OpenStreetMap routes, Open-Meteo, CurrentsAPI and Listen Notes |
| Languages | react-i18next | Every string is available in Italian and English |
Tests
The project has 142 test suites with 921 unit tests:


They cover:
- Math: property-based tests with
fast-checkcheck that the EMA filters converge and that the wrapping of particle coordinates never puts a particle off screen. - State changes: the dead-reckoning state machine, the audio lifecycle and the guards that require a ticket.
- Accessibility: React Native Testing Library checks the accessibility labels and the 44px minimum size of touch targets.
What I learned
Trenord gave us real operational data and context about their network. That pushed the project past a typical CRUD app: we had to deal with noisy sensors, coverage gaps, battery use and passengers who feel sick on a moving train.
On a train, connectivity is a bonus, not something to count on. Keeping the trip on the device, running animations on the UI thread and adapting the layout to the screen were enough to make the app work in the middle of a mountain tunnel.
Thanks to my teammates Tommaso Morganti and Luca Suzani, to the Trenord engineering team for their time and context, and to the DIMA course staff at Politecnico di Milano.
The code and the documentation are open source on GitHub(opens in a new tab).