> ## 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.

# Transport Modes

> Buses, local transport, and walking options in the MND system

## Overview

MND supports **three primary transport modes** that can be combined intelligently to create optimal multi-modal routes:

<CardGroup cols={3}>
  <Card title="Bus" icon="bus" color="#3b82f6">
    **Free** scheduled university buses
  </Card>

  <Card title="Local" icon="taxi" color="#f97316">
    **Paid** CNG/rickshaw transport
  </Card>

  <Card title="Walking" icon="person-walking" color="#22c55e">
    **Free** pedestrian movement
  </Card>
</CardGroup>

***

## 🚌 Bus Transport

### Overview

SUST operates **7 free bus routes** serving 19 locations across Sylhet city.

<AccordionGroup>
  <Accordion title="Bus Characteristics" icon="info">
    <ResponseField name="Cost" type="Free">
      University buses are **100% free** for students and staff
    </ResponseField>

    <ResponseField name="Schedule" type="Fixed">
      Buses run on **fixed schedules** with specific departure times:

      * Morning: 07:30 - 09:35
      * Afternoon: 13:10 - 17:10
      * Evening: 18:30 (limited routes)
    </ResponseField>

    <ResponseField name="Capacity" type="40-50 passengers">
      Standard bus capacity, can get crowded during peak hours
    </ResponseField>

    <ResponseField name="Speed" type="~5 min per stop">
      Average travel time between consecutive stops
    </ResponseField>
  </Accordion>

  <Accordion title="Route Coverage" icon="map">
    **7 Bus Routes:**

    * **Bus 1 & 2:** TILAGOR ↔ CAMPUS (via AMBARKHANA)
    * **Bus 3 & 4:** NAIORPUL ↔ CAMPUS (via JAIL\_RD)
    * **Bus 5:** LAKKATURA ↔ CAMPUS
    * **Bus 6:** NAIORPUL/SHAHI\_EIDGAH ↔ CAMPUS
    * **Bus 7:** SHEIKHGHAT/SHAHI\_EIDGAH ↔ CAMPUS

    **Key Hub Stops:**

    * AMBARKHANA (5 routes)
    * SUBIDBAZAR (6 routes)
    * CAMPUS (all routes)
  </Accordion>

  <Accordion title="Schedule Example" icon="calendar">
    **Bus 1 Schedule (Sample Day):**

    | Trip ID    | Direction    | Departure | Route            |
    | ---------- | ------------ | --------- | ---------------- |
    | bus1\_0825 | to\_campus   | 08:25     | TILAGOR → CAMPUS |
    | bus1\_0930 | to\_campus   | 09:30     | TILAGOR → CAMPUS |
    | bus1\_1310 | from\_campus | 13:10     | CAMPUS → TILAGOR |
    | bus1\_1710 | from\_campus | 17:10     | CAMPUS → TILAGOR |
  </Accordion>
</AccordionGroup>

### Data Model

<CodeGroup>
  ```typescript TypeScript Interface theme={null}
  export interface Route {
      route_id: string;      // "bus1", "bus2", etc.
      name: string;          // "Bus 1", "Bus 2", etc.
      trips: Trip[];         // List of scheduled trips
  }

  export interface Trip {
      trip_id: string;       // "bus1_0825"
      direction: 'to_campus' | 'from_campus';
      stops: string[];       // Node IDs in order
      departure_time: string; // "08:25" (HH:MM)
  }
  ```

  ```json JSON Example theme={null}
  {
    "route_id": "bus1",
    "name": "Bus 1",
    "trips": [
      {
        "trip_id": "bus1_0825",
        "direction": "to_campus",
        "stops": [
          "TILAGOR",
          "SHIBGONJ",
          "NAIORPUL",
          "KUMARPARA",
          "SHAHI_EIDGAH",
          "AMBARKHANA",
          "SUBIDBAZAR",
          "PATHANTULA",
          "MODINA_MARKET",
          "CAMPUS"
        ],
        "departure_time": "08:25"
      }
    ]
  }
  ```
</CodeGroup>

**Source:** `MND-backend/src/data/routes.json`

### Travel Time Calculation

Bus travel time is estimated using a **5-minute-per-hop** heuristic:

```typescript theme={null}
// From planner.ts:98-111
const hopsBefore = fromIndex;
const tripStart = parseTime(trip.departure_time);
const tripStartMin = timeToMinutes(tripStart);

// Estimate time to reach 'from' stop
const timeToFrom = hopsBefore * 5; // 5 min average per hop
const departureMin = tripStartMin + timeToFrom;

// Calculate travel time
const hops = toIndex - fromIndex;
const travelTime = hops * 5; // 5 min per stop
const arrivalTime = addMinutes(trip.departure_time, timeToFrom + travelTime);
```

<Info>
  The 5-minute estimate accounts for driving time + stop duration. Actual times may vary based on traffic.
</Info>

### Color Coding: Blue

In the mobile app, **bus segments are displayed in blue**:

```dart theme={null}
// Color mapping in Flutter app
Color getModeColor(String mode) {
  switch (mode) {
    case 'bus':
      return Colors.blue;      // 🚌 Bus routes
    case 'local':
      return Colors.orange;    // 🚕 Local transport
    case 'walk':
      return Colors.green;     // 🚶 Walking
    default:
      return Colors.grey;
  }
}
```

***

## 🚕 Local Transport (CNG/Rickshaw)

### Overview

**Local transport** refers to paid, on-demand options like CNG auto-rickshaws and cycle rickshaws.

