LiveTN
An interactive map to see where Trento's buses are in real time.
The idea
The Trentino Trasporti app is handy, but navigating through its timetables is rather cumbersome. I thought of building a map that would show the CURRENT position of all buses, so you could pick the right one much faster.
Click on a bus to see its route!
Try the full version →Tech Stack
I chose SvelteKit for its simplicity and native reactivity, perfect for a web app of this kind. Redis is great for managing real-time bus positions, acting as a cache. In the new version, updates are pushed via SSE, which is far more efficient than traditional polling. As soon as the server has fresh information about a bus, it sends it immediately. OpenStreetMap/Leaflet is the natural choice for a project like this, offering free and customisable maps.
Implementation and the future
The system is fairly straightforward. Given that the Trentino Trasporti APIs were not designed for a live map, buses are identified by periodically scanning the terminal stops. They are then updated using the dedicated API for the position of a specific bus. Credit for the reverse engineering goes to Matteo Contrini, who documented everything on GitHub.
Since the number of API calls is rather high, the map is currently limited to Trento, but in the future I would like to extend it to the whole province.
Also, when no user is watching the map, the server completely stops updates to avoid unnecessary load. As soon as a user connects, the server wakes up almost instantly.
Reliability
The map is fairly reliable. I use it myself (I suppose if the creator of a project uses it, that’s a good sign). That said, the data source is a bit unstable: sometimes buses disappear for a few minutes for no apparent reason, but in general it works reasonably well.