TransitAI Core

Digital twin · anomaly detection · data architecture · planned

Tables, keys and rules.

Every table on the lineage picture, with what one row stands for, how it is keyed, how many columns it has, how its files are split, how long it is kept and under whose key. Then the joins that hold it together and the rules that keep it clean. The column lists themselves live on the picture: hover a table, or hold Shift for the entity-relationship view.

The tablesKeys and joinsQuality and privacy

Every table.

Grain, partitioning and retention are decision 56, proposed; the columns of the regional tables are decision 57, proposed. Retention figures already in a contract or a cost model are kept as they stand.

TableLayerShapeGrain: one row isKeysColumnsSplit byKeptWhose key
AVL stop times
the sample files
Sourcevendor CSV, ;-delimited, UTF-8 BOMone row per trip per stopCALENDAR_ID, TRIP_ID, ROUTE_ABBR, GEO_NODE_ABBR, GEO_NAME prefix26one file a monththe agency's ruleagency
APC counters
the sample files
Sourcevendor CSV, ;-delimited, UTF-8 BOM; first two columns in the opposite order to AVLone row per trip per stop; a visit may have severalCALENDAR_ID, TRIP_ID, ROUTE_ABBR, STOP_NUMBER, PATTERN_STOP_SEQUENCE18one file a monththe agency's ruleagency
Raw AVL export
the sample files
Bronzeas received, plus file and landing timeas receivednone imposed28by file and service daythe agency's rule; never leavesagency
Raw APC export
the sample files
Bronzeas received, plus file and landing timeas receivednone imposed20by file and service daythe agency's rule; never leavesagency
TIDES stop_visits
tested on the sample
SilverTIDES stop_visits (AVL skeleton, APC counts merged)service day × trip × stop sequenceservice_date, trip_id_performed, trip_stop_sequence; stop_id = GTFS stop17by service daythe agency's rule; the region never reads itagency
TIDES trips_performed
planned
SilverTIDES trips_performedservice day × tripservice_date, trip_id_performed; trip_id_scheduled = GTFS trip_id through the trip map17by service daythe agency's rule; never leavesagency
5-minute loads
replayed on the sample
GoldTIDES passenger_events, summed; five extras named in the contract (decision 60)route × direction × stop × 5-minute windowservice_date, route_id, direction_id, stop_id, window_start9sent every 5 minutes, within 224 hours on the laneregion, on arrival
GTFS timetables
already standard
SourceGTFS zip, as publishedone row per trip per stop (stop_times)trip_id, stop_id, stop_sequence; service_id carries the board period39by party and feed versionevery version the archive still coversnone, open
GTFS-Realtime feeds
already standard
SourceGTFS-Realtime protobuf, as each party publishes itone position per vehicle every 10 s; one trip update per tripparty, vehicle id, trip id, timestamp39polled every 10 snot stored as such; see the live lanenone, open
Live lane
planned
Bronzerecords as received (Kinesis Data Streams), two record kindsone record per position or per load rowparty_id, sequence_number29one shard per party24 hoursregion
TIDES vehicle_locations
planned
SilverTIDES vehicle_locations plus extrasone row per positionlocation_ping_id; party_id, service_date, vehicle_id, event_timestamp19by party and service day3 years, as costed; a leaver's part deleted at once, snapshots expiredregion
Timetables
already standard
SilverGTFS, unchanged, plus party and versionas GTFSparty_id, feed_version, then each file's own key42by party and feed versionwhile the archive covers itregion
Delay and load per route
replayed on the sample
GoldCloudWatch metrics; the band is the detector'sroute × direction × 5-minute window, one value per metricparty_id, route_id, direction_id, metric_name, timestamp11one series per route and direction63 days; cannot be deleted soonerregion
Last state per vehicle
planned
GoldDynamoDB items of two kinds: a vehicle, a counterone item per vehicle, overwritten; one per route and stop for the counterspk = party_id; sk = vehicle_id, or route_id and stop_id16by partyuntil overwritten; expires a day after the last sightingregion
Who is affected
planned
GoldDynamoDB item, built with Athenaparty × route × stop → neighbours and their sharepk = party_id; sk = route_id#stop_id10by partyreplaced nightlybuilt under each agency's key, by grant
Regional transfer table
planned
SourceIceberg table; the contract's row, with the party ids resolvedto-agency × from-party × route × date × 3-hour bandparty_id, from_party, service_date, to_route, time_band11by party (the to-agency) and service date3 years; a leaver's rows deleted, snapshots expired, reports rebuilteach agency's, by revocable grant
Registry
planned
SourceAurora tables: parties, contracts, shared_stopsone party; one contract version; one shared stop pairparty_id; contract_id; party_id, stop_id, neighbour_party22not partitionedwhile the region runs; a leaver's row marked left, kept for auditregion
Alerts
replayed on the sample
Outno TIDES home; the shape the contract names (DynamoDB alert log)one row per alert, open or clearedalert_id; party_id and month for the partition18by party and month13 months at the region; copies stay with receiversregion; each receiver's own
Live alert feed
planned
OutJSON over the APIthe open alerts a reader may seereader's party; allow-or-deny rules14per requestnot storedregion
Weather and events
planned
Sourcenot chosennot chosenplace and time6not chosennot chosennone, open

