Vai al contenuto principale
Torna al Blog
•8 min di lettura•English

Nota Asimmetrica: Questo saggio è stato redatto in lingua inglese ed è presentato nel testo autoriale originario.

Building Trenord Infotainment: A Next-Generation Onboard Passenger Companion

Architecting an offline-resilient, sensor-augmented transit companion for regional rail commuters: from 60 FPS Reanimated motion cues to tunnel dead-reckoning and universal tablet layouts.

#Mobile Engineering#React Native#Expo#Transit Tech#System Design#TypeScript

Daily regional rail transit across Lombardy presents a demanding operating environment for mobile software. Commuters navigate high-speed curves, switch between cellular base stations, and pass through subterranean and alpine tunnels where satellite GNSS signals and cellular data disappear entirely. Simultaneously, many passengers experience motion discomfort when attempting to read on moving rolling stock.

As our final project for the Design and Implementation of Mobile Applications (DIMA) course in the Master of Science in Computer Science and Engineering at Politecnico di Milano—developed in academic collaboration with Trenord(opens in a new tab), one of the biggest railway companies in Italy and the largest regional rail operator in Lombardy—my teammates Tommaso Morganti, Luca Suzani, and I set out to architect and build Trenord Infotainment (GitHub repository(opens in a new tab)). Our objective was to create a modern, offline-first mobile companion that bridges the gap between raw railway telematics, passenger wellbeing, and resilient onboard media.

Trenord Infotainment live journey tracking map and station stop timeline

The Transit Computing Challenge

Modern mobile applications typically assume continuous, low-latency internet connectivity. In regional transit, however, that assumption routinely fails:

  1. Intermittent Connectivity & Tunnel Blackouts: Rail corridors throughout Lombardy pass through extensive cuttings and tunnels. Apps that gate user interactions behind blocking network requests quickly become unresponsive.
  2. Kinematic Discomfort (Kinetosis): Reading or interacting with handheld screens while rolling stock yaws and accelerates causes a sensory conflict between the vestibular system (which feels vehicle movement) and the ocular system (which sees a stationary phone screen).
  3. Information Fragmentation: Delay estimations, platform reassignments, destination weather, and transfer options are often spread across separate portals or noisy station announcements.
  4. Form Factor Diversity: Passengers carry diverse devices, from compact smartphones to wide tablets and iPads mounted on seatback trays, requiring adaptive spatial layouts rather than stretched mobile interfaces.

To address these constraints, we designed Trenord Infotainment around three architectural pillars: deterministic offline resilience, hardware-accelerated kinematic comfort, and responsive multi-column layout bifurcation.

Seamless Onboarding & Ticket Verification

The journey starts at the ticket gate. Rather than requiring users to manually configure their trip details, Trenord Infotainment supports two onboarding pathways: optical scanning of physical ticket 2D barcodes / PNR booking codes, or quick entry of a numerical train code (e.g. 24869).

Ticket scanning and destination station selection onboarding flow

Upon code submission, the client initiates an authenticated handshake with the Trenord timetable service, automatically hydrating:

Once hydrated, this journey contract is stored locally in device storage, ensuring that passengers never lose their active trip context even if connectivity drops seconds later.

Live Railway Telemetry & Tunnel Dead-Reckoning

Tracking a train’s real-time position requires combining network telematics with local device sensors. When satellite visibility is clear, the app samples GNSS fixes via high-frequency location streams.

Home dashboard with live train telemetry, station countdown, and contextual feed

Raw GPS data in moving trains is notoriously noisy due to metallic carriage shielding and multi-path reflections. To produce smooth, jitter-free speedometer telemetry, we process raw velocities through an Exponential Moving Average (EMA) filter:

vsmooth,t=α⋅vmeasured,t+(1−α)⋅vsmooth,t−1v_{\text{smooth}, t} = \alpha \cdot v_{\text{measured}, t} + (1 - \alpha) \cdot v_{\text{smooth}, t-1}

with a smoothing factor of α=0.35\alpha = 0.35.

Surviving Tunnel Blackouts

When rolling stock enters a tunnel, GNSS fixes freeze or drop out entirely. Standard transit applications fail in this scenario, displaying frozen coordinates or spinning loaders.

Trenord Infotainment implements a dead-reckoning fallback state machine:

  1. Signal Loss Detection: If no fresh GNSS fix arrives within a 5-second sampling window, the system switches from Satellite Mode to Dead-Reckoning Mode.
  2. Schedule Interpolation: The engine queries the pre-cached timetable, calculating expected position along the railway polyline based on elapsed run time between the previous scheduled departure and the upcoming station arrival.
  3. Seamless Re-acquisition: As soon as the train exits the tunnel and GNSS confidence is restored, the position smoothly snaps back to physical telemetry without jumping or resetting the user interface.

Mitigating Motion Sickness: The 60 FPS Anti-Kinetosis Engine

Reading text on a vibrating, swaying train frequently triggers kinetosis (motion sickness). This occurs because your inner ear feels the lateral centrifugal force as the train rounds a bend, but your eyes fixate on a phone screen that appears completely motionless relative to your hands.

To solve this, we built a hardware-accelerated vehicle motion cue overlay.

Vehicle motion cues active with edge-aligned inertial particles

The system renders 40 unobtrusive, edge-aligned inertial particles along the perimeter of the screen. As the train sways, accelerates, or enters a curve, these particles smoothly drift in the opposite direction of the vehicle’s acceleration vector, providing the commuter’s peripheral vision with an intuitive artificial horizon.

Lock-Free UI Worklets

