Frontend Architecture - seojedaperez/IgnisMap GitHub Wiki

Frontend Architecture

This documentation describes the frontend architecture of the IgnisMap React application, including component hierarchy, state management patterns, routing structure, and Progressive Web Application (PWA) features.

Application Root Structure

IgnisMap is built as a single-page React application with a progressive user flow and lazy-loaded components 1 . The main application manages the user journey through three distinct phases: organization setup, zone configuration, and operational dashboard 2 .

graph TD
    App["App.tsx<br/>Main Application Root"] --> Router["React Router<br/>Route Management"]
    App --> ContextLayer["Context Providers Layer"]
    App --> StateManagement["Application State<br/>organizationConfig<br/>monitoringZones<br/>currentStep"]
    
    Router --> WelcomeRoute["/ Route<br/>Conditional Rendering"]
    Router --> BiodiversityRoute["/biodiversity Route<br/>BiodiversityAnalysis"]
    Router --> CatchAllRoute["/* Route<br/>Navigate to /"]
    
    WelcomeRoute --> WelcomeScreen["WelcomeScreen<br/>React.lazy()"]
    WelcomeRoute --> ZoneConfiguration["ZoneConfiguration<br/>React.lazy()"]
    WelcomeRoute --> EmergencyDashboard["EmergencyDashboard<br/>React.lazy()"]
    
    ContextLayer --> MicrosoftAIProvider["MicrosoftAIProvider<br/>AI Services Context"]
    ContextLayer --> EmergencyProvider["EmergencyProvider<br/>Emergency Data Context"]
    ContextLayer --> WeatherProvider["WeatherProvider<br/>Weather Data Context"]
    ContextLayer --> AlertProvider["AlertProvider<br/>Alert Management Context"]
    
    App --> LoadingSpinner["LoadingSpinner<br/>Suspense Fallback"]
    App --> AppInsights["appInsights<br/>Azure Application Insights"]
Loading

Context Provider Architecture

The application uses React Context to provide global state management across components 3 . Four main context providers wrap the entire application:

  • MicrosoftAIProvider: Azure AI services integration
  • EmergencyProvider: Emergency operations data
  • WeatherProvider: Weather data and forecasting
  • AlertProvider: Alert management and notifications

Component Hierarchy and Lazy Loading

The application implements code splitting through React's lazy loading mechanism to optimize initial page load performance 1 . Heavy components are loaded on-demand:

const WelcomeScreen = React.lazy(() => import('./pages/WelcomeScreen'))
const ZoneConfiguration = React.lazy(() => import('./pages/ZoneConfiguration'))
const EmergencyDashboard = React.lazy(() => import('./pages/EmergencyDashboard'))
const BiodiversityAnalysis = React.lazy(() => import('./pages/BiodiversityAnalysis'))

The loading component provides visual feedback during transitions 4 .

Navigation and Layout System

The application uses a responsive layout system with a unified navigation header that adapts to different screen sizes 5 . The Layout component provides consistent navigation:

Navigation Elements:

  • Dashboard (/) - Home icon
  • Mapa (/map) - MapIcon
  • Alertas (/alerts) - AlertTriangle
  • Clima (/weather) - Cloud
  • Biodiversidad (/biodiversity) - Leaf
  • Configuración (/settings) - Settings

The navigation system implements active state highlighting based on the current route 6 and full mobile support with hamburger menu 7 .

State Management and Data Flow

The application implements a hybrid state management approach combining local component state with React Context for global state. The main state variables include:

State Variable Type Purpose
organizationConfig OrganizationConfig | null Organization setup data
monitoringZones MonitoringZone[] Configured monitoring zones
currentStep 'welcome' | 'zone-config' | 'dashboard' User flow progress

TypeScript Interface Definitions

The application defines several key TypeScript interfaces:

OrganizationConfig

interface OrganizationConfig {
  name: string
  type: 'firefighters' | 'medical' | 'police' | 'civil_protection' | 'other'
  contactInfo: {
    phone: string
    radio: string
    email: string
  }
  capabilities: string[]
}

PWA Configuration

The application is configured as a PWA with the following features 8 :

  • Name: IgnisMap - Predicción de Incendios
  • Display mode: standalone
  • Theme: #dc2626 (ember red)
  • Icons: 192x192 and 512x512 PNG
  • Caching: Weather APIs and Azure Maps

Build Configuration and Optimization

The build system uses Vite with specific optimizations 9 :

Manual Chunks:

  • react-vendor: React core
  • ui-vendor: UI components (Lucide React)
  • map-vendor: Leaflet and map components
  • azure-vendor: Azure services
  • chart-vendor: Recharts
  • geo-vendor: Geospatial libraries

Styling and Theming

The application uses Tailwind CSS with a custom theme. The Ember color palette includes:

  • Navy: #41436A
  • Burgundy: #974063
  • Coral: #F54768
  • Peach: #FF9677

Custom component classes are defined for consistent styling across the application.

Core Dependencies

Main Dependencies 10 :

  • React 18.2.0: Main framework
  • React Router DOM: Routing
  • Azure SDK: Azure services integration
  • Leaflet: Interactive maps
  • Lucide React: Iconography
  • Recharts: Data visualization
  • Tailwind CSS: Styling framework

Notes

This frontend architecture is designed to be scalable, maintainable, and performance-optimized. The implementation of lazy loading, PWA features, and code splitting ensures fast load times, while the context architecture provides clean and predictable state management.

Wiki pages you might want to explore:

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