back to index

CTA Transit Tracker

A real-time bus and train tracking system built during Loyola's Hackathon.

repo: https://github.com/EricSpencer00/LoyolaHACK



▶ Watch on YouTube


CTA Transit Tracker is a full-stack web app that predicts when Chicago buses and trains are about to arrive near a saved home location and sends a text about it. It was built solo in under 48 hours during Loyola's Spring Hackathon, which is enough time to write the code and about half the time needed to make it stop breaking.

The premise is to notice when a bus is a few minutes from a stop and send a text, instead of refreshing the CTA app. The CTA exposes real-time prediction APIs for both buses and trains, and publishes GTFS feeds, the standard transit data format, distributed as a set of CSVs (stops.txt, shapes.txt, and so on) describing every route and stop in the system. The data was already available. Everything around it is what the project builds.

The backend is Flask with SQLite for storage and Flask-Migrate/Alembic for schema changes, which came up more often than expected for a weekend project. The map is Leaflet: a draggable marker sets the home location, lines of interest are selected, and both are saved to the account. Authentication is OTP over SMS, so no passwords are stored. Notifications run on Celery with a beat scheduler that wakes on an interval, polls the CTA prediction APIs for the saved lines, and decides whether anything is close enough to be worth a message.

The texting is the cheap trick of the project. Rather than paying for Twilio for a hackathon demo, texts go out through SMS-over-email gateways: every US carrier runs an email-to-SMS bridge (number@txt.att.net, @vtext.com, and others), so the app sends an email and the carrier delivers it as a text. Reliability is roughly what that suggests. It worked for the demo.

Running all of this in one place takes a Procfile with the Flask app under Gunicorn, the Celery worker, and the Celery beat scheduler, in the Heroku style, though during the hackathon it ran locally on a laptop in a Loyola classroom. Nothing crashed during the judging round.

The app is still buggy. The code is at the GitHub repo, and a demo video shows it working through a flow.