Alert System and Notifications - seojedaperez/IgnisMap GitHub Wiki

Overview

IgnisMap implements a comprehensive alert and notification system that provides real-time fire risk monitoring, weather-based alerts, and emergency response notifications. The system leverages Azure Cognitive Services for intelligent alert generation and provides multiple severity levels with customizable notification preferences. 2

graph TB
    subgraph "Alert Generation"
        AzureCognitive["Azure Cognitive Services"]
        WeatherAPI["Weather APIs"]
        SatelliteData["Satellite Data"]
        UserInput["User Configuration"]
    end
    
    subgraph "Alert Processing"
        AlertContext["AlertContext Provider"]
        AlertGeneration["Alert Generation Logic"]
        SeverityAssessment["Severity Assessment"]
    end
    
    subgraph "Alert Storage & Management"
        AlertState["Alert State Management"]
        AlertFiltering["Alert Filtering"]
        AlertActions["Alert Actions"]
    end
    
    subgraph "User Interface"
        Dashboard["Dashboard Metrics"]
        AlertsPage["Alerts Center"]
        NotificationSettings["Notification Settings"]
    end
    
    subgraph "Notification Delivery"
        InAppNotifications["In-App Notifications"]
        EmailNotifications["Email Notifications"]
        SystemAlerts["System Alerts"]
    end
    
    AzureCognitive --> AlertGeneration
    WeatherAPI --> AlertGeneration
    SatelliteData --> AlertGeneration
    UserInput --> AlertGeneration
    
    AlertGeneration --> SeverityAssessment
    SeverityAssessment --> AlertContext
    
    AlertContext --> AlertState
    AlertState --> AlertFiltering
    AlertFiltering --> AlertActions
    
    AlertContext --> Dashboard
    AlertContext --> AlertsPage
    AlertActions --> NotificationSettings
    
    NotificationSettings --> InAppNotifications
    NotificationSettings --> EmailNotifications
    NotificationSettings --> SystemAlerts
Loading

Alert Data Structure

The alert system uses a structured data model to represent different types of emergency notifications: 3

classDiagram
    class Alert {
        +string id
        +string title
        +string message
        +severity: low|medium|high|extreme
        +status: active|resolved
        +string location
        +string timestamp
        +boolean read
    }
    
    class AlertContextType {
        +Alert[] alerts
        +addAlert(alert) void
        +markAsRead(id) void
        +dismissAlert(id) void
    }
    
    Alert --> AlertContextType : managed by
Loading

Alert Severity Levels

The system implements four distinct severity levels with corresponding visual indicators and response protocols: 4

Severity Color Scheme Icon Use Case
Low Green Bell Normal conditions, informational updates
Medium Yellow Clock Moderate risk conditions requiring attention
High Orange Alert Triangle Dangerous conditions requiring immediate action
Extreme Red Alert Triangle Life-threatening conditions, emergency response
flowchart TD
    subgraph "Severity Assessment"
        WeatherData["Weather Conditions"]
        VegetationData["Vegetation Status"]
        HistoricalData["Historical Fire Data"]
        RealTimeData["Real-time Monitoring"]
    end
    
    subgraph "Risk Calculation"
        AIAnalysis["Azure AI Analysis"]
        RiskAlgorithm["Risk Assessment Algorithm"]
    end
    
    subgraph "Alert Classification"
        Low["Low Severity<br/>Informational"]
        Medium["Medium Severity<br/>Caution Required"]
        High["High Severity<br/>Immediate Action"]
        Extreme["Extreme Severity<br/>Emergency Response"]
    end
    
    WeatherData --> AIAnalysis
    VegetationData --> AIAnalysis
    HistoricalData --> AIAnalysis
    RealTimeData --> AIAnalysis
    
    AIAnalysis --> RiskAlgorithm
    RiskAlgorithm --> Low
    RiskAlgorithm --> Medium
    RiskAlgorithm --> High
    RiskAlgorithm --> Extreme
Loading

Alert Context Provider

The AlertProvider component manages the global alert state and provides methods for alert manipulation: 5

sequenceDiagram
    participant App as Application
    participant Provider as AlertProvider
    participant Context as AlertContext
    participant UI as User Interface
    
    App->>Provider: Initialize AlertProvider
    Provider->>Context: Create alert state
    Provider->>Provider: Generate mock alerts
    Provider->>Provider: Start periodic alert generation
    
    loop Every 30 seconds
        Provider->>Provider: Check for new conditions (30% chance)
        Provider->>Context: Add new alert if conditions met
        Context->>UI: Update alert displays
    end
    
    UI->>Context: User marks alert as read
    Context->>Provider: Update alert status
    Provider->>UI: Reflect changes in interface
