CASE STUDYFull-stack web app · civic tech

Fair-Fare

Check whether a CNG or bus driver is overcharging you, using official fare rates.

Live demo
Next.jsReactTypeScriptSupabasePostgreSQLRow-Level-SecurityGoogle-OAuthTailwind-CSS
01

Screenshots

02

The problem

In Dhaka, CNG auto-rickshaws and buses have government-set fares, but passengers have no quick way to check what a trip should cost. Fair Fare lets you pick a start and a destination on a map, shows the allowed fare and compares it with what the driver asked.
03

What it does

  • 01Fare calculator for CNG, bus and minibus based on official rates stored with effective dates and source links
  • 02Place search (Photon) and map tap; the real road route is drawn with OSRM
  • 03Driver comparison with a clear verdict: fair, slightly high or overcharged
  • 04Trip reports from signed-in users, with location rounded to about 110 m for privacy
  • 05Admin dashboard: moderation, CSV export and a form to add new fare rates without touching code
  • 06Bangla, mobile-first UI with Bangla numerals; accepts Bangla and English digits
  • 07Accessible: keyboard-navigable search, visible focus states, reduced-motion support
04

Architecture

Browser
  |  pick places (Photon) -> route + distance (OSRM)
  v
Next.js server components -- fare_rules (Supabase) --> calculateFare()
  |                                                         |
  |  reports (RLS: users see only their own)                v
  v                                                 fair fare + verdict
Admin area (is_admin() checked in the DB and every server action)
05

Engineering decisions

  • Fare rules are database rows, not code: a new gazette rate is a new row with an effective date.
  • calculateFare is a pure function with unit tests for base distance, minimum fare, waiting charge and invalid input.
  • Security lives in the database: RLS on every table and an is_admin() check re-verified in every admin server action.
06

Tech stack

Framework
Next.js (App Router, Cache Components), React, TypeScript
Styling
Tailwind CSS, custom CSS design tokens
Database + Auth
Supabase (Postgres, Row Level Security, Google OAuth)
Maps
Leaflet, react-leaflet, OpenStreetMap
Geo services
Photon (geocoding), OSRM (routing)
Testing
Vitest
Hosting
Vercel
  • Installable PWA with offline fare calculation
  • Fare estimate for rickshaws and vans, trained on community reports
  • Rate limiting on report submission
  • More cities and fare areas