System Design Atlas

Multimodal journey planning

06 / 10Worked example

The overall architecture

Imports and queries have separate runtimes. Which conditions ensure a valid result?

Validation of large timetables must not block the search.

Starting point Activation atomically swaps a pointer.

Assumptions for the example case

A fictional journey planner for buses, trains and walking routes in one region. Each response binds a timetable version and a real-time snapshot. The scope ends with journey information, without a booking commitment. All quantities, thresholds and operational objectives are illustrative assumptions.

Import and search in parallel

Import and search in parallel

Journey interfaceInformation
Journey information APIPin a snapshot
Search worker poolCalculate routes
Timetable graphImmutable generation
Real-time snapshotAppropriate status
Response cacheSnapshot + Preference
Import processValidate + Activate
Active pointerGeneration
Transport data providersExternal
Journey interface → Journey information APIQ-41
Journey information API → Active pointerAtomically pin the generation + real-time snapshot
Journey information API → Search worker poolPass the pinned snapshot
Search worker pool → Timetable graphRead generation
Search worker pool → Real-time snapshotRead matching snapshot
Search worker pool → Response cacheComplete key
Transport data provider → Import processTimetable + real-time data
Import process → Timetable graphNew immutable generation
Import process → Active pointerActivate generation atomically

The import activates a generation through an atomic pointer update; each request pins the graph and real-time snapshot before searching.

The import process writes graph generations; the API and search workers read them. The cache sits on the response path, and the provider is external.

Responsibilities within the application

Search worker modules

Route determinationCandidates
Transfer check300 s
Real-time matchingMatching snapshot
Result ranking4 Classes

Route finding, transfer checks, real-time matching and result ranking use the same snapshot.

Internal modules: Timetable import validates stops, services and time references. Journey search finds connected routes in the selected data version. Real-time matching associates changes with specific services. Result ranking orders valid alternatives and explains uncertainty. The overall architecture maps these responsibilities to runtime processes and datastores.

Runtime components and authoritative data

Runtime boundary
Journey interface → journey information API → search worker pool → immutable timetable graph and real-time snapshot. Transport data provider → import process; the import process writes a new graph generation and activates it through an atomic pointer update. The response cache stores only results keyed by the complete snapshot and preference set.
Module responsibilities
Timetable import validates stops, services and time references. Journey search finds connected routes in the selected data version. Real-time matching associates changes with specific services. Result ranking orders valid alternatives and explains uncertainty.

Imports and queries have separate runtimes.

Imports and queries have separate runtimes.

The import process and search worker write and read versioned artifacts respectively.

Validation of large timetables must not block the search.

Provider → import process → new graph generation → atomic activation pointer. API → search worker → pinned graph/real-time snapshot → response cache with a complete key.

Alternative considered
Import in the request process couples response time to data delivery.
Trade-off
Additional processes increase operating expenses.
Reassess
Very small datasets may allow import and search to share a process.

Try it yourself

Draw the write and read paths, including their datastores.

A hint for your attempt

Validation of large timetables must not block the search.

Compare with a possible solution
Write path
Provider → import process → new graph generation → atomic activation pointer.
Read path
API → search worker → pinned graph and real-time snapshot → response cache with a complete key.

Apply to your project

How does this principle apply in your own project: Imports and queries have separate runtimes.

Step 7: Exhausting the search budget does not prove that no route exists. Which conditions ensure a valid result?