A smart route planning application that helps users make environmentally conscious travel decisions by calculating and comparing carbon emissions across different transportation modes.
- ๐ About
- ๐ Links
- ๐งฎ Carbon Emission Calculations
- ๐ ๏ธ Tech Stack
- ๐ Project Structure
- ๐ Technical Requirements
- ๐ Getting Started (Local Hosting)
- ๐ฏ Usage
- ๐ก API Endpoints
- ๐ License
- ๐ Acknowledgments
Carbon Compass is an interactive web application that empowers users to reduce their environmental impact through informed transportation choices. Simply enter your origin and destination, and our app will show you multiple route options with their respective carbon footprints, helping you choose the most sustainable way to travel.
- Deployment
- Figma
- Multi-Modal Route Planning: Compare walking, cycling, public transit, and driving options
- Real-Time Carbon Calculations: See estimated COโ emissions for each transportation mode
- Interactive Map Interface: Visualize routes and make selections directly on the map
- Live Weather Integration: Real-time weather data powered by Open-Meteo API with automatic geolocation
- Trip Tracking: Track your journey in real-time with live location updates
- Responsive Design: Optimized for both desktop and mobile devices
- Dark Mode Support: Comfortable viewing in any lighting condition
Our carbon footprint calculations are based on established emission factors for different transportation modes:
| Transportation Mode | Emission Factor (g COโe/km) | Notes |
|---|---|---|
| Walking | 0 | No direct emissions |
| Cycling | 0 | No direct emissions |
| Public Transit | 89 | Average bus/train occupancy considered |
| Driving (Gasoline Car) | 210 | Based on average fuel consumption of 8.0L/100km |
For each route, we calculate emissions using:
Total Emissions (g COโe) = Distance (km) ร Emission Factor (g COโe/km)
Note: These estimates are for educational purposes and may vary based on actual vehicle efficiency, occupancy rates, and regional energy sources.
- React.js 19.2.0 with Vite 7.1.9 - Modern React development environment
- TailwindCSS v3.4.17 - Utility-first CSS framework for styling
- PostCSS 8.4.49 with Autoprefixer - CSS processing pipeline
- Google Maps JavaScript API - Interactive maps and route visualization
- Lucide React - Modern icon library
- Node.js with Express.js - Server-side JavaScript runtime and web framework
- Google Maps Directions API - Route calculation and distance data
- CORS - Cross-origin resource sharing support
- Open-Meteo API - Free, open-source weather forecasting (no API key required)
- OpenStreetMap Nominatim - Reverse geocoding for location names
- Browser Geolocation API - Automatic location detection
- Auto-refresh - Weather updates every 10 minutes
This project follows a monorepo structure with separate client and server applications, built with SOLID principles and modular architecture:
CarbonCompass/
โโโ ๐ client/ # Frontend React application
โ โโโ ๐ public/ # Static assets
โ โโโ ๐ src/
โ โ โโโ ๐ assets/ # Images and icons
โ โ โโโ ๐ constants/ # Configuration constants
โ โ โ โโโ index.js # Panel dimensions, breakpoints, API config
โ โ โโโ ๐ services/ # API service layer
โ โ โ โโโ apiService.js # Backend API calls
โ โ โ โโโ autocompleteService.js # Google Places API
โ โ โ โโโ geolocationService.js # Browser geolocation
โ โ โโโ ๐ hooks/ # Custom React hooks
โ โ โ โโโ useAutocomplete.js # Autocomplete with debouncing
โ โ โ โโโ useDirections.js # Route fetching logic
โ โ โ โโโ useLocalStorage.js # localStorage management
โ โ โ โโโ useRecentSearches.js # Recent searches logic
โ โ โ โโโ useResponsive.js # Responsive design utilities
โ โ โ โโโ useTripTracking.js # Real-time trip tracking
โ โ โ โโโ useWeatherData.js # Weather data fetching
โ โ โโโ ๐ components/ # Modular React components
โ โ โ โโโ ๐ ui/ # Shared UI primitives
โ โ โ โ โโโ SharedComponents.jsx
โ โ โ โโโ ๐ SearchPanel/ # Route search & planning
โ โ โ โ โโโ index.jsx
โ โ โ โ โโโ components/
โ โ โ โ โ โโโ LocationInput.jsx
โ โ โ โ โ โโโ MinimizedView.jsx
โ โ โ โ โ โโโ PredictionDropdown.jsx
โ โ โ โ โ โโโ RecentSearches.jsx
โ โ โ โ โ โโโ RouteCard.jsx
โ โ โ โ โโโ hooks/
โ โ โ โ โ โโโ useGeolocation.js
โ โ โ โ โ โโโ useSearchState.js
โ โ โ โ โโโ utils/
โ โ โ โ โโโ styleUtils.js
โ โ โ โโโ ๐ MapView/ # Google Maps integration
โ โ โ โ โโโ index.jsx
โ โ โ โ โโโ components/
โ โ โ โ โโโ ErrorDisplay.jsx
โ โ โ โ โโโ MapButton.jsx
โ โ โ โโโ ๐ RouteDetailsPanel/ # Step-by-step directions
โ โ โ โ โโโ index.jsx
โ โ โ โ โโโ components/
โ โ โ โ โ โโโ Header.jsx
โ โ โ โ โ โโโ StartButton.jsx
โ โ โ โ โ โโโ StepRenderer.jsx
โ โ โ โ โโโ utils/
โ โ โ โ โโโ routeUtils.js
โ โ โ โโโ ๐ RoutePolyline/ # Route visualization
โ โ โ โ โโโ index.jsx
โ โ โ โ โโโ polylineManager.js
โ โ โ โ โโโ usePolyline.js
โ โ โ โโโ ๐ WeatherPanel/ # Weather information
โ โ โ โ โโโ index.jsx
โ โ โ โ โโโ components/
โ โ โ โ โ โโโ Header.jsx
โ โ โ โ โ โโโ MetricCard.jsx
โ โ โ โ โ โโโ MinimizedView.jsx
โ โ โ โ โโโ utils/
โ โ โ โ โโโ weatherUtils.js
โ โ โ โโโ ๐ CarbonPanel/ # Carbon footprint tracking
โ โ โ โ โโโ index.jsx
โ โ โ โ โโโ components/
โ โ โ โ โ โโโ CarbonMetric.jsx
โ โ โ โ โ โโโ Header.jsx
โ โ โ โ โ โโโ MinimizedView.jsx
โ โ โ โ โ โโโ TotalSaved.jsx
โ โ โ โ โโโ utils/
โ โ โ โ โโโ metricConfig.js
โ โ โ โโโ ๐ LandingPage/ # Marketing landing page
โ โ โ โ โโโ index.jsx
โ โ โ โ โโโ Header.jsx
โ โ โ โ โโโ HeroSection.jsx
โ โ โ โ โโโ AboutSection.jsx
โ โ โ โ โโโ Footer.jsx
โ โ โ โโโ TripProgressPanel.jsx # Real-time trip progress
โ โ โ โโโ DirectionsComponent.jsx
โ โ โ โโโ GlassCard.jsx
โ โ โ โโโ MapView.jsx
โ โ โโโ ๐ styles/ # Styling configurations
โ โ โ โโโ darkMapStyles.js
โ โ โ โโโ lightMapStyles.js
โ โ โ โโโ responsive-panels.css
โ โ โโโ ๐ utils/ # Utility functions
โ โ โ โโโ decodePolyline.js
โ โ โ โโโ tripTrackingUtils.js
โ โ โโโ App.jsx # Main application component
โ โ โโโ main.jsx # React entry point
โ โ โโโ index.css # Global styles + Tailwind
โ โโโ tailwind.config.js # Tailwind CSS configuration
โ โโโ postcss.config.js # PostCSS configuration
โ โโโ vite.config.js # Vite build configuration
โ โโโ package.json
โ โโโ vercel.json
โ
โโโ ๐ server/ # Backend Node.js/Express application
โ โโโ ๐ src/
โ โ โโโ ๐ controllers/ # Route controllers
โ โ โ โโโ directions.js
โ โ โโโ ๐ middleware/ # Express middleware
โ โ โ โโโ validation.js
โ โ โโโ ๐ services/ # External service integrations
โ โ โ โโโ googleMaps.js
โ โ โโโ ๐ utils/ # Utility functions
โ โ โ โโโ errors.js
โ โ โโโ index.js # Server entry point
โ โโโ package.json
โ โโโ vercel.json
โ
โโโ ๐ demo_pic/ # Demo screenshots
โโโ .gitignore
โโโ LICENSE
โโโ README.md
- Layered Architecture: Components โ Hooks โ Services โ Constants
- SOLID Principles: Single responsibility, separation of concerns
- Modular Components: Each feature in its own folder with subcomponents
- Custom Hooks: Reusable business logic and state management
- Service Layer: Isolated API interactions (Google Maps, Geolocation, Backend)
- Tailwind CSS: Utility-first styling with custom configurations
- 67-87% Code Reduction: Achieved through refactoring and component reusability
Before running the project, ensure you have the following installed:
- Node.js v20
- npm v9
- Google Cloud Platform account with the following APIs enabled:
- Maps JavaScript API
- Directions API
- Places API
Clone the repository and install dependencies for both client and server:
# Clone the repository
git clone <repository-url>
# Install server dependencies
cd server
npm install
# Install client dependencies
cd ../client
npm installCreate .env files in both directories:
Server .env file (server/.env):
GOOGLE_MAPS_API_KEY=your_google_maps_api_key_hereClient .env file (client/.env):
VITE_GOOGLE_MAPS_API_KEY=your_google_maps_api_key_here
VITE_API_URL=http://localhost:3001You need to run both the server and client in separate terminals:
Terminal 1 - Start the Backend Server:
cd server
npm start
# For development with auto-reload:
# npm run devTerminal 2 - Start the Frontend Client:
cd client
npm run devThe application will be available at:
- Frontend: http://localhost:5173 (or the URL shown in your terminal)
- Backend API: http://localhost:3001
- Health Check: http://localhost:3001/api/health
Once both servers are running:
- Open the application in your browser (typically http://localhost:5173)
- Enter your starting location in the "From" field
- Enter your destination in the "To" field
- View route options with carbon emission calculations for each transportation mode
- Compare environmental impact and choose the most sustainable option
The backend provides the following API endpoints:
GET /api/health- Health check endpointGET /api/directions- Get route directions and carbon calculations
- Open-Meteo API:
https://api.open-meteo.com/v1/forecast- Weather data (no key required) - Nominatim API:
https://nominatim.openstreetmap.org/reverse- Reverse geocoding (no key required)
For detailed weather integration documentation, see WEATHER_INTEGRATION.md
This project is licensed under the MIT License - see the LICENSE file for details.
- Google Maps Platform for routing and mapping services
- Open-Meteo for free, open-source weather data (CC BY 4.0 license)
- OpenStreetMap contributors for geocoding services (ODbL license)
- Environmental data sources for emission factor calculations
- Open source community for the tools and libraries used
Carbon Compass - Making sustainable transportation choices easier, one route at a time. ๐ฑ


