The Smart City Data Dashboard is a React web app that visualizes real-time environmental data β including weather and air quality β for any selected city using open public APIs. It uses Chart.js for interactive graphs and showcases how data-driven insights can help monitor and improve city conditions.
- Fetch real-time or publicly available Smart City data using APIs.
- Visualize metrics such as temperature, humidity, and air quality (PM2.5, PM10).
- Present data through an interactive dashboard with a clean and modern UI.
- (Bonus) Support multiple APIs and auto-refresh for live updates.
β Fetches real-time weather and air quality data β Displays key metrics like temperature, humidity, wind speed, and AQI β Visualizes trends using Chart.js (react-chartjs-2) β Responsive and user-friendly React UI β City selector to dynamically update data β (Bonus) Auto-refreshes every few minutes for live updates
| Category | Technology |
|---|---|
| Frontend Framework | React.js |
| Visualization | Chart.js + react-chartjs-2 |
| API Integration | Axios |
| Data Sources | OpenWeatherMap API (Weather), OpenAQ API (Air Quality) |
| Styling | CSS / TailwindCSS (optional) |
| Tools | Postman (for testing APIs), GitHub (for version control) |
| Data Type | API | Example Endpoint |
|---|---|---|
| π¦ Weather | OpenWeatherMap API | https://api.openweathermap.org/data/2.5/weather?q=Delhi&appid=YOUR_API_KEY&units=metric |
| π« Air Quality | OpenAQ API | https://api.openaq.org/v2/latest?city=Delhi |
smart-city-dashboard/
β
βββ src/
β βββ components/
β β βββ WeatherCard.js
β β βββ AirQualityCard.js
β β βββ ChartComponent.js
β β βββ CitySelector.js
β βββ App.js
β βββ App.css
β βββ index.js
β
βββ .env
βββ package.json
βββ README.md
git clone https://github.com/<your-username>/smart-city-dashboard.git
cd smart-city-dashboardnpm installGet a free API key from OpenWeatherMap and create a .env file:
REACT_APP_WEATHER_API_KEY=your_api_key_here
β οΈ Note: Restart the app after editing.envfor React to detect environment variables.
npm startApp runs at π http://localhost:3000
Fetches and displays real-time weather metrics:
- Temperature π‘
- Humidity π§
- Wind Speed π¬
Uses OpenAQ API to display:
- PM2.5, PM10, and overall AQI levels
- AQI status (Good / Moderate / Poor)
Renders interactive line/bar charts showing data trends over time using react-chartjs-2.
Dropdown to select a city dynamically β triggers re-fetch of all data.
import { Line } from 'react-chartjs-2';
const data = {
labels: ['9 AM', '12 PM', '3 PM', '6 PM', '9 PM'],
datasets: [
{
label: 'PM2.5 Levels (Β΅g/mΒ³)',
data: [45, 60, 72, 58, 49],
borderColor: 'rgba(75,192,192,1)',
fill: false,
},
],
};
<Line data={data} options={{ responsive: true }} />;"dependencies": {
"axios": "^1.7.0",
"chart.js": "^4.4.0",
"react": "^18.2.0",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18.2.0"
}Install manually if needed:
npm install axios chart.js react-chartjs-2πΉ Add auto-refresh every minute to update live readings πΉ Use multiple APIs (e.g., Weather + Air Quality + Traffic) πΉ Display AQI color status (green β red based on value) πΉ Add charts comparing multiple cities πΉ Integrate Leaflet.js map to show sensor locations
β Working with public REST APIs in React β Managing API keys with environment variables β Handling asynchronous requests using Axios β Building reusable components and props β Creating interactive data visualizations with Chart.js β Designing clean, responsive dashboards
--------------------------------------------
π Smart City Dashboard β Delhi
[City Selector βΌ]
π¦ Weather: 29Β°C | π§ Humidity: 62% | π¬ Wind: 3.4 m/s
π« Air Quality (PM2.5): 175 Β΅g/mΒ³ [Unhealthy]
π [Chart showing AQI trend over time]
--------------------------------------------
Aryan Singh π GitHub Profile π§ [your-email@example.com] π‘ Web Developer | Data Enthusiast | React Learner
The Smart City Data Dashboard demonstrates the power of open data and modern web technologies. It combines React.js, Chart.js, and real-time APIs to visualize urban metrics and provide valuable insights β making it an ideal project for developers exploring API integration and data visualization.