# byatuljain/aqua_alert architecture

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

- Interactive diagram: https://gitdiagram.com/byatuljain/aqua_alert
- Repository: https://github.com/byatuljain/aqua_alert

## Overview

##### Project type and purpose
- From the file tree and README, “Aqua Alert” is a cross-platform Flutter application (mobile, web, desktop) that monitors and manages water distribution in Indore.
- It relies on Firebase (Auth, Firestore/Realtime DB, Storage, possibly Functions) for backend services and Google Maps API for geospatial visualization and zone tracking.

##### File structure
- Top-level “android”, “ios”, “web”, “linux”, “macos”, “windows”: platform shells generated by Flutter.
- “lib/”: Dart source files—each screen or feature in a separate file (e.g. login_screen.dart, map_screen.dart, reporting.dart).
- “firebase.json” + android/app/google-services.json + ios/Runner/Info.plist: Firebase configuration.
- “pubspec.yaml”/“pubspec.lock”: dependencies (Firebase SDKs, Google Map plugin).
- “test/”: unit/widget tests.

##### README for additional insights
- Objectives: advanced metering, reporting, leak detection, tanker monitoring, illegal connection prevention.
- Technical stack: Flutter v3.16.8, Dart v3.2.5, Firebase, Google Map API.

##### Elements
- Platforms: Android, iOS, Web, Windows, macOS, Linux
- Flutter App layers: UI Widgets (login, map, reporting), State Management (BLoC/Provider), Data Services
- Firebase: Auth, Firestore, Storage, Cloud Functions
- Google Maps API
- UI → Business Logic → Data Services → Firebase SDK → Firestore/Auth
- Flutter Map Widget → Google Maps API
- Firebase Functions → Firestore
- Backend services in another (e.g., orange)
- External API in a third (e.g., green)

##### Detailed capture of essential architectural elements
- How the app’s various screens (login_screen, otp_screen, map_screen, reporting, booking, user_profile, add_user_detail) connect through a shared Auth/Data service.
- Firebase_options.dart config as the injection point for all Firebase SDK usage.
- How real-time updates in Firestore propagate back to UI via streams or providers.
- Module boundaries so a new engineer can see where to plug in new features (e.g., adding a new “leak_detection.dart” service tied to Firestore/Functions).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Zone
    subgraph CLIENT
        subgraph "Platform Embedders"
            Android["Android"]:::platform
            iOS["iOS"]:::platform
            Web["Web"]:::platform
            Windows["Windows"]:::platform
            macOS["macOS"]:::platform
            Linux["Linux"]:::platform
        end
        subgraph "Flutter App"
            Entry["main.dart"]:::dart
            subgraph "UI Screens"
                Login["Login Screen"]:::ui
                OTP["OTP Verification Screen"]:::ui
                Home["Home/Dashboard Screen"]:::ui
                Map["Map Visualization Screen"]:::ui
                Reporting["Reporting Screen"]:::ui
                Booking["Booking/Tanker Monitoring Screen"]:::ui
                AddUser["Add User Details Screen"]:::ui
                Profile["User Profile Screen"]:::ui
                NavBar["Bottom Navigation Bar"]:::ui
            end
            State["State Management & Business Logic"]:::business
            DataLayer["Data Layer"]:::data
        end
    end

    %% Backend Zone
    subgraph BACKEND
        Auth["Firebase Auth"]:::backend
        Firestore["Firestore (Database)"]:::db
        Storage["Cloud Storage"]:::backend
        Functions["Cloud Functions"]:::backend
    end

    %% External API
    External["Google Maps API"]:::external

    %% Config Files
    subgraph "Configuration"
        FirebaseConfig["firebase.json"]:::config
        AndroidConfig["android/app/google-services.json"]:::config
        iOSConfig["ios/Runner/Info.plist"]:::config
        Pubspec["pubspec.yaml / pubspec.lock"]:::config
        Tests["test/widget_test.dart"]:::config
    end

    %% Connections
    Entry -->|"initializes"| State
    Login -->|"user action"| State
    OTP -->|"user action"| State
    Home -->|"user action"| State
    Map -->|"user action"| State
    Reporting -->|"user action"| State
    Booking -->|"user action"| State
    AddUser -->|"user action"| State
    Profile -->|"user action"| State
    NavBar -->|"navigation"| State

    State -->|"requests data"| DataLayer
    DataLayer -->|"uses Auth SDK"| Auth
    DataLayer -->|"reads/writes"| Firestore
    DataLayer -->|"uploads/downloads"| Storage
    DataLayer -->|"triggers"| Functions
    DataLayer -->|"loads config"| FirebaseConfig

    Map -->|"geospatial calls"| External

    Functions -->|"listens & reacts"| Firestore

    %% Click Events
    click Entry "https://github.com/byatuljain/aqua_alert/blob/master/lib/main.dart"
    click Login "https://github.com/byatuljain/aqua_alert/blob/master/lib/login_screen.dart"
    click OTP "https://github.com/byatuljain/aqua_alert/blob/master/lib/otp_screen.dart"
    click Home "https://github.com/byatuljain/aqua_alert/blob/master/lib/home_screen.dart"
    click Map "https://github.com/byatuljain/aqua_alert/blob/master/lib/map_screen.dart"
    click Reporting "https://github.com/byatuljain/aqua_alert/blob/master/lib/reporting.dart"
    click Booking "https://github.com/byatuljain/aqua_alert/blob/master/lib/booking.dart"
    click AddUser "https://github.com/byatuljain/aqua_alert/blob/master/lib/add_user_detail_screen.dart"
    click Profile "https://github.com/byatuljain/aqua_alert/blob/master/lib/user_profile.dart"
    click NavBar "https://github.com/byatuljain/aqua_alert/blob/master/lib/bottom_nav_bar.dart"
    click State "https://github.com/byatuljain/aqua_alert/blob/master/lib/firebase_options.dart"
    click DataLayer "https://github.com/byatuljain/aqua_alert/blob/master/lib/firebase_options.dart"
    click FirebaseConfig "https://github.com/byatuljain/aqua_alert/blob/master/firebase.json"
    click AndroidConfig "https://github.com/byatuljain/aqua_alert/blob/master/android/app/google-services.json"
    click iOSConfig "https://github.com/byatuljain/aqua_alert/blob/master/ios/Runner/Info.plist"
    click Pubspec "https://github.com/byatuljain/aqua_alert/blob/master/pubspec.yaml"
    click Tests "https://github.com/byatuljain/aqua_alert/blob/master/test/widget_test.dart"

    %% Styles
    classDef platform fill:#d0e1f9,stroke:#0366d6,color:#0366d6
    classDef dart fill:#f7df1e,stroke:#c69500,color:#000
    classDef ui fill:#cce5ff,stroke:#004085,color:#004085
    classDef business fill:#ffeeba,stroke:#856404,color:#856404
    classDef data fill:#d4edda,stroke:#155724,color:#155724
    classDef backend fill:#f8d7da,stroke:#721c24,color:#721c24
    classDef db fill:#d1ecf1,stroke:#0c5460,color:#0c5460
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#6c757d
    classDef config fill:#fff3cd,stroke:#856404,color:#856404
```
