# hrpofficial736/resq architecture

> Architecture diagram of the GitHub repository hrpofficial736/resq, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hrpofficial736/resq
- Repository: https://github.com/hrpofficial736/resq

## Overview

##### Project type and purpose
- This is a Flutter mobile application (“resq”) focusing on emergency response: showing weather, air-quality, recent alerts, shelters on map, SOS button, reporting feature, and emergency contacts.
- It follows a feature-driven modular structure with clear separation between UI (presentation), state management (providers), domain/use-cases, data/repositories, models, and network services.

##### File structure
- Top-level Flutter project: android/, lib/, test/, pubspec.yaml, etc.
- lib/ core folders:
- features/ – one folder per feature (home, alerts, emergency, report, shelters, splash). Each feature has subfolders: data/models, domain/use-cases, presentation/screens & widgets.
- providers/ – Riverpod/Provider classes coordinating UI and business logic (e.g., weather_provider.dart).
- services/ – API clients for external services (weather_api_service.dart, air_quality_api_service.dart, location_api_service.dart) and a generic network_client.dart.
- main.dart – application entry, sets up routing and providers.

##### README

a. Main components:
- Mobile App (Flutter)
· Presentation Layer (Screens & Widgets)
· State Management Layer (Providers)
· Domain Layer (Use-Case Classes)
· Data Layer (Repositories & Models)
· Network Layer (NetworkClient & API Services)
- External Services:
· Weather API
· Air Quality API
· Location API (geocoding/reverse)
· (Optional) Backend for alerts reporting, shelters data (if external)
b. Relationships & Interactions:
- UI Screens invoke Providers → Providers call Use-Cases → Use-Cases call Repositories → Repositories use API Services (via NetworkClient) → External API → Response flows back upward, populating Models and updating UI via Providers.
- Shared Widgets (core/widgets) sit alongside Screens and are fed data by Providers.
c. Architectural patterns & design principles:
- Layered (Clean) Architecture: separation of concerns between presentation, domain, data, and external layers.
- Feature-based modularization: each feature folder encapsulates its own data, domain, presentation.
- Dependency injection via Providers.
- Single source of truth for state in each Provider.
d. Relevant technologies & libraries:
- Flutter/Dart
- Provider or Riverpod (state management)
- HTTP client (network_client.dart likely wraps Dio or HttpClient)
- Google Maps or similar (in shelters/maps_widget.dart)
- JSON serialization mapped to Dart models