Loading

Alert Generation Logic

The system includes intelligent alert generation that simulates real-world emergency conditions: 6

flowchart LR
    subgraph "Alert Generation Triggers"
        Timer["30-second Timer"]
        Probability["30% Probability Check"]
        Conditions["Weather Conditions"]
        Location["Geographic Location"]
    end
    
    subgraph "Alert Content Generation"
        SeverityPool["Severity Pool<br/>low|medium|high|extreme"]
        LocationPool["Location Pool<br/>Madrid|Barcelona|Valencia|Sevilla|Bilbao"]
        TitlePool["Title Pool<br/>Weather Alerts|Risk Updates|Forecasts"]
        MessageTemplate["Azure Cognitive Services Message"]
    end
    
    subgraph "Alert Creation"
        NewAlert["New Alert Object"]
        Timestamp["Current Timestamp"]
        UniqueID["Unique Alert ID"]
        UnreadStatus["Unread Status"]
    end
    
    Timer --> Probability
    Probability --> SeverityPool
    Probability --> LocationPool
    Probability --> TitlePool
    Probability --> MessageTemplate
    
    SeverityPool --> NewAlert
    LocationPool --> NewAlert
    TitlePool --> NewAlert
    MessageTemplate --> NewAlert
    
    NewAlert --> Timestamp
    NewAlert --> UniqueID
    NewAlert --> UnreadStatus
Loading

Dashboard Integration

The alert system integrates seamlessly with the main dashboard, providing real-time metrics and status indicators: 7

graph TB
    subgraph "Dashboard Alert Metrics"
        ActiveAlerts["Active Alerts Counter"]
        HighRiskAlerts["High Risk Alerts Counter"]
        AlertsDisplay["Alerts Display Component"]
    end
    
    subgraph "Alert Context Integration"
        AlertProvider["Alert Provider"]
        AlertState["Alert State"]
        AlertFilters["Alert Filtering Logic"]
    end
    
    subgraph "Visual Components"
        MetricCards["Metric Cards"]
        AlertIcons["Alert Icons"]
        StatusIndicators["Status Indicators"]
    end
    
    AlertProvider --> AlertState
    AlertState --> AlertFilters
    AlertFilters --> ActiveAlerts
    AlertFilters --> HighRiskAlerts
    
    ActiveAlerts --> MetricCards
    HighRiskAlerts --> MetricCards
    MetricCards --> AlertIcons
    MetricCards --> StatusIndicators
    
    AlertsDisplay --> MetricCards
Loading

Alerts Management Interface

The dedicated alerts page provides comprehensive alert management capabilities: 8

flowchart TD
    subgraph "Alert Filtering"
        StatusFilter["Status Filter<br/>all|active|resolved"]
        SeverityFilter["Severity Filter<br/>all|low|medium|high|extreme"]
        FilterLogic["Filter Logic"]
    end
    
    subgraph "Alert Statistics"
        ActiveCount["Active Alerts Count"]
        HighRiskCount["High Risk Count"]
        ResolvedCount["Resolved Count"]
        UnreadCount["Unread Count"]
    end
    
    subgraph "Alert Actions"
        MarkAsRead["Mark as Read"]
        DismissAlert["Dismiss Alert"]
        ResolveAlert["Resolve Alert"]
    end
    
    subgraph "Alert Display"
        AlertList["Alert List"]
        AlertCard["Individual Alert Cards"]
        AlertDetails["Alert Details"]
    end
    
    StatusFilter --> FilterLogic
    SeverityFilter --> FilterLogic
    FilterLogic --> AlertList
    
    AlertList --> ActiveCount
    AlertList --> HighRiskCount
    AlertList --> ResolvedCount
    AlertList --> UnreadCount
    
    AlertCard --> MarkAsRead
    AlertCard --> DismissAlert
    AlertCard --> ResolveAlert
    
    AlertList --> AlertCard
    AlertCard --> AlertDetails
Loading

Notification System

The notification system provides multiple channels for alert delivery with user-configurable preferences: 9