Tested: an exploration built the table from the real month. Replayed: the sample replay computed its values at route grain from the month's files. Standard: the shape is the published one already. Nothing is deployed. The column count links to the picture, where every column is listed with its type and key role.

Keys and joins.

Four identifiers carry every join in this use case. Each is written once in the sample's vendor form and once in the standard's.

KeyIn the vendor filesIn the standardLiveChecked
Service dayCALENDAR_ID, 1YYYYMMDD; times as seconds past midnight, past 86,400 after midnightservice_date; a timestamp per eventstart_date in the GTFS-Realtime trip5.45 M visits decoded, none rejected
Tripvendor TRIP_ID, never in GTFS trips.txt; 15,230 ids, each one timetable trip all monthtrip_id_performed → GTFS trip_id through the trip map, held in trips_performed.trip_id_scheduledtrip_id as the feed names it99.78% of 136,684 trip-days match one GTFS trip exactly, 99.97% within 60 s
Route and directionROUTE_ABBR; direction codes such as Noh, SohGTFS route_id through route_short_name; direction_id 0 or 1 from the timetable triproute_id, direction_idevery route-direction pair maps to one direction_id
StopGEO_NODE_ABBR (AVL), STOP_NUMBER (APC); repeated stops told apart by sequencestop_id = GTFS stop_id, which equals stop_code in this feedstop_id in the trip update; shared stops from the registry's crosswalk100% of visits find their GTFS stop
Windownonewindow_start: the departure time rounded down to 5 minutesthe same96% of 247,241 route-windows hold three or more visits
Partythe file is one agency'sa party id from the registry, on every regional rowthe feed address the registry holdsby contract: no registered party, no row

AVL and APC join to each other on service day, trip, route, stop and stop sequence; the four-column key alone collides on loop routes. Neither joins to GTFS on the trip id, which is why the trip map exists.

Quality and privacy rules.

The same rules the data contracts page states, written against the tables above. Each is also written into the step that applies it, on the picture.

On the way into Silver

  • Every row checked against the published TIDES schema: types, required fields, non-negative counts and dwell, enums, unique key.
  • Stop must exist in the party's GTFS; sequence must run 1, 2, 3 within a trip.
  • Duplicate counter records of one visit summed (20,077 visits in the sample); the string NULL becomes null.
  • Flagged, not rejected: load above capacity (2,251), visits with no observation (50,532).

While it runs

  • Feed gap, frozen vehicle, position jump, dead counter: the rules on the live lane (T8).
  • Loads late or off-contract: crowding alerts pause for that party; delay alerts carry on.
  • A window with fewer than three visits, or a party not sharing, shows unknown, never normal.
  • A new series alarms only after two weeks of history; a stale timetable check is still to be drawn.

Never

  • No fare card is read in this use case; loads are counts of people from door sensors.
  • No card serial or per-card record is written to the repo or the site (decision 16); the sample's fare file is not touched.
  • The one fare-derived input, transfer totals, is protected at home: rows under 5 cards dropped (decision 26); 10 proposed for other fare counts.
  • Alerts name a party, a route, a vehicle as its own feed names it, and a neighbour; never a rider.

Decided

  • Standards are the table shapes (4); raw data stays home (5); loads are counts with no minimum group size (21)
  • Live loads v1 and transfer totals v1 set the grain, cadence, custody and retention of what crosses (42, 55)
  • Metrics age out in 63 days; the archive is costed at 3 years