<AccordionGroup>
  <Accordion title="CNG Auto-Rickshaw" icon="taxi">
    **Characteristics:**

    * 💰 **Cost:** 20-50 BDT (typically \~2 BDT per 100m)
    * ⚡ **Speed:** Moderate (faster than rickshaw, slower than bus)
    * 🛣️ **Range:** Short to medium distances (1-5 km)
    * 🚦 **Availability:** High (found everywhere in Sylhet)

    **When to Use:**

    * Final mile connectivity (after bus drop-off)
    * Destinations not served by buses
    * Urgent travel (no time to wait for bus)
  </Accordion>

  <Accordion title="Cycle Rickshaw" icon="bicycle">
    **Characteristics:**

    * 💰 **Cost:** 10-30 BDT (cheaper than CNG)
    * 🐌 **Speed:** Slow (human-powered)
    * 🛣️ **Range:** Very short distances (\< 2 km)
    * 🚦 **Availability:** High in residential areas

    **When to Use:**

    * Very short distances
    * Budget-conscious travel
    * Areas with narrow roads (CNG can't access)
  </Accordion>
</AccordionGroup>

### Data Model

<CodeGroup>
  ```typescript Edge Interface theme={null}
  export interface Edge {
      from: string;
      to: string;
      mode: 'bus' | 'local' | 'walk';
      route_ids?: string[];        // Only for bus edges
      time_min: number;            // Travel time in minutes
      distance_meters?: number;    // Physical distance
      cost: number;                // 0 for bus/walk, > 0 for local
      one_way: boolean;            // Directionality
      source?: 'graph' | 'distance_matrix';
  }
  ```

  ```json Graph Edge Example theme={null}
  {
    "from": "SUBIDBAZAR",
    "to": "HOSPITAL",
    "mode": "local",
    "time_min": 8,
    "distance_meters": 1500,
    "cost": 30,
    "one_way": false,
    "source": "graph"
  }
  ```

  ```json Distance Matrix Example theme={null}
  {
    "mode": "local",
    "submode": "driving",
    "from": "AMBARKHANA",
    "to": "LAKKATURA",
    "durationMin": 10,
    "distanceMeters": 2000,
    "cost": 40,
    "source": "distance_matrix"
  }
  ```
</CodeGroup>

### Cost Calculation

Local transport costs are estimated using a **distance-based formula**:

```typescript theme={null}
// From planner.ts:179
const costPerHundredMeters = 2; // BDT
const totalCost = Math.round(distanceMeters / 100) * 2;

// Example: 2000 meters = 20 × 2 = 40 BDT
```

<Warning>
  This is an **approximate cost model**. Actual fares may vary based on:

  * Negotiation with driver
  * Time of day (night surcharge)
  * Traffic conditions
  * Shared vs. private ride
</Warning>

### Distance Matrix Integration

When local transport segments are **not in the graph**, MND uses Google Maps Distance Matrix API:

```typescript theme={null}
// From distanceMatrixClient.ts
export async function getLocalSegment(
    from: string,
    to: string,
    mode: 'driving' | 'walking'
): Promise<DistanceMatrixResult> {
    // Check cache first
    const cacheKey = `${from}-${to}-${mode}`;
    const cached = this.cache.get(cacheKey);
    
    if (cached && !this.isCacheExpired(cached)) {
        return { ok: true, ...cached, fromCache: true };
    }
    
    // Call Google Maps API
    const response = await fetch(
        `https://maps.googleapis.com/maps/api/distancematrix/json?` +
        `origins=${from}&destinations=${to}&mode=${mode}&key=${API_KEY}`
    );
    
    const data = await response.json();
    const element = data.rows[0]?.elements[0];
    
    if (element?.status === 'OK') {
        const result = {
            distanceMeters: element.distance.value,
            durationSeconds: element.duration.value,
            timestamp: Date.now()
        };
        
        // Cache for 7 days
        this.cache.set(cacheKey, result);
        
        return { ok: true, ...result, fromCache: false };
    }
    
    return { ok: false, errorMessage: 'API call failed' };
}
```

### Color Coding: Orange

Local transport segments are displayed in **orange**:

```dart theme={null}
// Flutter route visualization
if (leg.mode == 'local') {
  return Container(
    decoration: BoxDecoration(
      border: Border.all(color: Colors.orange, width: 3),
      borderRadius: BorderRadius.circular(8),
    ),
    child: ListTile(
      leading: Icon(Icons.local_taxi, color: Colors.orange),
      title: Text('CNG/Rickshaw'),
      subtitle: Text('${leg.durationMin} min • ${leg.cost} BDT'),
    ),
  );
}
```

***

## 🚶 Walking

### Overview

**Walking** is used for very short distances between nearby locations.

<AccordionGroup>
  <Accordion title="Walking Characteristics" icon="person-walking">
    <ResponseField name="Cost" type="Free">
      Walking costs nothing
    </ResponseField>

    <ResponseField name="Speed" type="~4-5 km/h">
      Average walking speed (Google Maps standard)
    </ResponseField>

    <ResponseField name="Range" type="< 1 km">
      Only suggested for very short distances
    </ResponseField>

    <ResponseField name="Comfort" type="Weather-dependent">
      Not ideal during rain or extreme heat
    </ResponseField>
  </Accordion>

  <Accordion title="Use Cases" icon="compass">
    * **Between nearby stops:** SUBIDBAZAR ↔ RIKABI\_BAZAR (300m)
    * **Campus navigation:** Building to building
    * **Last 100 meters:** From bus stop to exact destination
  </Accordion>
</AccordionGroup>

### Data Model

<CodeGroup>
  ```typescript Walking Edge theme={null}
  {
    "from": "SUBIDBAZAR",
    "to": "RIKABI_BAZAR",
    "mode": "walk",
    "time_min": 4,
    "distance_meters": 300,
    "cost": 0,
    "one_way": false
  }
  ```

  ```typescript RouteLeg Format theme={null}
  {
    "mode": "walk",
    "from": "SUBIDBAZAR",
    "to": "RIKABI_BAZAR",
    "durationMin": 4,
    "distanceMeters": 300,
    "cost": 0,
    "source": "graph"
  }
  ```
</CodeGroup>

### Color Coding: Green

Walking segments are displayed in **green**:

```dart theme={null}
if (leg.mode == 'walk') {
  return Container(
    decoration: BoxDecoration(
      border: Border.all(color: Colors.green, width: 3),
      borderRadius: BorderRadius.circular(8),
    ),
    child: ListTile(
      leading: Icon(Icons.directions_walk, color: Colors.green),
      title: Text('Walking'),
      subtitle: Text('${leg.durationMin} min • ${leg.distanceMeters}m'),
    ),
  );
}
```

***

## Multi-Modal Routes

MND's power lies in **combining transport modes** intelligently:

### Example 1: Bus + Local

```mermaid theme={null}
graph LR
    A[TILAGOR] -->|Bus 1<br/>30 min<br/>FREE| B[AMBARKHANA]
    B -->|CNG<br/>10 min<br/>30 BDT| C[LAKKATURA]
    
    style A fill:#e0f2fe
    style B fill:#fef3c7
    style C fill:#e0f2fe
```

**Route Breakdown:**

<Steps>
  <Step title="Board Bus 1 at TILAGOR">
    Departure: 08:25 | Cost: 0 BDT
  </Step>

  <Step title="Ride bus for 30 minutes">
    Pass through: SHIBGONJ, NAIORPUL, KUMARPARA, SHAHI\_EIDGAH
  </Step>

  <Step title="Drop off at AMBARKHANA">
    Arrival: 08:55
  </Step>

  <Step title="Take CNG to final destination">
    AMBARKHANA → LAKKATURA (10 min, 30 BDT)
  </Step>
</Steps>

**Total:** 40 min | 30 BDT

### Example 2: Bus + Walk + Bus (Transfer)

```mermaid theme={null}
graph LR
    A[NAIORPUL] -->|Bus 3<br/>20 min| B[SUBIDBAZAR]
    B -->|Walk<br/>5 min| C[RIKABI_BAZAR]
    C -->|Bus 6<br/>15 min| D[CAMPUS]
    
    style A fill:#e0f2fe
    style B fill:#dcfce7
    style C fill:#dcfce7
    style D fill:#e0f2fe
