Matching Engine
Pipeline
- Find journeys near the origin — coarse, index-backed pre-filter.
- Compare destination compatibility.
- Compare time windows.
- Check seats.
- Calculate route overlap and detour.
- Apply hard filters.
- Evaluate compliance.
- Score the remaining candidates.
- 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.
