Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ihfaz297/MND/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The RouteOption model represents a complete route from origin to destination, including all legs (bus, local transport, walking), timing, transfers, and cost information.

Type Definition

interface RouteOption {
  label: string;
  category: 'fastest' | 'least_local' | 'both';
  type: 'direct' | 'transfer' | 'local_only';
  transfers: number;
  totalTimeMin: number;
  totalCost: number;
  localTimeMin: number;
  localDistanceMeters: number;
  usesDistanceMatrix: boolean;
  legs: RouteLeg[];
}
Source: /home/daytona/workspace/source/MND-backend/src/core/types.ts:86-97

Fields

label
string
required
Human-readable label describing this route option.Examples:
  • "Fastest Route"
  • "Least Local Transport"
  • "Bus 1 + Local"
  • "Best Option"
category
string
required
Route category based on optimization goal.
type
string
required
Route structure type.
transfers
number
required
Number of bus-to-bus transfers required.
  • 0: Direct route or local only
  • 1: One transfer between buses
  • 2+: Multiple transfers (rare)
totalTimeMin
number
required
Total journey time in minutes, including:
  • Wait time for buses
  • Bus travel time
  • Local transport time
  • Walking time
  • Transfer time between buses
totalCost
number
required
Total cost in local currency (Bangladeshi Taka).
  • Bus rides: 0 (free university service)
  • Local transport (CNG/rickshaw): 15-50 BDT depending on distance
  • Walking: 0
localTimeMin
number
required
Time spent in paid local transport (CNG, rickshaw) in minutes.Used to differentiate routes that prefer free bus service over paid alternatives.
localDistanceMeters
number
required
Distance traveled via local transport in meters.May be 0 if distance data is not available or route uses only buses/walking.
usesDistanceMatrix
boolean
required
Whether this route used Google Distance Matrix API for calculations.
  • true: At least one leg used real-time distance/duration from Google
  • false: All calculations from pre-computed graph data
legs
RouteLeg[]
required
Array of route segments in order. See RouteLeg model.Each leg represents:
  • A bus ride between stops
  • A local transport segment
  • A walking segment

Examples

Direct Bus Route

Simplest case: single bus from origin to destination.
{
  "label": "Fastest Route",
  "category": "fastest",
  "type": "direct",
  "transfers": 0,
  "totalTimeMin": 50,
  "totalCost": 0,
  "localTimeMin": 0,
  "localDistanceMeters": 0,
  "usesDistanceMatrix": false,
  "legs": [
    {
      "mode": "bus",
      "route_id": "bus1",
      "trip_id": "bus1_0930",
      "from": "TILAGOR",
      "to": "CAMPUS",
      "departure": "09:30",
      "arrival": "10:20",
      "durationMin": 50,
      "cost": 0,
      "source": "graph"
    }
  ]
}

Bus + Local Transport

Combines bus ride with CNG/rickshaw to reach final destination faster.
{
  "label": "Bus 1 + Local",
  "category": "fastest",
  "type": "direct",
  "transfers": 0,
  "totalTimeMin": 46,
  "totalCost": 25,
  "localTimeMin": 6,
  "localDistanceMeters": 1200,
  "usesDistanceMatrix": false,
  "legs": [
    {
      "mode": "bus",
      "route_id": "bus1",
      "trip_id": "bus1_1710",
      "from": "SUBIDBAZAR",
      "to": "AMBARKHANA",
      "departure": "17:15",
      "arrival": "17:20",
      "durationMin": 5,
      "cost": 0,
      "source": "graph"
    },
    {
      "mode": "local",
      "submode": "driving",
      "from": "AMBARKHANA",
      "to": "CHOWHATTA",
      "durationMin": 6,
      "distanceMeters": 1200,
      "cost": 25,
      "source": "graph"
    }
  ]
}

Local Only Route

No bus available; uses only CNG/rickshaw and walking.
{
  "label": "Fastest Route",
  "category": "fastest",
  "type": "local_only",
  "transfers": 0,
  "totalTimeMin": 11,
  "totalCost": 20,
  "localTimeMin": 11,
  "localDistanceMeters": 0,
  "usesDistanceMatrix": false,
  "legs": [
    {
      "mode": "local",
      "from": "SUBIDBAZAR",
      "to": "RIKABI_BAZAR",
      "durationMin": 5,
      "cost": 20,
      "source": "graph"
    },
    {
      "mode": "walk",
      "from": "RIKABI_BAZAR",
      "to": "CHOWHATTA",
      "durationMin": 6,
      "cost": 0,
      "source": "graph"
    }
  ]
}