d. Under Domain layer, note use-case classes (e.g., GetWeather, GetAQI, GetAlerts).
e. Under Data layer, show repositories (weather_repo, aqi_repo, alert_repo) alongside model definitions.
f. Under Network layer, show NetworkClient connecting to each API service class.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        HS["HomeScreen"]:::presentation
        AS["AlertsScreen"]:::presentation
        ECS["EmergencyContactsScreen"]:::presentation
        RS["ReportScreen"]:::presentation
        SS["SheltersScreen"]:::presentation
        SPS["SplashScreen"]:::presentation
        CW["Shared Widgets"]:::presentation
    end

    %% State Management Layer
    subgraph "State Management Layer"
        WP["WeatherProvider"]:::provider
        AP["AqiProvider"]:::provider
        LP["LocationProvider"]:::provider
        MP["MapProvider"]:::provider
        Alp["AlertProvider"]:::provider
    end

    %% Domain Layer
    subgraph "Domain Layer"
        GWU["GetWeatherUseCase"]:::domain
        GAU["GetAQIUseCase"]:::domain
        GLU["GetLocationUseCase"]:::domain
        GAletU["GetAlertsUseCase"]:::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        WR["WeatherRepository"]:::data
        AR["AqiRepository"]:::data
        LR["LocationRepository"]:::data
        WM["WeatherModel"]:::data
        AM["AQIModel"]:::data
        LM["LocationModel"]:::data
        AlertM["AlertsModel"]:::data
        ECM["EmergencyContactModel"]:::data
        RM["ReportModel"]:::data
    end

    %% Network Layer
    subgraph "Network Layer"
        NC["NetworkClient"]:::network
        WAS["WeatherApiService"]:::network
        AQAS["AirQualityApiService"]:::network
        LAS["LocationApiService"]:::network
    end

    %% External Services
    subgraph "External Services"
        EWA["External Weather API"]:::external
        EAQ["External Air Quality API"]:::external
        ELO["External Location API"]:::external
        EAL["Alerts Backend"]:::external
    end

    %% Application Entry
    MB["main.dart"]:::presentation
    AB["app.dart"]:::presentation

    %% Connections
    HS -->|uses| WP
    AS -->|uses| Alp
    ECS -->|uses| LP
    RS -->|uses| WP
    SS -->|uses| MP
    SPS -->|uses| WP

    CW -->|used by| HS
    CW -->|used by| AS

    WP -->|executes| GWU
    AP -->|executes| GAU
    LP -->|executes| GLU
    Alp -->|executes| GAletU

    GWU -->|calls| WR
    GAU -->|calls| AR
    GLU -->|calls| LR
    GAletU -->|calls| WR

    WR -->|fetches via| WAS
    AR -->|fetches via| AQAS
    LR -->|fetches via| LAS

    WAS -->|requests| EWA
    AQAS -->|requests| EAQ
    LAS -->|requests| ELO

    EWA -->|responds| WAS
    EAQ -->|responds| AQAS
    ELO -->|responds| LAS

    MB -->|starts| AB
    AB -->|configures| HS
    AB -->|configures| AS
    AB -->|configures| ECS
    AB -->|configures| RS
    AB -->|configures| SS
    AB -->|configures| SPS
    AB -->|provides| WP
    AB -->|provides| AP
    AB -->|provides| LP
    AB -->|provides| MP
    AB -->|provides| Alp

    %% Click Events
    click HS "https://github.com/hrpofficial736/resq/blob/main/lib/features/home/presentation/screens/home_screen.dart"
    click AS "https://github.com/hrpofficial736/resq/blob/main/lib/features/alerts/presentation/screens/alerts.dart"
    click ECS "https://github.com/hrpofficial736/resq/blob/main/lib/features/emergency/presentation/screens/emergency_contacts_screen.dart"
    click RS "https://github.com/hrpofficial736/resq/blob/main/lib/features/report/presentation/screens/report_screen.dart"
    click SS "https://github.com/hrpofficial736/resq/blob/main/lib/features/shelters/presentation/screens/shelters_screen.dart"
    click SPS "https://github.com/hrpofficial736/resq/blob/main/lib/features/splash/presentation/screens/splash_screen.dart"
    click CW "https://github.com/hrpofficial736/resq/tree/main/lib/core/widgets/"
    click WP "https://github.com/hrpofficial736/resq/blob/main/lib/providers/weather_provider.dart"
    click AP "https://github.com/hrpofficial736/resq/blob/main/lib/providers/aqi_provider.dart"
    click LP "https://github.com/hrpofficial736/resq/blob/main/lib/providers/location_provider.dart"
    click MP "https://github.com/hrpofficial736/resq/blob/main/lib/providers/map_provider.dart"
    click Alp "https://github.com/hrpofficial736/resq/blob/main/lib/providers/alert_provider.dart"
    click GWU "https://github.com/hrpofficial736/resq/blob/main/lib/features/home/domain/get_weather.dart"
    click GAU "https://github.com/hrpofficial736/resq/blob/main/lib/features/home/domain/get_aqi.dart"
    click GLU "https://github.com/hrpofficial736/resq/blob/main/lib/features/home/domain/get_location.dart"
    click GAletU "https://github.com/hrpofficial736/resq/blob/main/lib/features/alerts/domain/get_alerts.dart"
    click WR "https://github.com/hrpofficial736/resq/blob/main/lib/features/home/data/repositories/weather_repo.dart"
    click AR "https://github.com/hrpofficial736/resq/blob/main/lib/features/home/data/repositories/aqi_repo.dart"
    click LR "https://github.com/hrpofficial736/resq/blob/main/lib/features/home/data/repositories/location_repo.dart"
    click WM "https://github.com/hrpofficial736/resq/blob/main/lib/features/home/data/models/weather_model.dart"
    click AM "https://github.com/hrpofficial736/resq/blob/main/lib/features/home/data/models/aqi_model.dart"
    click LM "https://github.com/hrpofficial736/resq/blob/main/lib/features/home/data/models/location_model.dart"
    click AlertM "https://github.com/hrpofficial736/resq/blob/main/lib/features/alerts/data/models/alerts_model.dart"
    click ECM "https://github.com/hrpofficial736/resq/blob/main/lib/features/emergency/data/models/emergency_contact_model.dart"
    click RM "https://github.com/hrpofficial736/resq/blob/main/lib/features/report/data/report_model.dart"
    click NC "https://github.com/hrpofficial736/resq/blob/main/lib/services/network_client.dart"
    click WAS "https://github.com/hrpofficial736/resq/blob/main/lib/services/weather_api_service.dart"
    click AQAS "https://github.com/hrpofficial736/resq/blob/main/lib/services/air_quality_api_service.dart"
    click LAS "https://github.com/hrpofficial736/resq/blob/main/lib/services/location_api_service.dart"
    click MB "https://github.com/hrpofficial736/resq/blob/main/lib/main.dart"
    click AB "https://github.com/hrpofficial736/resq/blob/main/lib/app.dart"

    %% Styles
    classDef presentation fill:#cfe2f3,stroke:#0366d6,stroke-width:1px
    classDef provider fill:#d9ead3,stroke:#6aa84f,stroke-width:1px
    classDef domain fill:#fff2cc,stroke:#b45f06,stroke-width:1px
    classDef data fill:#fce5cd,stroke:#ca5010,stroke-width:1px
    classDef network fill:#f4cccc,stroke:#a1260d,stroke-width:1px
    classDef external fill:#d9d9d9,stroke:#666666,stroke-width:1px
```
