Smart route planning that prioritizes environmental impact alongside traditional factors
Air Pollution Routing is a cutting-edge web application that revolutionizes route planning by considering environmental factors. Unlike traditional navigation apps that focus solely on distance and time, our platform optimizes routes based on air pollution exposure, carbon emissions, and energy efficiency.
- π― Multi-Objective Optimization: Balance distance, time, pollution, and emissions
- π Vehicle-Specific Routing: Tailored routes for cars and two-wheelers
- π Real-time Analytics: Comprehensive environmental impact metrics
- πΊοΈ Interactive Maps: Beautiful Mapbox-powered visualizations
- β‘ Modern Architecture: Built with React hooks and modular design
- Node.js (v20 or higher)
- yarn package manager
- Mapbox API Key
# Clone the repository
git clone https://github.com/clean-route/nextjs-client
cd nextjs-client
# Install dependencies
yarn install
# Set up environment variables
cp .env.example .env
# Edit .env with your API keys
# Start development server
yarn start
π That's it! Open http://localhost:3000 to see the app in action.
Feature | Car | Two Wheeler |
---|---|---|
Mass Range | 800-3000 kg | 100-300 kg |
Engine Types | Petrol, Diesel, CNG, EV | Petrol, Diesel, CNG, EV |
Condition | Age-based optimization | Age-based optimization |
| Route Type | π― Objective | π‘ Best For | |------------|--------------|----------|-------------| | Shortest | Minimize distance | Fuel efficiency | | Fastest | Minimize time | Time-sensitive trips | | LEAP | Minimize pollution exposure | Health-conscious users | | LCO2 | Minimize carbon emissions | Environmental impact | | Suggested | Balanced optimization | Recommended |
- Distance: Human-readable measurements (km, miles)
- Time: Accurate travel estimates with traffic
- Pollution Exposure: Air quality impact (ΞΌg/γ₯)
- Energy Consumption: Route efficiency (kJ)
- Step-by-step Navigation: Detailed turn-by-turn instructions
Our application follows modern React best practices with a clean, modular architecture:
graph TD
A[MapDrawer] --> B[RouteForm]
A --> C[RouteDetails]
B --> D[useInput Hook]
A --> E[useMap Hook]
A --> F[useRouteData Hook]
F --> G[RouteService]
G --> H[Backend API]
E --> I[Mapbox API]
src/
βββ π¦ components/ # React components
β βββ π― MapDrawer.js # Main application container
β βββ π RouteForm.js # User input form
β βββ π RouteDetails.js # Route information display
β βββ π§ Instruction.js # Navigation instructions
β βββ ποΈ useInput.js # Custom input hook
βββ πͺ hooks/ # Custom React hooks
β βββ πΊοΈ useMap.js # Map functionality
β βββ π useRouteData.js # Route data management
βββ π§ services/ # API and business logic
β βββ π£οΈ routeService.js # Route calculation service
βββ βοΈ constants/ # Configuration and constants
β βββ π index.js # Centralized constants
βββ π οΈ utils/ # Utility functions
βββ π getGeojson.js # GeoJSON conversion
βββ π getIconFromMode.js # Vehicle icons
βββ βοΈ getMassfromMode.js # Vehicle mass calculations
βββ π¨ getRouteColor.js # Route color mapping
- Select your vehicle type (Car or Two Wheeler)
- Enter vehicle mass within the specified range
- Choose vehicle condition based on age
- Select engine type (Petrol, Diesel, CNG, or EV)
- Shortest: For fuel efficiency
- Fastest: For time-sensitive trips
- LEAP: For health-conscious routing
- LCO2: For environmental impact
- Suggested: Recommended balanced approach
- All: Compare all route types
- Type source and destination addresses
- Use autocomplete for accuracy
- Click on map for precise locations
- View comprehensive route summary
- Expand details for in-depth analysis
- Review step-by-step instructions
- Compare multiple routes
# Required
REACT_APP_MAPBOX_API_KEY=your_mapbox_api_key
REACT_APP_SERVER_URL=http://localhost:8000/
# Optional
REACT_APP_GRAPHHOPPER_API_KEY=your_graphhopper_key
Vehicle Type | Mass Range | Default Mass | Mode Value |
---|---|---|---|
Car | 800-3000 kg | 2500 kg | driving-traffic |
Two Wheeler | 100-300 kg | 150 kg | scooter |
# Install dependencies
yarn install
# Start development server
yarn start
# Run tests
yarn test
# Build for production
yarn build
Our codebase follows modern React best practices:
- β Functional Components with hooks
- β Custom Hooks for reusable logic
- β Service Layer for business logic
- β Constants for configuration
- β Type Safety with consistent naming
# Run all tests
yarn test
# Run with coverage
yarn test --coverage
# Run in watch mode
yarn test --watch
Method | Endpoint | Description |
---|---|---|
POST |
/all-routes |
Get all route types |
POST |
/route |
Get single route |
{
"source": [longitude, latitude],
"destination": [longitude, latitude],
"delayCode": 0,
"mode": "driving-traffic",
"route_preference": "balanced",
"vehicle_mass": 2500,
"condition": "good",
"engine_type": "petrol"
}
{
"distance": 15000,
"time": 1800000,
"total_exposure": 45.2,
"total_energy": 1250.5,
"instructions": [...]
}
yarn build
- Netlify: Drag and drop
build
folder - Vercel: Connect GitHub repository
- AWS S3: Upload static files
- GitHub Pages: Use GitHub Actions
Ensure all required environment variables are configured in your hosting platform.
We welcome contributions! Here's how you can help:
- Check existing issues
- Create a new issue with detailed description
- Include steps to reproduce
- Describe the feature
- Explain the use case
- Discuss implementation approach
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
- Follow existing code structure
- Add appropriate documentation
- Ensure all tests pass
- Update constants for new features
- Maintain separation of concerns
This project is licensed under the GNU GPL-3 License - see the LICENSE file for details.
- Mapbox for mapping and geolocation services
- React Community for the amazing framework
- DaisyUI for beautiful UI components
- All contributors who made this project possible
Built with β€οΈ by the Air Pollution Routing Team