```

**Route Breakdown:**

<Steps>
  <Step title="Board Bus 3 at NAIORPUL">
    08:30 departure
  </Step>

  <Step title="Ride to SUBIDBAZAR (20 min)">
    Free bus segment
  </Step>

  <Step title="Walk to RIKABI_BAZAR (5 min)">
    Short 400m walk between stops
  </Step>

  <Step title="Board Bus 6 at RIKABI_BAZAR">
    09:00 departure (5 min wait)
  </Step>

  <Step title="Arrive at CAMPUS (15 min)">
    Total journey: 40 min
  </Step>
</Steps>

**Total:** 40 min | 0 BDT

### Example 3: Local Only (Fallback)

```mermaid theme={null}
graph LR
    A[SHEIKHGHAT] -->|CNG<br/>25 min<br/>60 BDT| B[LAKKATURA]
    
    style A fill:#fee2e2
    style B fill:#fee2e2
```

**When Used:**

* ❌ No bus routes serve both locations
* ⏰ Late night (no buses running)
* 🚨 Emergency (can't wait for bus)

***

## Mode Selection Logic

How does MND decide which transport mode to use?

### Decision Tree

```mermaid theme={null}
graph TD
    Start([Route Planning Request]) --> Q1{Both locations<br/>served by bus?}
    
    Q1 -->|Yes| Strategy1["✅ Direct Bus<br/>(Strategy 1)"]
    Q1 -->|No| Q2{Origin served<br/>by bus?}
    
    Q2 -->|Yes| Strategy2["✅ Bus + Local<br/>(Strategy 2)"]
    Q2 -->|No| Q3{Common transfer<br/>point exists?}
    
    Q3 -->|Yes| Strategy3["✅ Bus Transfer<br/>(Strategy 3)"]
    Q3 -->|No| Strategy4["✅ Local Only<br/>(Strategy 4)"]
    
    Strategy1 --> Compare[Compare All Options]
    Strategy2 --> Compare
    Strategy3 --> Compare
    Strategy4 --> Compare
    
    Compare --> Result[Return Best 2-3 Routes]
    
    style Start fill:#e0f2fe
    style Strategy1 fill:#dbeafe
    style Strategy2 fill:#fef3c7
    style Strategy3 fill:#fce7f3
    style Strategy4 fill:#fee2e2
    style Compare fill:#f3e8ff
    style Result fill:#dcfce7
