Inspiration
Every MBTA subway car has a four-digit number printed inside it, and most riders never notice it. We wanted to make the daily commute into a collecting game: a Pokédex, but for the T. The hard part was making it cheat-proof. Anyone can type four digits, so the game had to know whether you were really on that train.
What it does
T-Dex is an iOS game for Boston subway riders. When you board a train, you type in the car number printed inside it. Our server accepts the catch only if its own log of the MBTA's live vehicle feed shows that car's train near your phone's location in the last few minutes.
- Coins by rarity: each car has a tier from Common to Legendary, worth 10 to 200 coins. Cars that run less often are rarer.
- The Dex: a collection of every car you've caught, line by line (Red, Orange, Blue, Green, Mattapan).
- Map: a station map showing which stations you've visited.
- Leaderboards: daily, weekly and all-time.
- Anti-cheat: every rejected catch gets a specific reason: unknown car, train not running, location too old, too far from the train, same train twice, duplicate, or moving impossibly fast between catches.
How we built it
- iOS app: Swift and SwiftUI (iOS 17), with MapKit for the station map, CoreLocation for GPS, and the Keychain for storing sign-in tokens.
- Backend: Python 3.12, FastAPI and Uvicorn, using psycopg 3 with plain SQL (no ORM). Login uses JWTs, and Sign in with Apple tokens are checked against Apple's public keys.
- Data: PostgreSQL with TimescaleDB. A feed logger streams the MBTA V3 vehicles API over server-sent events and stores one row per car per update, so the server keeps its own record of where every car has been.
- Rarity: an hourly job ranks cars within each line by how many minutes they've been in service. The car seen least on each line is Legendary.
- Deploy: Docker Compose for the database, with the API exposed over HTTPS through a Cloudflare tunnel so it works from a phone on cellular.
- Process: four people on four workloads (feed and rarity, catch API and anti-cheat, iOS app, collection and leaderboard), each on its own Git branch. A frozen API contract with example JSON let the iOS app run against mocks before the backend existed. We used Claude Code throughout, guided by a shared rulebook, and a script checked that no branch edited files owned by another team member.
Challenges we ran into
- Matching a person to a train: GPS and the MBTA feed don't line up perfectly. A train can leave a station a minute before your location updates, and coupled cars are only a few meters apart. We tested our verification rules against a recorded evening of real feed data, not just made-up cases.
- Raw feed data: car numbers have to be kept exactly as the feed gives them. For example, Blue Line cars have a leading zero (
07xx). We also had to guarantee that only one process ever writes the observation log. - One clock: to make replaying recorded data possible, every part of the catch and leaderboard code reads the time from the feed, never from the system clock. A test enforces this.
- Cross-platform teamwork: Windows and Mac line-ending differences broke 23 tests in a fresh clone until we forced LF line endings. We also had to keep a separate database for development and for production.
- Fair rarity on day one: with less than a day of data, we needed a ranking that still gave every line exactly one Legendary car.
Accomplishments that we're proud of
- Real catches accepted in production, verified against the live MBTA feed from a phone on cellular.
- 406 passing backend tests and a passing iOS test suite on the merged code. Each core rule (rejected catches pay nothing, coins exist only as ledger entries, a car's tier is locked in at catch time) has a test that fails if the rule breaks.
- Four people built in parallel and merged twice with almost no conflicts.
- A coin balance you can audit: a player's coins always equal the sum of their ledger entries, and our deploy check verifies that.
What we learned
- Checking that the data actually arrived (rows in the table, values read back through the API) catches far more bugs than checking that a command exited cleanly.
- A frozen API contract with example responses lets the frontend and backend move at full speed independently.
- Real transit data is messier than any test case we wrote, so recording it and replaying it was worth the effort.
- Clear file ownership and written rules made AI-assisted coding on a team practical.
What's next for T-Dex
- Tuning the anti-cheat thresholds from real gameplay data. Our sample so far is too small to set them.
- Fog of war on the map, daily and weekly quests, turf wars between lines, and cosmetics.
- Testing catches deep underground, where GPS is weakest.
- Commuter Rail and bus fleets, and possibly other transit systems.
Built With
- cloudflare
- fastapi
- postgressql
- python
- swift
- swiftui
- timescaledb