System Architecture
React Route Finder is a full-stack JavaScript application that helps users find optimal bus routes between two geographic points. The application follows a client-server architecture with clear separation of concerns.Architecture Components
Frontend Layer
A React-based single-page application that provides the user interface for route input and visualization using Google Maps integration.
Backend Layer
An Express.js server that handles API requests and executes the route-finding algorithm.
Technology Stack
Frontend
- React - UI component library
- Google Maps JavaScript API - Map rendering and directions display
- Webpack - Module bundling and build system
- Babel - JavaScript transpilation
Backend
- Express.js - Web server framework
- Node.js - Runtime environment
- node-fetch - HTTP client for external API calls
Data Flow
The application follows a unidirectional data flow pattern:Request/Response Flow
Route Finding Request Flow
Route Finding Request Flow
- User Input: User enters origin and destination coordinates in the RouteForm
- API Call: React app sends POST request to
/routewith coordinates - Data Retrieval: Server fetches bus stops from Laravel backend
- Algorithm Execution: FindLogic processes all stops and finds optimal route
- Response: Server returns ordered array of bus stops
- Visualization: React app displays route on map and in text format
Key Design Patterns
Component-Based UI
The frontend uses React’s component-based architecture for modularity and reusability:App- Root component managing global stateRouteForm- User input collectionResult- Route displayLatLongFields- Coordinate input fields
RESTful API
The backend exposes RESTful endpoints:GET /allRoutes- Retrieve all available routesPOST /route- Calculate route between two points
Algorithm Encapsulation
Route-finding logic is isolated inFindLogic.js, making it:
- Testable independently
- Easily replaceable with alternative algorithms
- Reusable across different contexts
Build Process
The application uses Webpack to bundle the React application:The build process separates vendor code (React, etc.) from application code for better caching and performance.
Deployment Architecture
The application runs on a single Node.js server that:- Serves static files from the
/publicdirectory - Handles API requests on
/routeand/allRoutes - Listens on port 8080 by default
The ServerMockup currently points to a Laravel backend at
http://localhost:8000/branch. In production, this should be configured to point to the actual backend service.Next Steps
Explore the detailed architecture documentation:- Frontend Architecture - React component structure
- Backend Architecture - Express server implementation
- Route Algorithm - Pathfinding algorithm details