TransitAI Core

Digital twin · use case · offline

Transfer analysis.

How many riders change from one agency to another, where, when, and how long they wait. Counted inside each agency from a flag PRESTO already writes on the tap, so no card is ever matched across agencies. Only totals cross. Told as one story in seven chapters: an agency joins, data moves, the region adds up, an agency leaves.

Start the storyThe decisions behind it

Chapter 1

An agency joins.

Brampton Transit joins a region where TTC and MiWay are already in. Five steps, from a signature to the first file. Names are an illustration: no agency has agreed to anything.

The region publishes the adapter; the agency runs it in its own account and pays its small compute. The key never leaves the agency. Buildings from the MIT-licensed Age of AI project; see the credits.
What a contract shows
Name and version · purpose · table shape (TIDES, plus any extra columns) · cadence and deadline · privacy rule · who may read it · what you receive back · retention · what happens on leaving
This one
transfer totals v1: TIDES station_activities plus the from-operator, the route, the distinct-card count, median wait and share over 15 minutes; nightly by 06:00; rows under 5 distinct cards dropped; readers are regional planners and the journey view; back come the public arrivals archive and the regional report

Chapter 2

How it works: four lanes.

Press Play to follow a transfer from a TTC tap to the regional report, or tap a step below the picture. Highlighted arrows are the only places anything crosses an account border. Each step names the general part and the recommended AWS service beside it.

Taps and cards stay in MiWay's account. The region holds public arrivals and the added-up totals.

What crosses

One row of the nightly file.

ColumnExampleNote
service_date2024-09-04the calendar day
from_operatorTTCfrom PRESTO's transfer flag
to_routeMiWay 101the agency's own route id, with its prefix
time_band06:00–09:003-hour band
transfers57distinct cards; rows under 5 are left out
median_wait_min9tap time minus the last from-operator arrival at that stop
share_wait_over_150.21share who waited more than 15 minutes

In the sample: 1,352 from-operator × route × band cells on 4 September; 28% of cells but 1.1% of transfers fall under 5 taps. Parties not on PRESTO, like Bike Share, show as unknown. A file late or missing by 06:00 raises an alarm; the report runs at 06:30 with what has landed and shows that agency as unknown.

On the real month

Sample transfer analysis.

MiWay's half of the regional analysis, run on the September 2024 sample exactly as the contract says: 20,233 riders a weekday arrive from another operator; Brampton in the morning, TTC and GO in the evening; Kipling the crossing point.

Open the sample analysis

Chapter 3

Data life: bronze, silver, gold, town by town.

The region as a small world: each agency a town, roughly where it really is, with distances stretched. Each full sharer refines its own data at home: bronze is the raw file, silver the TIDES table, gold the totals. Only gold crosses to the hall; the hall's own bronze is the public feeds. Press ? for the legend, ⛶ for full screen.

A bird is a public feed; a padlocked cart is a nightly file under the agency's key. Bike Share has a feed only, so a hut and no coins.

Chapter 4

The architecture: what runs where.

Every part, with AWS's own icons, accounts as boxes. Blue arrows are the only crossings. The shared parts are drawn because every use case is costed with them.

Transfer analysis architecture: TTC's open feed archived by the region; MiWay translating, counting and pushing nightly totals under its key; the region checking, adding up and serving, with sign-in, rule check, registry, audit, keys and monitoring beside.
Services are recommendations, not settled. Open the image for full size.

Reading it, left to right

  1. Three AWS accounts, one picture. Each party has its own locked room in the cloud. TTC is a full sharer with its own mill and nightly file, but this story follows a MiWay tap, so only TTC's public feed appears. MiWay owns everything about its riders. The region owns the exchange and nothing about a rider.
  2. Inside MiWay, bronze to gold. Raw files land as they are, become TIDES tables, become totals. All of it inside MiWay's account; the card id is hashed there to count riders and never leaves.
  3. The public arrivals come back the other way. The region archives every public feed and derives arrivals at each stop, on stop ids every agency shares. MiWay reads TTC's arrivals and the stop crosswalk in place, through a grant, to work out the waits.
  4. One file crosses. The thick blue arrow: nightly totals, under MiWay's key, rows under 5 cards already dropped.
  5. At the region: inbox, check, add, serve. The contract check is a function; the add-up a nightly job; each agency's rows stay under its own key inside the regional table, which the region reads only through a grant the agency can revoke; queries and a JSON report behind sign-in.
  6. The shared parts. Sign-in, rule check, registry, audit, keys and monitoring: the exchange's running costs, included in every use case's bill so the figure stands alone.
  7. Nothing exotic. Managed services only: no servers to patch, no models to train. Swap Glue for Databricks and the picture still holds.
  8. What this buys. An agency can join with a mill and a key, see exactly what leaves, and leave with everything it brought.