Open

  • Decision 56, proposed: grain, partitioning and retention of every other table as listed above
  • Decision 57, proposed: the columns of the regional tables
  • Decision 60, proposed: the live-loads contract names route, direction and visits as extras and on_board as the mean load over the window's visits, as the column-level pass found it must
  • Decision 61, proposed: the registry and the regional transfer table are the same tables, column for column, in both use cases
  • Whether 5-minute loads are also archived raw: the detailed picture writes every lane record to the archive, the contract keeps loads 24 hours
  • A TIDES home for alerts and for the summed loads; both are named extras for now
  • Weather and events: not sourced, not shaped

Caveats

  • Tested means the adapter prototype built stop_visits from one agency's month; trips_performed, the live lane, archive and state tables exist on paper only
  • Replayed values are at route grain from stop-level arrivals, not from positions; about 48 delay and 46 crowding alerts a weekday across {('gtfs', 'T2'): {'fs': 't', 'fo': -40, 'ts': 'b', 'via': [['y', 'gap:public:-30']], 'label': 'fetched when they change'}, ('gtfs', 'T6'): {'fs': 'r', 'ts': 't', 'via': [['x', 'x:T6']], 'label': 'when they change'}, ('rt', 'T5'): {'fs': 'r', 'ts': 't', 'via': [['x', 'x:T5']], 'label': 'every 10 s'}, ('T4', 'lane'): {'fs': 'b', 'fo': -20, 'ts': 't', 'via': [['y', 'top:region:1']], 'label': '5-minute loads, every 5 min, within 2'}, ('T5', 'lane'): {'fs': 'b', 'ts': 'l', 'via': [['y', 'row:region:0']]}, ('T6', 'timetables'): {'fs': 'b', 'ts': 'l', 'via': [['y', 'row:region:2']]}, ('registry', 'T5'): {'fs': 't', 'fo': 40, 'ts': 'b', 'tof': 30, 'via': [['y', 'row:region:0.5'], ['x', 'x:T5:30']], 'kind': 'ctl', 'label': 'which feeds'}, ('registry', 'T6'): {'fs': 't', 'fo': 70, 'ts': 'b', 'tof': -20, 'via': [['y', 'row:region:1.5'], ['x', 'x:T6:-20']], 'kind': 'ctl', 'label': 'which timetables'}, ('lane', 'T7'): {'fs': 'b', 'ts': 'l', 'via': [['y', 'row:region:1']]}, ('lane', 'T9'): {'fs': 'r', 'fo': 14, 'ts': 'l', 'tof': -12, 'via': [['x', 'colR:2:14']]}, ('timetables', 'T9'): {'fs': 'r', 'fo': -14, 'ts': 'l', 'tof': 12, 'via': [['x', 'colR:2:28']]}, ('timetables', 'T10'): {'fs': 'r', 'fo': 14, 'ts': 'l', 'tof': 14, 'via': [['x', 'colR:2:28']]}, ('registry', 'T10'): {'fs': 'r', 'fo': -14, 'ts': 'l', 'tof': -14, 'via': [['x', 'colR:0:20']]}, ('metrics', 'T11'): {'fs': 'r', 'ts': 'l', 'tof': 12, 'via': [['x', 'colR:3:28']]}, ('affects', 'T11'): {'fs': 'r', 'ts': 'b', 'tof': -30, 'via': [['x', 'colR:3:14']]}, ('weather', 'T11'): {'fs': 'r', 'ts': 't', 'tof': 24, 'via': [['x', 'colR:0:16'], ['y', 'gap:region:32'], ['x', 'x:T11:24']], 'label': 'a label, planned'}, ('T11', 'alerts'): {'fs': 'r', 'ts': 'l'}, ('alerts', 'T12'): {'fs': 'b', 'ts': 't'}, ('T12', 'feed'): {'fs': 'b', 'ts': 't'}, ('a_trips', 'T3'): {'fs': 'r', 'ts': 'l', 'tof': 14, 'via': [['x', 'colR:2:20']]}} routes
  • Vendor ids and formats are one agency's; a second vendor would need its own adapter mapping
  • The dead-counter rule at the region sees route and stop sums, so it flags a stop whose counter reads zero, not a vehicle; the vehicle-level check belongs at home

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