# suhanisunehra/women_safety_framework architecture

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

- Interactive diagram: https://gitdiagram.com/suhanisunehra/women_safety_framework
- Repository: https://github.com/suhanisunehra/women_safety_framework

## Overview

##### Project Type and Purpose
- This is a cross-platform Flutter application (“women_safety_framework”) targeting mobile (Android, iOS), web, and desktop (Windows, macOS, Linux).
- Its purpose is to provide safety features for women in different roles (normal user, working woman, organization admin), including incident reporting, geofencing alerts, emergency contacts, and location-based services (e.g., finding nearby hospitals or police stations).

##### File-Structure Analysis
- Top-level platform folders: `android/`, `ios/`, `web/`, `windows/`, `macos/`, `linux/`
- Core application code in `lib/` with subfolders:
- `roles/` – screens per user role (normal_user, working_women, organization_admin)
- `widgets/` & `reusable_widgets/` – UI components
- `utils/` – helper functions, constants
- `secureStorageService.dart` – local storage for tokens/settings
- `fetchWorkplaceDetails.dart` – network service for external data
- Standard Flutter config files: `pubspec.yaml`, platform runners, Gradle/Xcode projects.

##### Key Technologies & Services
- Flutter / Dart for UI and business logic
- Firebase (implied by `google-services.json`) for authentication, data storage
- HTTP / REST for external workplace details
- Device APIs: Geolocation, Geofencing, Battery status, Notifications (via platform channels or Flutter plugins)
- Secure local storage for sensitive tokens/settings

##### Components
a. Client-side Layers
- Presentation Layer: Screens & Widgets (`lib/roles/*`, `lib/widgets/*`)
- Business Logic Layer: Services & Controllers (`fetchWorkplaceDetails.dart`, `secureStorageService.dart`, role screen ViewModels)
- Data Layer:
- Local Storage (secure storage plugin)
- Network Services (HTTP/Firebase SDK)
- Platform Integration:
- Flutter Engine
- Platform Channels (for geofencing, battery monitoring, notifications)
b. External Services
- Firebase Auth & Firestore (or Realtime Database)
- External REST API for workplace details
- Third-party Maps/Places API (for hospital/police station lookup)
c. Platform Runners
- Android (Gradle / Java-Kotlin stub)
- iOS (Xcode / Swift stub)
- Web, Windows, macOS, Linux runners

##### Interactions & Data Flows
- User interacts with UI screens → UI dispatches to Business Logic
- Business Logic calls:
- SecureStorageService for local read/write
- Network Services:
– Firebase SDK (sign-in/up, read/write reports)
– HTTP client (fetchWorkplaceDetails)
- Platform Channels (request geolocation, set geofence, monitor battery)
- External Services return data → Business Logic transforms → UI updates

##### Architectural Patterns & Principles
- Layered Architecture (Presentation / Domain / Data)
- Separation of Concerns: each role’s screens isolated under `lib/roles`
- Reusable Components: centralized widgets & utilities to avoid duplication
- Single Source of Truth: services handle all data access