graph TB
    subgraph "Notification Types"
        FireAlerts["Fire Alerts<br/>High & Extreme Risk"]
        WeatherUpdates["Weather Updates<br/>Significant Changes"]
        SystemAlerts["System Alerts<br/>Maintenance & Updates"]
        EmailNotifications["Email Notifications<br/>Daily Summaries"]
    end
    
    subgraph "Notification Settings"
        UserPreferences["User Preferences"]
        ToggleControls["Toggle Controls"]
        NotificationState["Notification State"]
    end
    
    subgraph "Delivery Channels"
        InApp["In-App Notifications"]
        Email["Email Delivery"]
        SystemMessages["System Messages"]
        PushNotifications["Push Notifications"]
    end
    
    subgraph "Notification Logic"
        SeverityCheck["Severity Check"]
        UserOptIn["User Opt-in Check"]
        DeliveryLogic["Delivery Logic"]
    end
    
    FireAlerts --> SeverityCheck
    WeatherUpdates --> SeverityCheck
    SystemAlerts --> SeverityCheck
    EmailNotifications --> SeverityCheck
    
    UserPreferences --> ToggleControls
    ToggleControls --> NotificationState
    NotificationState --> UserOptIn
    
    SeverityCheck --> DeliveryLogic
    UserOptIn --> DeliveryLogic
    
    DeliveryLogic --> InApp
    DeliveryLogic --> Email
    DeliveryLogic --> SystemMessages
    DeliveryLogic --> PushNotifications
Loading

Alert Lifecycle Management

The system implements a complete alert lifecycle from generation to resolution: 10

stateDiagram-v2
    [*] --> Generated : Alert Created
    Generated --> Active : Alert Activated
    Active --> Read : User Views Alert
    Active --> Dismissed : User Dismisses
    Read --> Dismissed : User Dismisses
    Dismissed --> Resolved : Alert Resolved
    Resolved --> [*] : Alert Archived
    
    Active --> Active : Periodic Updates
    Read --> Read : Status Maintained
    
    note right of Generated : Timestamp assigned<br/>Unique ID created<br/>Severity assessed
    note right of Active : Visible in dashboard<br/>Triggers notifications<br/>Requires attention
    note right of Read : User acknowledged<br/>Visual indicator removed<br/>Still active
    note right of Dismissed : User action taken<br/>Status changed<br/>Ready for resolution
    note right of Resolved : Incident closed<br/>Historical record<br/>Analytics data
Loading

Integration with Azure Services

The alert system leverages Azure Cognitive Services for intelligent alert generation and analysis: 2

graph TB
    subgraph "Azure Integration"
        CognitiveServices["Azure Cognitive Services"]
        WeatherAPI["Weather Data APIs"]
        SatelliteData["Satellite Imagery"]
        AIAnalysis["AI Risk Assessment"]
    end
    
    subgraph "Data Processing"
        DataIngestion["Data Ingestion"]
        RiskCalculation["Risk Calculation"]
        AlertGeneration["Alert Generation"]
        ContentGeneration["Content Generation"]
    end
    
    subgraph "Alert System"
        AlertContext["Alert Context"]
        AlertStorage["Alert Storage"]
        AlertDelivery["Alert Delivery"]
    end
    
    CognitiveServices --> DataIngestion
    WeatherAPI --> DataIngestion
    SatelliteData --> DataIngestion
    
    DataIngestion --> RiskCalculation
    RiskCalculation --> AIAnalysis
    AIAnalysis --> AlertGeneration
    AlertGeneration --> ContentGeneration
    
    ContentGeneration --> AlertContext
    AlertContext --> AlertStorage
    AlertStorage --> AlertDelivery
Loading

Performance and Scalability

The alert system is designed for high performance with efficient state management and optimized rendering:

flowchart LR
    subgraph "Performance Optimizations"
        ReactContext["React Context"]
        StateManagement["Efficient State Management"]
        LazyLoading["Lazy Component Loading"]
        Memoization["React Memoization"]
    end
    
    subgraph "Scalability Features"
        AlertFiltering["Client-side Filtering"]
        PaginatedDisplay["Paginated Display"]
        PeriodicCleanup["Periodic Cleanup"]
        MemoryManagement["Memory Management"]
    end
    
    subgraph "Real-time Updates"
        PeriodicGeneration["30-second Generation Cycle"]
        StateUpdates["Automatic State Updates"]
        UIRefresh["UI Refresh Optimization"]
    end
    
    ReactContext --> StateManagement
    StateManagement --> AlertFiltering
    AlertFiltering --> PaginatedDisplay
    
    LazyLoading --> MemoryManagement
    Memoization --> UIRefresh
    
    PeriodicGeneration --> StateUpdates
    StateUpdates --> UIRefresh
Loading

Notes

The alert system in IgnisMap provides a comprehensive emergency notification framework with Azure integration, multiple severity levels, and user-configurable preferences. The system includes mock data generation for demonstration purposes and real-time alert simulation. 11 The tactical plans display component also includes alert-related risk warnings for extreme conditions. 12

⚠️ **GitHub.com Fallback** ⚠️