# fariaislam04/safeguardher-women-safety-app architecture

> Architecture diagram of the GitHub repository fariaislam04/safeguardher-women-safety-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fariaislam04/safeguardher-women-safety-app
- Repository: https://github.com/fariaislam04/safeguardher-women-safety-app

## Overview

##### Main Components
- Mobile Frontend – Represent the Flutter UI components found in the lib directory. This includes the various screens like authentication, panic button, map, safety tips, record screen, tracking, etc. Also include the custom widgets, navigation (app bar, bottom navbar), and state management (providers).
- Business Logic & Models – Highlight the models (alert_model, user_model, etc.) and provider files that drive the state and data flow across the UI.
- Services Layer – Group the service files:
- Background services: location tracking, camera service, SMS sender, permissions, storage, etc.
- Firebase Services: Firebase messaging, Firestore service, and related configuration from firebase_options.dart.
- Utility modules that help with constants, formatting, logging, and validation.
- Backend & Cloud Functions – Include the Firebase Cloud Functions folder (functions directory) that supplies additional server-side logic on Firebase.
- External Integrations – Denote Firebase (authentication, Firestore, messaging) along with external messaging/SMS services.
- Platform-specific Configurations – Represent the Android and iOS native project folders which handle platform-specific setups and deployment configurations.

##### Relationships and Data Flow
- Data flow from the user interacting with the Flutter-based UI (screens and widgets) which then communicates with the service layer (e.g., user taps on panic button, triggering background services for SMS, location, and media recording).
- How the providers and models sit in between the UI and service layers to manage state.
- Integration points where Flutter communicates with Firebase services (e.g., using Firestore for storing incident reports, messaging for push notifications) and how Firebase Cloud Functions may process data on the backend.
- Flow of background services (permission, camera, SMS, storage) which operate asynchronously to support the real-time tracking and incident recording features.

##### Architectural Patterns and Technologies
- The architecture follows a typical Flutter “separation of concerns” approach where UI components (screens/widgets) are separated from business logic (providers/models) and from service integrations.
- Use of asynchronous background services—a critical aspect for real-time tracking, emergency response, and media capture.
- Usage of Firebase connects mobile frontend with cloud storage, messaging, and serverless functions.
- Make a note that although the project is built in Flutter, native code exists in the android and ios folders for platform-specific implementations.

## Diagram (Mermaid)

```mermaid
graph TD
    U["User"]:::user

    subgraph "Mobile Frontend (Flutter)"
        Screens["Screens"]
        Widgets["Widgets & Navigation"]
    end

    subgraph "Business Logic & State Management"
        Providers["Providers"]
        Models["Models"]
    end

    subgraph "Services Layer"
        BG["Background Services"]
        FS["Firestore Service"]
        FMService["Firebase Messaging Service"]
        FMO["Firebase Options"]
        Utils["Utilities"]
    end

    CF["Cloud Functions"]:::backend

    EI["Firebase Integration"]:::integration

    subgraph "Platform-specific Configurations"
        Android["Android"]
        iOS["iOS"]
    end

    U -->|"uses"| Screens
    U -->|"uses"| Widgets
    Screens -->|"triggers"| Providers
    Widgets -->|"triggers"| Providers
    Providers -->|"manages_state"| Models
    Providers -->|"calls"| BG
    Providers -->|"calls"| FS
    Providers -->|"calls"| FMService
    Providers -->|"calls"| FMO
    Providers -->|"calls"| Utils
    BG -->|"alerts"| CF
    FS -->|"stores_data"| CF
    FMService -->|"receives_push"| CF
    Utils -->|"supports"| BG
    Utils -->|"supports"| Providers
    FMService -->|"integrates_with"| EI

    Screens -->|"configured_by"| Android
    Screens -->|"configured_by"| iOS
    Widgets -->|"configured_by"| Android
    Widgets -->|"configured_by"| iOS

    style U fill:#d3d3d3,stroke:#333,stroke-width:2px
    style Screens fill:#f9c74f,stroke:#333,stroke-width:2px
    style Widgets fill:#f9c74f,stroke:#333,stroke-width:2px
    style Providers fill:#90be6d,stroke:#333,stroke-width:2px
    style Models fill:#90be6d,stroke:#333,stroke-width:2px
    style BG fill:#f9844a,stroke:#333,stroke-width:2px
    style FS fill:#f9844a,stroke:#333,stroke-width:2px
    style FMService fill:#f9844a,stroke:#333,stroke-width:2px
    style FMO fill:#f9844a,stroke:#333,stroke-width:2px
    style Utils fill:#f9844a,stroke:#333,stroke-width:2px
    style CF fill:#577590,stroke:#333,stroke-width:2px
    style EI fill:#f94144,stroke:#333,stroke-width:2px
    style Android fill:#277da1,stroke:#333,stroke-width:2px
    style iOS fill:#277da1,stroke:#333,stroke-width:2px

    click Screens "https://github.com/fariaislam04/safeguardher-women-safety-app/tree/main/lib/screens"
    click Widgets "https://github.com/fariaislam04/safeguardher-women-safety-app/tree/main/lib/widgets"
    click Providers "https://github.com/fariaislam04/safeguardher-women-safety-app/blob/main/lib/providers.dart"
    click Models "https://github.com/fariaislam04/safeguardher-women-safety-app/tree/main/lib/models"
    click BG "https://github.com/fariaislam04/safeguardher-women-safety-app/tree/main/lib/services/background"
    click FS "https://github.com/fariaislam04/safeguardher-women-safety-app/blob/main/lib/services/database/firestore_service.dart"
    click FMService "https://github.com/fariaislam04/safeguardher-women-safety-app/blob/main/lib/firebase_messaging_service.dart"
    click FMO "https://github.com/fariaislam04/safeguardher-women-safety-app/blob/main/lib/firebase_options.dart"
    click Utils "https://github.com/fariaislam04/safeguardher-women-safety-app/tree/main/lib/utils"
    click CF "https://github.com/fariaislam04/safeguardher-women-safety-app/tree/main/functions"
    click EI "https://github.com/fariaislam04/safeguardher-women-safety-app/blob/main/android/app/google-services.json"
    click Android "https://github.com/fariaislam04/safeguardher-women-safety-app/tree/main/android"
    click iOS "https://github.com/fariaislam04/safeguardher-women-safety-app/tree/main/ios"
```