Running continuous trigonometric calculations on the JavaScript thread would introduce frame drops and degrade UI responsiveness. Instead, our motion engine executes entirely on the native UI thread using React Native Reanimated worklets:

Hardware sensor processing and kinematics pipeline

  1. The device accelerometer is sampled at display refresh rate (~60 Hz / 120 Hz) via useAnimatedSensor(SensorType.ACCELEROMETER).
  2. A low-pass filter (α=0.8\alpha = 0.8) separates the static gravitational vector (1.0G1.0\text{G}) from dynamic vehicle acceleration.
  3. The resulting linear acceleration vector drives particle displacement across the screen boundary with smooth coordinate wrapping and depth fading.
  4. Because the math runs inside a worklet, the overlay maintains a rock-solid 60 FPS without consuming a single cycle on the main JavaScript event loop.

Complementing the motion cues, we also built a Shake-to-Report safety listener. If a sudden severe deceleration or physical shaking occurs (M>2.2GM > 2.2\text{G}, ΔM>1.2G\Delta M > 1.2\text{G}), the application automatically opens the onboard incident reporting sheet, enabling passengers to report delays, maintenance issues, or medical emergencies immediately.

Zero-Latency Offline Arcade & Media Hub

Streaming video or loading heavy web pages over congested train Wi-Fi or intermittent LTE is frustrating. We designed the entertainment subsystem to be self-contained and battery-friendly.

Media hub showcasing film spotlights and background audio podcasts

The media hub combines curated regional transit culture, news, and entertainment:

Offline arcade games: Trenord Hop 60 FPS runner and Commuter Sudoku

Both games execute 100% locally with zero external network requests, offering immediate entertainment regardless of network state.

Destination Intelligence & Local Insights

As the train approaches its destination, the app transitions into an environmental and local intelligence hub:

Destination POI explore sheet and digital news magazine

Notifications timeline sheet and passenger settings controls

Universal Tablet Bifurcation (iPad Support)

Commuters on intercity and regional routes frequently travel with tablets and iPads. Instead of stretching phone-proportioned lists across wide screens or maintaining separate codebase forks, Trenord Infotainment adopts render-time layout bifurcation:

Tablet two-column simultaneous map and timeline layout on iPad

When the viewport width meets the tablet threshold (w≥768 pxw \ge 768\,\mathrm{px}):

Tablet multi-column home dashboard on iPad

Because this bifurcation happens purely at the presentation layout layer, domain state, audio playback, and active game sessions continue uninterrupted across device rotation and window resizing.

System Architecture & Verification Rigor

Under the hood, Trenord Infotainment follows a decoupled C4 container architecture engineered for predictability and testability:

C4 container topology diagram for Trenord Infotainment

Technology Stack & Engineering Specifications

DimensionTechnology & VersionArchitectural Role
Mobile RuntimeReact Native 0.83.10 / Expo SDK 55Modern mobile application framework running the React Native New Architecture
LanguageTypeScript 5.9Full strict typing across models, API payloads, state stores, and component props
State ManagementZustand 5 + AsyncStorage11 decoupled domain state stores with atomic JSON persistence and session resets
NavigationExpo Router v5File-based hierarchical navigation, tab shells, and slide-sheet modals
Kinematics & UIReact Native Reanimated 360 FPS lock-free UI thread worklets driving anti-kinetosis particle vectors
Hardware Sensorsexpo-sensors + expo-location3-axis accelerometer IMU streaming and high-frequency GPS speedometer fixes
Audio Subsystemexpo-audioDecoupled background playback with OS lockscreen MediaSession sync
Native Device Bridgesexpo-camera, expo-haptics, expo-notificationsOptical barcode ticket onboarding, tactile feedback, and proximity alerts
Testing FrameworkJest 29 + React Native Testing Library + fast-check142 test suites (921 tests), property-based EMA tests, and accessibility checks
Cloud & APIsEdge SSRF Proxy + OAuth 2.0 (RS256 JWT)Trenord B2B services, OpenStreetMap polylines, Open-Meteo, CurrentsAPI, Listen Notes
Internationalizationreact-i18next100% bilingual parity across all user-facing strings (Italian & English)

Testing Pyramid & Quality Gates

To ensure stability across all physical device scenarios, we instituted an exhaustive automated verification strategy. The test baseline includes 142 test suites comprising 921 passing unit tests with comprehensive line and branch coverage:

Automated code coverage report showing over 90 percent coverage across 142 test suites

Our test suite covers:

Reflections & Takeaways

Building Trenord Infotainment for the Design and Implementation of Mobile Applications exam at Politecnico di Milano in collaboration with Trenord was an incredible engineering journey. Working with real-world operational insights from Trenord—whose transport network connects hundreds of thousands of commuters daily across Lombardy as the region’s premier rail carrier—pushed us to look beyond conventional CRUD app development and tackle the real physics of mobile computing: noisy sensor hardware, intermittent cellular corridors, battery constraints, and physical human ergonomics.

Designing systems for transit requires treating connectivity as a luxury rather than an assumption. By pairing local-first state persistence with native UI worklets and responsive layouts, it is possible to build software that feels fast, reliable, and genuinely helpful—even in the middle of a mountain tunnel.

Special thanks to my teammates Tommaso Morganti and Luca Suzani for the stellar collaboration, to the Trenord engineering team for the domain context and collaboration, and to the faculty at Politecnico di Milano for encouraging deep system engineering and polished human-centered design.

The complete codebase, documentation, and architecture specifications are open-source on GitHub(opens in a new tab).