Transfer Route

Requires changing between bus routes.
{
  "label": "Bus 1 → Bus 3",
  "category": "least_local",
  "type": "transfer",
  "transfers": 1,
  "totalTimeMin": 65,
  "totalCost": 0,
  "localTimeMin": 0,
  "localDistanceMeters": 0,
  "usesDistanceMatrix": false,
  "legs": [
    {
      "mode": "bus",
      "route_id": "bus1",
      "trip_id": "bus1_0825",
      "from": "TILAGOR",
      "to": "SUBIDBAZAR",
      "departure": "08:25",
      "arrival": "08:50",
      "durationMin": 25,
      "cost": 0,
      "source": "graph"
    },
    {
      "mode": "bus",
      "route_id": "bus3",
      "trip_id": "bus3_0925",
      "from": "SUBIDBAZAR",
      "to": "CAMPUS",
      "departure": "09:25",
      "arrival": "09:50",
      "durationMin": 25,
      "cost": 0,
      "source": "graph"
    }
  ]
}

Category Selection Logic

The API returns multiple route options with different categories:

Fastest

Selected when totalTimeMin is minimal among all options.
{
  "label": "Fastest Route",
  "category": "fastest",
  "totalTimeMin": 25,
  "localTimeMin": 10
}

Least Local

Selected when localTimeMin is minimal (preferably 0).
{
  "label": "Least Local Transport",
  "category": "least_local",
  "totalTimeMin": 55,
  "localTimeMin": 0
}

Both

Selected when a route is both fastest AND uses least local transport.
{
  "label": "Best Option",
  "category": "both",
  "totalTimeMin": 30,
  "localTimeMin": 0
}

Cost Calculation

Bus Rides

Free university service:
{
  "mode": "bus",
  "cost": 0
}

Local Transport

Based on pre-configured costs in graph data:
{
  "mode": "local",
  "cost": 25,
  "durationMin": 6
}
Typical costs:
  • Short distance (< 2 km): 15-20 BDT
  • Medium distance (2-5 km): 25-35 BDT
  • Long distance (> 5 km): 40-50 BDT

Walking

Always free:
{
  "mode": "walk",
  "cost": 0
}

Time Calculation

Total Time Components

  1. Wait Time: Time until next bus departure
  2. Bus Time: Actual bus travel time
  3. Local Transport Time: CNG/rickshaw time
  4. Walking Time: Pedestrian time
  5. Transfer Time: Time between buses (if applicable)
totalTimeMin = waitTime + busTime + localTime + walkTime + transferTime

Example Calculation

Request at 08:15 for route with bus at 08:30:
Wait: 15 minutes (08:30 - 08:15)
Bus: 50 minutes (08:30 → 09:20)
Local: 6 minutes (CNG to final destination)

Total: 71 minutes

Distance Matrix Usage

When usesDistanceMatrix: true, at least one leg used real-time data:
{
  "usesDistanceMatrix": true,
  "legs": [
    {
      "mode": "local",
      "submode": "driving",
      "from": "TILAGOR",
      "to": "MEDICAL",
      "durationMin": 15,
      "distanceMeters": 3500,
      "cost": 40,
      "source": "distance_matrix"  // ← Google API used
    }
  ]
}
Distance Matrix results are cached. Check /api/health for cache statistics.

Validation

Required Fields

All fields are required in the response. Missing fields indicate a server error.

Constraints

  • transfers ≥ 0
  • totalTimeMin > 0
  • totalCost ≥ 0
  • localTimeMin ≤ totalTimeMin
  • localDistanceMeters ≥ 0
  • legs.length > 0

Type Validation

if (option.type === 'direct') {
  // Should have transfers = 0
  assert(option.transfers === 0);
}

if (option.type === 'local_only') {
  // Should have no bus legs
  assert(option.legs.every(leg => leg.mode !== 'bus'));
}

RouteLeg

Individual route segment

Route Response

Complete API response structure

Node

Location/stop information

Bus Schedule

Bus trip timing data

Build docs developers (and LLMs) love