Skip to content

About

Turns raw city sensor data into a conversation — ask about pollution or congestion, get AI-driven fixes in seconds.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

UrbanSense — AI Smart City Advisor

UrbanSense is a full-stack environmental intelligence and municipal decision-support dashboard designed for urban planners, municipal authorities, and sustainability teams. The application integrates real-time air quality metrics, arterial traffic congestion modeling, and Google Gemini AI to synthesize cross-domain urban interventions.


Key Features

1. Spatial GIS Map & Sensor Visualization

  • Free OpenStreetMap Base Layer: Rendered with high-contrast, watermark-free OpenStreetMap tiles, requiring no third-party map API keys.
  • Air Quality Sensor Overlay: Interactive monitoring stations color-coded by EPA AQI categories (Good, Moderate, Sensitive, Unhealthy, Very Unhealthy, Hazardous).
  • Arterial Traffic Corridors: Polyline corridor overlays visualizing road speed, free-flow metrics, and congestion percentage (from clear greens to congested crimson).
  • Bi-directional Inspector: Clicking any map sensor or roadway focuses granular telemetry (PM2.5, NO₂, O₃, CO, SO₂, congestion %, average speeds, and active incident alerts).

2. Global City Explorer & Geocoding

  • Metropolitan Hub Strip: Quick-switch presets for global hubs including Los Angeles, New York, Chicago, San Francisco, London, Paris, Berlin, Delhi, Mumbai, Tokyo, Seoul, Singapore, Sydney, Toronto, and Dubai.
  • Search Any City Worldwide: Integrated geocoding modal powered by open Nominatim geocoding. Enter any municipality on Earth to dynamically generate localized coordinate grids, monitoring arrays, and traffic corridors.

3. Environmental Data & Dynamic Simulation

  • OpenAQ v3 Integration: Server-side proxy (/api/air-quality) that queries live monitoring stations around each city using the OpenAQ v3 API.
  • 12-Hour AQI Trend Chart: Visual history showing diurnal particulate fluctuations and peak pollution hours.
  • Real-Time Traffic Engine: Live simulation tick that periodically adjusts roadway congestion and traffic flow to mirror real-world commuting cycles.

4. AI Municipal Advisor (Gemini API)

  • Data-Grounded Reasoning: Supplies the AI model with comprehensive city telemetry snapshots (average AQI, peak particulate hotspots, corridor congestion percentages, and active incidents).
  • Multi-Model Failover: Configured with a resilient model sequence (gemini-3.1-flash-lite, gemini-3.8-flash, gemini-flash-latest) with timeout guards.
  • Continuous Availability: Includes a telemetry heuristic engine that ensures actionable mitigation strategies even during upstream network fluctuations.

Tech Stack

  • Frontend: React 18, TypeScript, Tailwind CSS, Lucide React, Leaflet (interactive maps)
  • Backend: Node.js, Express, Vite middleware mode, @google/genai (Google Gen AI SDK)
  • Geocoding & Tiles: OpenStreetMap, Nominatim API
  • Data Feeds: OpenAQ v3 REST API, Simulated Real-Time Traffic Telemetry

Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • npm or bun

Installation

  1. Clone or extract the repository:

    git clone <repository-url>
    cd urbansense
  2. Install dependencies:

    npm install
  3. Configure Environment Variables: Copy .env.example to .env and provide your API keys:

    cp .env.example .env
    # Required for AI advisor queries (Google AI Studio)
    GEMINI_API_KEY=your_gemini_api_key_here
    
    # Optional: For live global sensor stations (defaults to high-fidelity modeled data if omitted)
    OPENAQ_API_KEY=your_openaq_api_key_here
  4. Start Development Server:

    npm run dev

    The application runs on http://localhost:3000.

  5. Build for Production:

    yarn install && yarn build
    node dist/server.cjs

API Endpoints

  • GET /api/health: Health status and configured credentials telemetry.
  • GET /api/air-quality?lat=:lat&lng=:lng&city=:city: Proxies OpenAQ v3 API queries to retrieve live particulate observations near target coordinates.
  • POST /api/chat: Accepts { message, snapshot } payload and returns structured urban planning recommendations.

License

MIT License. Designed for civic innovation and smart city research.

About

Turns raw city sensor data into a conversation — ask about pollution or congestion, get AI-driven fixes in seconds.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages