Skip to content

Manas103/CrisisNavigator

Repository files navigation

AI Crisis Navigator

AI Crisis Navigator automatically monitors global disaster events, analyzes their severity using AI, and provides real-time visualization and recommendations for emergency response teams. The system processes data from NASA EONET, ReliefWeb, and GDACS, then uses Google Gemini AI to generate severity assessments and response guidance.

Features

  • Real-time Data Ingestion: Automatically fetches disaster events from NASA EONET API (every 10 minutes)
  • AI-Powered Analysis: Uses Google Gemini AI to analyze disasters and assign severity scores (1-10 scale)
  • Interactive Map: Leaflet-based map with color-coded markers showing disaster locations and severity
  • Live Updates: WebSocket-based real-time synchronization of disasters, statistics, and activities
  • Response Recommendations: AI-generated evacuation guidance, resource priorities, and immediate actions
  • Activity Feed: Real-time log of system events and disaster updates
  • Filtering & Search: Filter disasters by processing status and severity level
  • Bulk Processing: Process multiple unanalyzed disasters simultaneously

Technology Stack

Frontend

  • Framework: React 18 with TypeScript
  • Routing: Wouter for lightweight client-side routing
  • State Management: TanStack Query for server state management
  • UI Components: Radix UI primitives with shadcn/ui component library
  • Styling: Tailwind CSS with custom CSS variables for theming
  • Maps: Leaflet for interactive mapping with disaster visualization
  • Real-time: WebSocket connection for live data synchronization

Backend

  • Runtime: Node.js with Express.js server
  • Language: TypeScript with ES modules
  • API Design: RESTful endpoints with WebSocket support
  • Data Ingestion: NASA EONET API, ReliefWeb API, GDACS API
  • AI Processing: Google Gemini AI for disaster analysis
  • Database: PostgreSQL (Neon) with Drizzle ORM (currently using in-memory storage)

Build System

  • Frontend Build: Vite for fast development and optimized production builds
  • Backend Build: esbuild for server-side bundling
  • Development: tsx for TypeScript execution in development
  • Database Migrations: Drizzle Kit for schema management

Prerequisites

  • Node.js 20 or higher
  • npm or yarn package manager
  • PostgreSQL database (optional, currently using in-memory storage)
  • Google Gemini API key

Installation

  1. Clone the repository

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

    npm install
  3. Set up environment variables

    Create a .env file in the root directory with the following variables:

    # Required
    GEMINI_API_KEY=your_google_gemini_api_key
    GOOGLE_API_KEY=your_google_api_key  # Alternative to GEMINI_API_KEY
    
    # Optional - Database (currently using in-memory storage)
    DATABASE_URL=postgresql://user:password@host:port/database
    
    # Optional - Server Configuration
    PORT=5000
    NODE_ENV=development
    
    # Optional - AI Model Configuration
    GEMINI_MODEL=gemini-2.5-flash-lite
    
    # Optional - Data Ingestion
    DISASTER_MAX_AGE_DAYS=30
    ENABLE_RELIEFWEB=1
    ENABLE_GDACS=1
    RELIEFWEB_DAYS=30
    GDACS_DAYS=30
    RELIEFWEB_APPNAME=crisis-navigator-demo/0.1
  4. Set up database (optional)

    If you want to use PostgreSQL instead of in-memory storage:

    npm run db:push

Usage

Development Mode

Start the development server with hot reload:

npm run dev

The application will be available at http://localhost:5000

Production Build

Build the application for production:

npm run build

Start the production server:

npm start

Type Checking

Run TypeScript type checking:

npm run check

API Endpoints

REST API

  • GET /api/disasters - Get all disasters (filtered by max age)
  • GET /api/disasters/:id - Get a specific disaster by ID
  • GET /api/stats - Get system statistics
  • GET /api/activities - Get recent activities (limit query param)
  • POST /api/ingest - Manually trigger NASA data ingestion
  • POST /api/analyze - Manually trigger AI analysis processing
  • POST /api/process-all - Bulk process all unanalyzed disasters

WebSocket

Connect to /ws for real-time updates:

  • stats - System statistics updates
  • disasters - Disaster list updates
  • activities - Activity feed updates

Data Flow

  1. Data Ingestion: Periodic fetching from NASA EONET API (every 10 minutes)
  2. Data Processing: Events are normalized and stored
  3. AI Analysis: Gemini AI analyzes unprocessed events (every 30 seconds)
  4. Storage: Processed data and analysis results are persisted
  5. Real-time Distribution: WebSocket broadcasts updates to connected clients (every 15 seconds)
  6. Client Rendering: React components display interactive maps and analysis

Severity Scoring

Disasters are assigned severity scores on a 1-10 scale:

  • Low (1-3): Small, localized events with minimal impact
  • Medium (4-6): Events with measurable impact but under control
  • High (7-10): Major disasters requiring significant response (requires 2+ high-severity criteria)

High-severity criteria include:

  • 1+ confirmed fatalities
  • 1,000+ people displaced
  • Major infrastructure failure
  • Emergency declarations with external aid
  • Rapid uncontrolled escalation
  • Economic loss > $100M USD

Configuration

*Either GEMINI_API_KEY or GOOGLE_API_KEY must be set.

Youtube Hackathon Tutorial link

https://youtu.be/1mn8ucRLJmI

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published