A modern, real-time monitoring dashboard for air quality, weather forecasts, and traffic density. Built with React, integrating multiple Google APIs, OpenWeatherMap, and Firebase Authentication.
- Features
- Tech Stack
- Screenshots
- Getting Started
- Environment Variables
- Project Structure
- API Integrations
- Available Scripts
- Deployment
- Contributing
- License
- Real-time monitoring of 6 key pollutants (PM2.5, PM10, NOβ, SOβ, Oβ, CO)
- EPA-standard AQI calculation with 6 health levels
- Interactive bar charts visualizing pollutant concentrations
- City search with Google Places autocomplete
- Color-coded health indicators (Good β Hazardous)
- Coordinates display for precise location tracking
- Current weather conditions (temperature, humidity, pressure, wind speed)
- 24-hour forecast with 3-hour intervals
- Detailed weather metrics (feels like, min/max temps, cloudiness)
- Weather icons from OpenWeatherMap
- City-based weather search with autocomplete
- Interactive Google Maps with real-time traffic layer overlay
- Route planning (Origin β Destination with autocomplete)
- Traffic analysis (duration, distance, traffic levels)
- Popular routes quick-select (4 pre-defined routes in Delhi)
- Traffic level indicators (Low/Moderate/High)
- Turn-by-turn directions visualization
- Multiple sign-in methods: Google OAuth, GitHub OAuth, Email/Password
- Secure session management with Firebase
- User profile display (name, email, photo)
- Password reset functionality
- Protected routes (redirects to login if not authenticated)
- Dark theme with neon accents
- Fully responsive (Mobile, Tablet, Desktop)
- Smooth animations and transitions
- Glassmorphism effects (backdrop blur)
- Card-based layouts with hover effects
- Modern gradient backgrounds
- React 19.2.0 - UI library
- React Router DOM 7.9.6 - Client-side routing
- Chart.js 4.5.1 - Data visualization
- react-chartjs-2 5.3.1 - React wrapper for Chart.js
- Axios 1.13.2 - HTTP client
- Vite 7.2.2 - Build tool & dev server
- Firebase Authentication - User authentication
- Google Maps JavaScript API - Maps & Places
- Google Air Quality API - Real-time air quality data
- OpenWeatherMap API - Weather data
- ESLint - Code linting
- Netlify - Deployment platform
Add your screenshots here
- Node.js (v16 or higher)
- npm or yarn
- Google Cloud Platform account (for API keys)
- Firebase project (for authentication)
- OpenWeatherMap API key
-
Clone the repository
git clone <repository-url> cd smart-city
-
Install dependencies
npm install
-
Set up environment variables Create a
.envfile in the root directory:VITE_GOOGLE_API_KEY=your_google_api_key_here
-
Configure Firebase
- Create a Firebase project at Firebase Console
- Enable Authentication (Google, GitHub, Email/Password)
- Copy your Firebase config and update
auth.htmlandsignup.html - Update the
firebaseConfigobject in both files
-
Start development server
npm run dev
-
Open in browser Navigate to
http://localhost:5173
Create a .env file in the root directory with the following:
VITE_GOOGLE_API_KEY=your_google_maps_api_keyRequired APIs to enable in Google Cloud Console:
- Maps JavaScript API
- Places API
- Directions API
- Distance Matrix API
- Air Quality API
Firebase Configuration:
Update auth.html and signup.html with your Firebase config:
const firebaseConfig = {
apiKey: "your-api-key",
authDomain: "your-project.firebaseapp.com",
projectId: "your-project-id",
storageBucket: "your-project.appspot.com",
messagingSenderId: "123456789",
appId: "your-app-id"
};OpenWeatherMap API:
The API key is currently hardcoded in WeatherPage.jsx. Consider moving it to environment variables for production.
smart-city/
βββ src/
β βββ pages/
β β βββ Dashboard.jsx # Main landing page
β β βββ Dashboard.css
β β βββ AQIPage.jsx # Air Quality monitoring
β β βββ AQIPage.css
β β βββ WeatherPage.jsx # Weather forecasts
β β βββ WeatherPage.css
β β βββ TrafficPage.jsx # Traffic & routes
β β βββ TrafficPage.css
β βββ components/
β β βββ SearchBar.jsx # City search component
β β βββ SearchBar.css
β β βββ AirQualityChart.jsx # Bar chart visualization
β β βββ PollutantMetrics.jsx # AQI & metrics display
β β βββ PollutantMetrics.css
β β βββ WeatherInfo.jsx # Weather display
β β βββ WeatherInfo.css
β βββ utils/
β β βββ googleMapsLoader.js # Google Maps API loader
β βββ App.jsx # Main app router
β βββ App.css # Global styles
β βββ main.jsx # Entry point
β βββ index.css # Base styles
βββ public/
β βββ _redirects # Netlify SPA routing
β βββ vite.svg
βββ auth.html # Login page
βββ signup.html # Signup page
βββ index.html # Main HTML template
βββ vite.config.js # Vite configuration
βββ netlify.toml # Netlify deployment config
βββ package.json
βββ eslint.config.js
βββ README.md
- Places API: City search and autocomplete
- Air Quality API: Real-time air quality data
- Directions API: Route calculation
- Distance Matrix API: Traffic duration analysis
- Traffic Layer: Visual traffic overlay
- Current Weather API: Real-time weather conditions
- 5-Day Forecast API: Weather predictions
- Authentication: User sign-in/sign-up
- Session Management: User session storage
# Start development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Lint code
npm run lint- Connect your repository to Netlify
- Configure build settings:
- Build command:
npm run build - Publish directory:
dist
- Build command:
- Add environment variables in Netlify dashboard:
VITE_GOOGLE_API_KEY
- Deploy! Netlify will automatically deploy on git push
The netlify.toml file is already configured for SPA routing.
-
Build the project:
npm run build
-
The
distfolder contains the production-ready files -
Upload to any static hosting service (Netlify, Vercel, GitHub Pages, etc.)
- Never commit API keys to version control
- Use environment variables for sensitive data
- Enable CORS restrictions in Google Cloud Console
- Set up API key restrictions in Google Cloud Console
- Use Firebase security rules for production
- Verify your API key is correct
- Check if all required APIs are enabled in Google Cloud Console
- Ensure API key restrictions allow your domain
- Verify Firebase configuration in
auth.htmlandsignup.html - Check if authentication methods are enabled in Firebase Console
- Verify domain is authorized in Firebase Console
- Check API quota limits
- Verify API keys are valid
- Check network connectivity
- Review browser console for detailed error messages
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Your Name
- GitHub: @yourusername
- Email: your.email@example.com
- React - UI library
- Vite - Build tool
- Chart.js - Data visualization
- Firebase - Authentication
- Google Maps Platform - Maps & APIs
- OpenWeatherMap - Weather data
β Active Development - Currently working on:
- Historical data tracking
- Multi-city comparison
- User preferences
- PWA support
Made with β€οΈ using React and Vite