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 MND backend is built with Node.js, TypeScript, and Express. It provides a graph-based routing engine with Google Distance Matrix API integration.Prerequisites
- Node.js 18+ and npm
- Git
- PM2 (for production)
- Google Distance Matrix API key
Installation
1. Clone and Navigate
2. Install Dependencies
express- Web frameworkcors- Cross-origin resource sharingdotenv- Environment variablesaxios- HTTP client for Google APIs
typescript- TypeScript compilertsx- TypeScript execution@types/*- Type definitions
3. Configure Environment
Copy the example environment file:.env with your configuration:
Building for Production
Compile TypeScript
The TypeScript compiler is configured intsconfig.json:
src/**/*.ts to dist/**/*.js with:
- Target: ES2022
- Module: CommonJS
- Source maps enabled
- Strict type checking
Verify Build
Running in Production
Option 1: Direct Node Execution
Option 2: PM2 Process Manager (Recommended)
Install PM2 globally:ecosystem.config.js):
PM2 Commands
Port Configuration
The server listens on port 3000 by default (configurable viaPORT env var).
Bind to all network interfaces:
The server is configured to listen on 0.0.0.0 for cross-device access:
Network Access
The server automatically detects and displays the network IP:Health Checks
Verify the server is running:API Endpoints
Full endpoint list:GET /api/health- Health checkGET /api/nodes- List all locationsGET /api/routes/list- List all bus routesGET /api/routes?from=X&to=Y&time=HH:MM- Plan a route
POST /api/auth/send-link- Send magic linkGET /api/auth/verify?token=X- Verify magic linkGET /api/profile- Get user profile
GET /api/favorites- List favoritesPOST /api/favorites- Add favoritePUT /api/favorites/:id- Update favoriteDELETE /api/favorites/:id- Delete favorite
GET /api/buses/upcoming?from=X- Upcoming busesGET /api/buses/schedule/:routeId- Route scheduleGET /api/routes/:routeId- Route details
Data Files
The graph data is loaded on startup from:Troubleshooting
Build Errors
Port Already in Use
Module Not Found
Cannot Access from Other Devices
- Check firewall settings
- Verify devices are on same network
- Use network IP (not localhost) from other devices
- Ensure server is binding to
0.0.0.0, not127.0.0.1
Production Checklist
- Environment variables configured
- Google Distance Matrix API key set
- TypeScript compiled successfully
- PM2 process running
- Health check endpoint responds
- Firewall allows port 3000
- PM2 configured for auto-restart on boot
- Log rotation configured
- Data files are up to date
- API quota monitoring enabled