##### Final Recommendations
- Significant parts: platform runners, Flutter engine, UI modules, services, storage, external backends.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Platform Runners
    subgraph "Platform Runners"
        AndroidRunner["Android Runner"]:::native
        iOSRunner["iOS Runner"]:::native
        WebRunner["Web Runner"]:::native
        WindowsRunner["Windows Runner"]:::native
        macOSRunner["macOS Runner"]:::native
        LinuxRunner["Linux Runner"]:::native
    end

    %% Flutter Engine & Integration
    FlutterEngine["Flutter Engine"]:::native
    PlatformChannels["Platform Channels"]:::native
    NativeServices["Native Services\n(Geofencing, Battery, Notifications)"]:::native

    %% Flutter App Structure
    subgraph "Flutter App"
        %% Entry & Routing
        Main["main.dart"]:::business
        LandingPage["landing_page.dart"]:::business
        SplashScreen["splash_screen.dart"]:::business

        %% Presentation Layer
        subgraph "Presentation Layer" 
            NormalUserModule["Normal User Module"]:::frontend
            WorkingWomenModule["Working Women Module"]:::frontend
            OrgAdminModule["Organization Admin Module"]:::frontend
            HomeWidgets["Home Widgets"]:::frontend
            LiveSafeWidgets["Live Safe Widgets"]:::frontend
            ReusableWidgets["Reusable Widgets"]:::frontend
        end

        %% Business Logic Layer
        subgraph "Business Logic Layer"
            FetchWorkplaceDetails["FetchWorkplaceDetails Service"]:::business
            SecureStorageService["SecureStorageService"]:::business
            Utils["Utils & Constants"]:::business
        end

        %% Data Layer
        subgraph "Data Layer"
            LocalStorage["Secure Local Storage"]:::data
            FirebaseSDK["Firebase SDK"]:::external
            HTTPClient["HTTP Client"]:::data
        end
    end

    %% External Services
    subgraph "External Services"
        FirebaseAuth["Firebase Auth"]:::external
        FirebaseDB["Firebase Firestore/RealtimeDB"]:::external
        WorkplaceAPI["Workplace Details API"]:::external
        MapsAPI["Maps/Places API"]:::external
    end

    %% Connections
    AndroidRunner -->|launch| FlutterEngine
    iOSRunner -->|launch| FlutterEngine
    WebRunner -->|launch| FlutterEngine
    WindowsRunner -->|launch| FlutterEngine
    macOSRunner -->|launch| FlutterEngine
    LinuxRunner -->|launch| FlutterEngine

    FlutterEngine -->|platform calls| PlatformChannels
    PlatformChannels -->|invoke| NativeServices

    Main -->|routes to| LandingPage
    Main -->|routes to| SplashScreen
    LandingPage -->|navigates to| NormalUserModule
    LandingPage -->|navigates to| WorkingWomenModule
    LandingPage -->|navigates to| OrgAdminModule

    NormalUserModule -->|uses| HomeWidgets
    NormalUserModule -->|uses| LiveSafeWidgets
    WorkingWomenModule -->|uses| ReusableWidgets
    OrgAdminModule -->|uses| ReusableWidgets

    NormalUserModule -->|calls| FetchWorkplaceDetails
    WorkingWomenModule -->|calls| FetchWorkplaceDetails
    OrgAdminModule -->|calls| FetchWorkplaceDetails

    FetchWorkplaceDetails -->|HTTP REST| WorkplaceAPI
    FetchWorkplaceDetails -->|uses| HTTPClient

    SecureStorageService -->|read/write| LocalStorage

    FetchWorkplaceDetails -->|stores tokens| SecureStorageService

    NormalUserModule -->|reads/writes| SecureStorageService
    WorkingWomenModule -->|reads/writes| SecureStorageService

    FetchWorkplaceDetails -->|calls SDK| FirebaseSDK
    SecureStorageService -->|calls SDK| FirebaseSDK

    FirebaseSDK -->|auth| FirebaseAuth
    FirebaseSDK -->|data read/write| FirebaseDB

    NormalUserModule -->|requests location| PlatformChannels
    NormalUserModule -->|sets geofence| PlatformChannels
    NormalUserModule -->|monitors battery| PlatformChannels

    LiveSafeWidgets -->|lookup| MapsAPI

    %% Click Events
    click NormalUserModule "https://github.com/suhanisunehra/women_safety_framework/tree/main/lib/roles/normal_user/"
    click WorkingWomenModule "https://github.com/suhanisunehra/women_safety_framework/tree/main/lib/roles/working_women/"
    click OrgAdminModule "https://github.com/suhanisunehra/women_safety_framework/tree/main/lib/roles/organization_admin/"
    click HomeWidgets "https://github.com/suhanisunehra/women_safety_framework/tree/main/lib/widgets/home_widgets/"
    click LiveSafeWidgets "https://github.com/suhanisunehra/women_safety_framework/tree/main/lib/widgets/live_safe/"
    click ReusableWidgets "https://github.com/suhanisunehra/women_safety_framework/tree/main/lib/reusable_widgets/"
    click FetchWorkplaceDetails "https://github.com/suhanisunehra/women_safety_framework/blob/main/lib/fetchWorkplaceDetails.dart"
    click SecureStorageService "https://github.com/suhanisunehra/women_safety_framework/blob/main/lib/roles/secureStorageService.dart"
    click Utils "https://github.com/suhanisunehra/women_safety_framework/tree/main/lib/utils/"
    click Main "https://github.com/suhanisunehra/women_safety_framework/blob/main/lib/main.dart"
    click LandingPage "https://github.com/suhanisunehra/women_safety_framework/blob/main/lib/landing_page.dart"
    click SplashScreen "https://github.com/suhanisunehra/women_safety_framework/blob/main/lib/splash_screen.dart"
    click AndroidRunner "https://github.com/suhanisunehra/women_safety_framework/tree/main/android/"
    click iOSRunner "https://github.com/suhanisunehra/women_safety_framework/tree/main/ios/"
    click WebRunner "https://github.com/suhanisunehra/women_safety_framework/tree/main/web/"
    click WindowsRunner "https://github.com/suhanisunehra/women_safety_framework/tree/main/windows/"
    click macOSRunner "https://github.com/suhanisunehra/women_safety_framework/tree/main/macos/"
    click LinuxRunner "https://github.com/suhanisunehra/women_safety_framework/tree/main/linux/"

    %% Styles
    classDef frontend fill:#DDEEFF,stroke:#333,stroke-width:1px;
    classDef business fill:#DFFFE0,stroke:#333,stroke-width:1px;
    classDef data fill:#FFE8C4,stroke:#333,stroke-width:1px;
    classDef external fill:#E8D4FF,stroke:#333,stroke-width:1px;
    classDef native fill:#CCCCCC,stroke:#333,stroke-width:1px;
```
