Skip to content

feat: Route Impact Score for route builder and community pages#17

Open
faizm10 wants to merge 11 commits into
mainfrom
feat/route-impact-score
Open

feat: Route Impact Score for route builder and community pages#17
faizm10 wants to merge 11 commits into
mainfrom
feat/route-impact-score

Conversation

@faizm10

@faizm10 faizm10 commented May 22, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #13.

Adds a Route Impact Score that evaluates every custom transit route across four dimensions and gives it an overall letter grade (A+ → F). The scorecard appears in two places:

  • Route Builder wizard — shown at the top of the review step, computed live from the current stops, schedule, and drawn geometry
  • Community post detail page — computed server-side from the stored routeData JSON and rendered between the map preview and action buttons

Scoring dimensions

Metric Weight How it's computed
Frequency 40% Best headway from schedule bands/frequency; ≤10 min = A+, ≤15 = A, ≤30 = C, etc.
Corridor length 25% Haversine sum of geometry (train) or stop-to-stop (bus); capped at 50 km = 100%
Service hours 20% Window parsed from banded/frequency schedule; ≥18 h/day = A+
Stop count 15% ≥12 stops = A+, ≥8 = A, ≥5 = B, etc.

New files

  • client/lib/routeScoring.ts — pure synchronous scoring engine, no external deps or fetches
  • client/components/RouteScorecard.tsx — dark-themed card with grade badge + color-coded progress bars

Also included

  • client/next.config.ts — Turbopack root: __dirname fix for the tailwindcss resolution error in monorepos (unrelated to scoring but caught in the same session)

Test plan

  • npm run build in client/ — clean (verified: no TS errors)
  • Open Route Builder → draw a train route with stops + a frequency schedule → advance to review → scorecard appears with correct grade
  • Change frequency interval from 15 → 60 min → grade drops from A → D instantly
  • Visit any /community/[id] post → scorecard renders between map and action buttons
  • Post with no schedule → F for frequency, rest of card still renders
  • routeData: null post → scorecard is skipped gracefully

🤖 Generated with Claude Code

faizm10 and others added 11 commits May 20, 2026 22:38
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Turbopack was picking up the wrong workspace root due to multiple
package-lock.json files in the repo. Setting `root: __dirname` in
next.config.ts pins it to the client/ directory.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements GitHub issue #13. A scorecard evaluates each custom route
across four weighted dimensions — frequency (40%), corridor length (25%),
service hours (20%), and stop count (15%) — and produces a letter grade
(A+ through F) displayed with color-coded progress bars.

- lib/routeScoring.ts: pure synchronous scoring engine; computes metrics
  from CustomRoute data (stops, geometry, schedule) with no external deps
- components/RouteScorecard.tsx: dark-themed card component with grade
  badge and per-metric progress bars, color-coded green → red by grade
- BuilderWizard.tsx: scorecard appears at the top of the review step,
  updating live as the user adjusts stops and schedule
- community/[id]/page.tsx: score computed server-side from stored
  routeData JSON and rendered between the map preview and action buttons

No DB schema changes required — scores are derived on-the-fly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented May 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
transit-flow Ready Ready Preview, Comment May 22, 2026 3:44pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Route Impact Score — Custom Route Planning Feedback

1 participant