```

### Optimization Criteria

<Tabs>
  <Tab title="Fastest Route">
    Minimize **total journey time** including:

    * ⏰ Wait time for bus
    * 🚌 Bus travel time
    * 🚕 Local transport time
    * 🚶 Walking time

    **Formula:**

    ```typescript theme={null}
    totalTimeMin = waitTime + busTravelTime + localTravelTime + walkTime
    ```
  </Tab>

  <Tab title="Least Local">
    Minimize **paid transport time**:

    * ✅ Prefer free bus routes
    * ✅ Accept longer total time if it reduces cost
    * ✅ Maximize bus coverage

    **Formula:**

    ```typescript theme={null}
    localTimeMin = sum(leg.durationMin where leg.mode == 'local')
    ```
  </Tab>

  <Tab title="Weighted Score">
    For Bus + Local strategy, apply **penalty to local transport**:

    ```typescript theme={null}
    const LOCAL_PENALTY = 1.5;
    const score = waitTime + busTravelTime + (localTime * LOCAL_PENALTY);
    ```

    This ensures the algorithm **favors bus travel** over local transport, even if slightly slower.
  </Tab>
</Tabs>

***

## Transport Mode Statistics

### Network Coverage

<CardGroup cols={3}>
  <Card title="Bus Edges" icon="bus">
    **1,537 connections**

    50% of total graph edges
  </Card>

  <Card title="Local Edges" icon="taxi">
    **1,200 connections**

    39% of total graph edges
  </Card>

  <Card title="Walking Edges" icon="person-walking">
    **337 connections**

    11% of total graph edges
  </Card>
</CardGroup>

### Average Journey Composition

<Tabs>
  <Tab title="Morning Commute">
    **07:00 - 10:00 (to campus)**

    | Mode        | % of Routes | Avg Time | Avg Cost |
    | ----------- | ----------- | -------- | -------- |
    | Bus Only    | 45%         | 40 min   | 0 BDT    |
    | Bus + Local | 35%         | 35 min   | 25 BDT   |
    | Local Only  | 20%         | 25 min   | 60 BDT   |
  </Tab>

  <Tab title="Afternoon Return">
    **13:00 - 18:00 (from campus)**

    | Mode        | % of Routes | Avg Time | Avg Cost |
    | ----------- | ----------- | -------- | -------- |
    | Bus Only    | 50%         | 35 min   | 0 BDT    |
    | Bus + Local | 30%         | 30 min   | 20 BDT   |
    | Local Only  | 20%         | 20 min   | 50 BDT   |
  </Tab>

  <Tab title="Off-Hours">
    **18:00 - 07:00 (no buses)**

    | Mode       | % of Routes | Avg Time | Avg Cost |
    | ---------- | ----------- | -------- | -------- |
    | Local Only | 100%        | 25 min   | 70 BDT   |
  </Tab>
</Tabs>

***

## Visual Reference

### Transport Mode Icons

<CardGroup cols={3}>
  <Card title="Bus" icon="bus">
    🚌 Blue routes

    Free scheduled service
  </Card>

  <Card title="CNG" icon="taxi">
    🚕 Orange routes

    Paid on-demand
  </Card>

  <Card title="Walking" icon="person-walking">
    🚶 Green routes

    Free pedestrian
  </Card>
</CardGroup>

### Route Card Design (Flutter)

```dart theme={null}
// From mnd_flutter/lib/widgets/route_card.dart
Widget buildRouteLeg(RouteLeg leg) {
  final modeConfig = {
    'bus': {
      'icon': Icons.directions_bus,
      'color': Colors.blue,
      'label': 'Bus ${leg.routeId?.toUpperCase()}'
    },
    'local': {
      'icon': Icons.local_taxi,
      'color': Colors.orange,
      'label': 'CNG/Rickshaw'
    },
    'walk': {
      'icon': Icons.directions_walk,
      'color': Colors.green,
      'label': 'Walking'
    },
  }[leg.mode]!;
  
  return Container(
    padding: EdgeInsets.all(12),
    decoration: BoxDecoration(
      border: Border.all(color: modeConfig['color'], width: 3),
      borderRadius: BorderRadius.circular(8),
    ),
    child: Row(
      children: [
        Icon(modeConfig['icon'], color: modeConfig['color'], size: 32),
        SizedBox(width: 12),
        Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(modeConfig['label'], style: TextStyle(fontWeight: FontWeight.bold)),
            Text('${leg.from} → ${leg.to}'),
            Text('${leg.durationMin} min • ${leg.cost} BDT'),
          ],
        ),
      ],
    ),
  );
}
```

***

## API Response Example

Here's how transport modes appear in API responses:

```json theme={null}
{
  "from": "NAIORPUL",
  "to": "LAKKATURA",
  "requestTime": "08:30",
  "options": [
    {
      "label": "Fastest Route",
      "category": "fastest",
      "totalTimeMin": 45,
      "totalCost": 30,
      "legs": [
        {
          "mode": "bus",
          "route_id": "bus3",
          "from": "NAIORPUL",
          "to": "AMBARKHANA",
          "departure": "08:30",
          "arrival": "09:00",
          "durationMin": 30,
          "cost": 0,
          "source": "graph"
        },
        {
          "mode": "local",
          "submode": "driving",
          "from": "AMBARKHANA",
          "to": "LAKKATURA",
          "durationMin": 15,
          "distanceMeters": 2500,
          "cost": 30,
          "source": "distance_matrix"
        }
      ]
    }
  ]
}
```

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Graph Model" icon="project-diagram" href="/concepts/graph-model">
    See how transport modes connect 19 locations
  </Card>

  <Card title="Routing Algorithm" icon="route" href="/concepts/routing-algorithm">
    Learn how modes are combined optimally
  </Card>

  <Card title="API: Plan Route" icon="code" href="/api-reference/routes/plan-route">
    Try the routing API with different modes
  </Card>

  <Card title="Architecture" icon="diagram-project" href="/concepts/architecture">
    Understand the full system design
  </Card>
</CardGroup>
