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.
- 23,140transfers into MiWay from another operator on one weekday, 18% of all taps
- 6operators named on those taps: Brampton, TTC, GO, Oakville and more
- 5 cardsthe smallest count that may leave an agency
- Nightlyone totals file per agency, under a published contract
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.
- 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_activitiesplus 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.
What crosses
One row of the nightly file.
| Column | Example | Note |
|---|---|---|
| service_date | 2024-09-04 | the calendar day |
| from_operator | TTC | from PRESTO's transfer flag |
| to_route | MiWay 101 | the agency's own route id, with its prefix |
| time_band | 06:00–09:00 | 3-hour band |
| transfers | 57 | distinct cards; rows under 5 are left out |
| median_wait_min | 9 | tap time minus the last from-operator arrival at that stop |
| share_wait_over_15 | 0.21 | share 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.
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.
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.
Reading it, left to right
- 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.
- 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.
- 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.
- One file crosses. The thick blue arrow: nightly totals, under MiWay's key, rows under 5 cards already dropped.
- 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.
- 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.
- Nothing exotic. Managed services only: no servers to patch, no models to train. Swap Glue for Databricks and the picture still holds.
- What this buys. An agency can join with a mill and a key, see exactly what leaves, and leave with everything it brought.
Chapter 5
Who owns what.
| Data | Lives | Key | Who may read | On leaving |
|---|---|---|---|---|
| Taps and cards | agency account | agency | the agency only | untouched |
| TIDES tables (stop visits, fare transactions) | agency account | agency | the agency; the region only by a question it answers in place | untouched |
| Nightly transfer totals | agency account, then the region's inbox | agency | the region, under a revocable grant | grant revoked: rows go dark; files deleted |
| Regional tables (six agencies added) | region account | each agency's rows under its own key | planners, journey view, through sign-in and the rule check | that agency's rows removed; table rebuilt |
| Public feed archive | region account | region | anyone with a contract; the agency itself | that agency's part deleted |
| Reports already received | agency | agency | the agency | kept |
- 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
| Choice | Chosen | Instead of | Why |
|---|---|---|---|
| How a transfer is found | PRESTO's flag, at home | Matching one card across agencies (trip chaining) | No card data crosses; the flag is already in every tap |
| How totals arrive | Nightly push under a contract | The region asks each agency on demand | A standing report; simpler and cheaper; asking stays for one-offs |
| Smallest count | 5 distinct cards | 10, or none | Standard small-cell suppression; 10 hid too much at fine grain |
| Where the adapter runs | In the agency's account, published by the region | Run by the region | Raw data never crosses; the agency pays about $6 a month |
| Platform | AWS-native: Glue, Athena, S3 with Iceberg | Databricks | Either reads the same Iceberg files; Databricks stays an option for an agency |
| Parties not on PRESTO | Shown as unknown | Estimated from docks near stops | Estimates 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.
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