Skip to content

Matching Engine ​

Pipeline ​

  1. Find journeys near the origin — coarse, index-backed pre-filter.
  2. Compare destination compatibility.
  3. Compare time windows.
  4. Check seats.
  5. Calculate route overlap and detour.
  6. Apply hard filters.
  7. Evaluate compliance.
  8. Score the remaining candidates.
  9. Return explainable matches.

Steps 1–4 and 6 are hard filters. Step 5 is a measurement, not a filter — detour has to be computed before it can be compared against a threshold, which is why it sits ahead of the filter gate in execution order even though the threshold it feeds is a hard constraint.

Step 7 is the compliance gate. Only ALLOW candidates reach step 8.

Rejected candidates ​

Unverified, cancelled, full, restricted, time-incompatible, outside detour policy, prohibited geography, compliance-blocked.

Rejection reasons are recorded, not discarded. A candidate that was evaluated and rejected is evidence for a later review of why a particular request found nothing.

What is stored per candidate ​

  • component scores
  • overall score
  • detour metres, seconds, percentage
  • eligibility status
  • compliance status
  • algorithm version

algorithm_version is stored on every match so a scoring change can be attributed rather than inferred.

Performance ​

The spatial pre-filter must run before route recalculation. ST_DWithin against a point column is index-backed and cheap; ST_Distance against every route LineString is neither.

See PostGIS.

Explainability ​

Every match carries the factors that produced it. "Route compatibility 94%, 1.2 km additional, 4 minutes additional" is shown to the passenger. The internal compliance reason codes are not.

See Matches API.

KHAWI — same route, go together.