Every service, every connection

Interactive detailed architecture.

The same picture in full: thirty-one services with their roles, every connection labelled with what flows on it, and the Databricks alternatives marked. Hover a component and only its links stay lit.

Open the interactive architectureStill picture

Chapter 5

Who owns what.

DataLivesKeyWho may readOn leaving
Taps and cardsagency accountagencythe agency onlyuntouched
TIDES tables (stop visits, fare transactions)agency accountagencythe agency; the region only by a question it answers in placeuntouched
Nightly transfer totalsagency account, then the region's inboxagencythe region, under a revocable grantgrant revoked: rows go dark; files deleted
Regional tables (six agencies added)region accounteach agency's rows under its own keyplanners, journey view, through sign-in and the rule checkthat agency's rows removed; table rebuilt
Public feed archiveregion accountregionanyone with a contract; the agency itselfthat agency's part deleted
Reports already receivedagencyagencythe agencykept
The trade-off we accepted
No report is hostage to one key, but a KMS grant has no built-in expiry (the retention date sits in the key policy or an automated revoke), every query needs every agency's key reachable, and a revoked key breaks queries that touch those files until they are removed. Athena, Glue and Databricks all read S3 files under cross-account keys.
Going dark, exactly
Revoking the grant blocks the stored rows at once. An off-boarding run then deletes them, expires old table snapshots and purges cached reports. Reports already downloaded cannot be recalled.
The card id
Read only inside the agency, hashed, used to count distinct riders for the 5-card rule, and never written to anything that leaves.
Decisions
3, 25 to 28, 37, 41 to 43, 48 to 50

Chapter 6

What it costs: cloud only.

This use case on its own, on the seven-party scenario, at AWS list prices. The front door, sign-in, rule check, registry, audit, keys and monitoring are included in full, so the figure stands alone.

Whole region, per year
$2.2k low · $2.6k typical · $4.3k high
The region's share
$2.2k a year, typical; most of it the shared parts
One full agency
$71 a year, typical: a ten-minute job a night and a key
Feed-only party
$0
Scenario
TTC, MiWay, Brampton, YRT, Durham, GO as full sharers; Bike Share Toronto feed-only; 4,559 road vehicles
Source
explorations/dt-cost/model.py, prices imported from the earlier cost models

Trade-offs

ChoiceChosenInstead ofWhy
How a transfer is foundPRESTO's flag, at homeMatching one card across agencies (trip chaining)No card data crosses; the flag is already in every tap
How totals arriveNightly push under a contractThe region asks each agency on demandA standing report; simpler and cheaper; asking stays for one-offs
Smallest count5 distinct cards10, or noneStandard small-cell suppression; 10 hid too much at fine grain
Where the adapter runsIn the agency's account, published by the regionRun by the regionRaw data never crosses; the agency pays about $6 a month
PlatformAWS-native: Glue, Athena, S3 with IcebergDatabricksEither reads the same Iceberg files; Databricks stays an option for an agency
Parties not on PRESTOShown as unknownEstimated from docks near stopsEstimates would be guesses

Chapter 7

An agency leaves.

The mirror of joining. Brampton revokes its key and its rows go dark at once; the region deletes and rebuilds; Brampton keeps everything it has.

Transfers to and from a party that left show as unknown, like any party not sharing.

Decided

  • Decisions 24 to 28, 33 to 39, 41 to 44: see the decisions page

Open

  • Whether 5 distinct cards also replaces 10 for other fare counts
  • A TIDES home for transfer totals: proposed, not in the standard

Caveats

  • One agency's sample, one month; wait times not yet computed on it
  • Nothing deployed; costs are a design estimate, not a quote
  • PRESTO's flag names the operator, not the vehicle or the stop of the previous tap

↑ ↓ to move · ↵ to open · esc to close