Installation Guide
This guide will walk you through installing React Route Finder and setting up your development environment.Prerequisites
Before you begin, ensure you have the following installed on your system:React Route Finder requires Node.js and npm to run. Make sure you have at least Node.js 8.x or higher.
Required Software
- Node.js (v8.x or higher) - JavaScript runtime
- npm (v5.x or higher) - Package manager (comes with Node.js)
- Google Maps API Key - For map visualization features
Getting a Google Maps API Key
Go to Google Cloud Console
Visit Google Cloud Console
Installation Steps
1. Clone the Repository
2. Install Dependencies
Install all required npm packages:react(^16.3.2) - UI frameworkreact-dom(^16.3.2) - React renderingexpress(^4.16.3) - Web serverbabel-core(^6.26.3) - JavaScript transpilerbabel-loader(^7.1.4) - Webpack Babel integrationbabel-preset-env(^1.7.0) - Babel environment presetbabel-preset-react(^6.24.1) - Babel React presetwebpack(^4.8.3) - Module bundlerwebpack-cli(^2.1.4) - Webpack command line
concurrently(^3.5.1) - Run multiple commandsnodemon(^1.12.1) - Auto-restart server
The source code uses
node-fetch in ServerMockup.js but it’s not listed in package.json. You may need to install it manually:3. Configure Google Maps API
Openpublic/index.html and replace the API key in the Google Maps script tag:
YOUR_API_KEY_HERE with your actual Google Maps API key.
The current index.html contains a sample API key. You must replace it with your own key for the application to work properly.
4. Configure Backend Data Source
The application usesServerMockup.js to fetch bus stop data. By default, it expects a Laravel backend at http://localhost:8000/branch.
Open src/server/ServerMockup.js and configure your data source:
You can modify this function to return mock data or connect to a different API endpoint that provides bus stop information.
Project Structure
After installation, your project should have the following structure:Key Files Explained
Client Side:index.jsx- Main React app, handles route finding and map integrationRouteForm.jsx- Form component for entering start/end coordinatesResult.jsx- Displays step-by-step route instructionsLatLongFields.jsx- Reusable component for lat/long inputs
server.js- Express server with/routePOST endpoint and/allRoutesGET endpointFindLogic.js- Core pathfinding algorithm using distance calculationsServerMockup.js- Fetches bus stop data from external API
Verify Installation
Check that all dependencies are installed correctly:package.json without any errors.
Configuration Files
.babelrc
The project uses Babel to transpile modern JavaScript and JSX:webpack.config.js
Webpack bundles the application and splits vendor libraries for optimal loading.Troubleshooting
npm install fails
Port 8080 already in use
If port 8080 is occupied, modify the port insrc/server/server.js:
Google Maps not loading
Verify that:- Your API key is correctly configured in
public/index.html - The Maps JavaScript API and Directions API are enabled in Google Cloud Console
- Your API key has no restrictions that block localhost