# aasavchauhan/water-supply-management-system architecture

> Architecture diagram of the GitHub repository aasavchauhan/water-supply-management-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aasavchauhan/water-supply-management-system
- Repository: https://github.com/aasavchauhan/water-supply-management-system

## Overview

1. This repository is a single Android application module (`app`) built in Java with an MVVM-style structure. The app is a field-oriented water supply management system, not a general-purpose web/backend project.

2. The top-level runtime entry points are `WaterSupplyApplication` and `MainActivity`, with multiple feature-specific activities and fragments under `com.watersupply.ui`. The app uses Android XML layouts, ViewBinding, Material-style resources, and standard Android navigation patterns rather than a server-rendered architecture.

3. The main architectural boundary is the data layer under `com.watersupply.data`. It contains:
   - Firebase integration helpers (`firebase`)
   - Data migration support (`migration`)
   - Domain/data models (`models`)
   - Repository classes (`repository`)
   This is the central abstraction layer between UI and persistence/auth services.

4. Firebase is the primary backend dependency. The repository includes `FirebaseManager`, Firestore collection/document helpers, and LiveData wrappers around Firestore queries/documents. This suggests the UI observes remote data reactively, while repositories encapsulate reads/writes and sync behavior.

5. The app is explicitly offline-first in the README, and Firestore offline persistence is part of the design. That means data flows are expected to work locally on device first, then sync with Firestore when connectivity returns. The `DataMigrationManager` implies the local/remote schema or data format has evolved over time and needs controlled upgrades.

6. Authentication is handled as a dedicated subsystem under `ui.auth` with `LoginActivity`, `RegisterActivity`, and corresponding ViewModels. The README mentions multiple auth methods and biometric access, so auth is a distinct access-control boundary before the operational parts of the app.

7. Core business data is organized around four operational domains:
   - Farmers
   - Supply entries
   - Payments
   - Reports/analytics
   These map directly to feature packages and repositories (`FarmerRepository`, `SupplyRepository`, `PaymentRepository`, `AppSettingsRepository`, `AuthRepository`), which keep each domain isolated.

8. The farmer workflow is its own mini-subsystem: list, detail, add, and edit screens with a recycler adapter for list rendering. Farmer records are likely a hub entity because both supply and payment flows select or reference a farmer.

9. Supply management is a separate workflow centered on `SupplyListActivity`, `NewSupplyActivity`, dialogs for selecting farmers and viewing details, and `SupplyEntryAdapter`. The README and utility classes show that supply billing can be computed in different modes, so this subsystem likely transforms usage input into billable entries.

10. Payments are similarly isolated with `PaymentListActivity`, `AddPaymentActivity`, a selection dialog, a detail dialog, and a list adapter. This indicates payments are tracked as a separate lifecycle from supply records, but linked through shared farmer identity and billing state.

11. Dashboard, profile, reports, and settings are the app’s “navigation and summary” layer. `DashboardFragment` and `ReportsFragment` provide aggregated views, while `ProfileFragment` and `SettingsActivity` expose user preferences and app configuration. These features read from the same repositories but do not own core transactional data.

12. The utility package contains cross-cutting business logic that is not tied to any single screen: billing calculation, currency/date formatting, constants, report generation, and theme preference storage. `ReportGenerator` and the HTML templates in `assets` indicate that reporting/export is a presentation pipeline separate from normal CRUD screens.

13. UI rendering is mostly classic Android view-based architecture with RecyclerView adapters for lists and multiple modal dialogs for selection/details. That means the diagram should show feature screens consuming ViewModel state, which in turn call repositories, which then talk to Firebase.

14. Around the app are supporting project concerns: GitHub Actions builds/releases, Firebase setup docs, release batch scripts, and image/layout resources. These do not change the runtime architecture, but they show the project is packaged and distributed as a mobile field app with a CI-generated release process.

Main entry points: [`app/src/main/java/com/watersupply/data/repository`](https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/data/repository) (Repositories), [`app/src/main/java/com/watersupply/ui/dashboard`](https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/ui/dashboard) (Dashboard), [`app/src/main/java/com/watersupply/MainActivity.java`](https://github.com/aasavchauhan/water-supply-management-system/blob/main/app/src/main/java/com/watersupply/MainActivity.java) (Main Activity), [`app/src/main/java/com/watersupply/utils`](https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/utils) (Utilities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_app(("WaterSupplyApp"))
  node_main_activity["Main Activity<br/>entry activity<br/>[MainActivity.java]"]
end

subgraph group_ui["UI"]
  node_auth["Auth<br/>access control"]
  node_onboarding["Onboarding<br/>setup flow"]
  node_dashboard["Dashboard<br/>summary ui"]
  node_farmers["Farmers<br/>farmer workflow"]
  node_supply["Supply<br/>billing workflow"]
  node_payments["Payments<br/>payment workflow"]
  node_reports["Reports<br/>analytics ui"]
  node_profile["Profile<br/>user ui"]
  node_settings["Settings<br/>preferences ui"]
end

subgraph group_data["Data"]
  node_repositories["Repositories<br/>data access"]
  node_models["Models"]
  node_firebase["Firebase<br/>backend adapter"]
  node_migration["Migration<br/>upgrade support"]
end

subgraph group_shared["Shared"]
  node_utils["Utilities<br/>shared logic"]
end

node_app -->|"launches"| node_main_activity
node_main_activity -->|"routes to"| node_auth
node_main_activity -->|"opens"| node_onboarding
node_main_activity -->|"hosts"| node_dashboard
node_auth -->|"auth data"| node_repositories
node_onboarding -->|"setup data"| node_repositories
node_dashboard -->|"navigates"| node_farmers
node_dashboard -->|"navigates"| node_supply
node_dashboard -->|"navigates"| node_payments
node_dashboard -->|"summarizes"| node_reports
node_dashboard -->|"opens"| node_profile
node_dashboard -->|"opens"| node_settings
node_farmers -->|"reads/writes"| node_repositories
node_supply -->|"reads/writes"| node_repositories
node_payments -->|"reads/writes"| node_repositories
node_reports -->|"aggregates"| node_repositories
node_settings -->|"stores"| node_repositories
node_repositories -->|"backed by"| node_firebase
node_repositories -->|"operates on"| node_models
node_firebase -.->|"evolves with"| node_migration
node_supply -->|"calculates with"| node_utils
node_payments -->|"formats with"| node_utils
node_reports -->|"generates with"| node_utils
node_profile -->|"themes with"| node_utils

click node_app "https://github.com/aasavchauhan/water-supply-management-system/blob/main/app/src/main/java/com/watersupply/WaterSupplyApplication.java"
click node_main_activity "https://github.com/aasavchauhan/water-supply-management-system/blob/main/app/src/main/java/com/watersupply/MainActivity.java"
click node_auth "https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/ui/auth"
click node_onboarding "https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/ui/onboarding"
click node_dashboard "https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/ui/dashboard"
click node_farmers "https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/ui/farmers"
click node_supply "https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/ui/supply"
click node_payments "https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/ui/payments"
click node_reports "https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/ui/reports"
click node_profile "https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/ui/profile"
click node_settings "https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/ui/settings"
click node_repositories "https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/data/repository"
click node_models "https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/data/models"
click node_firebase "https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/data/firebase"
click node_migration "https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/data/migration"
click node_utils "https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/utils"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_main_activity toneBlue
class node_auth,node_onboarding,node_dashboard,node_farmers,node_supply,node_payments,node_reports,node_profile,node_settings toneAmber
class node_repositories,node_models,node_firebase,node_migration toneMint
class node_utils toneRose
```

## Components

### Runtime

Android app entry points and host screens

- [WaterSupplyApp](https://github.com/aasavchauhan/water-supply-management-system/blob/main/app/src/main/java/com/watersupply/WaterSupplyApplication.java): application · Application startup and global initialization · `app/src/main/java/com/watersupply/WaterSupplyApplication.java`
- [Main Activity](https://github.com/aasavchauhan/water-supply-management-system/blob/main/app/src/main/java/com/watersupply/MainActivity.java): entry activity · Primary launcher and navigation host · `app/src/main/java/com/watersupply/MainActivity.java`

### UI

Feature screens, fragments, dialogs, and adapters

- [Auth](https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/ui/auth): access control · Login and registration flow · `app/src/main/java/com/watersupply/ui/auth`
- [Onboarding](https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/ui/onboarding): setup flow · Business setup and first-run guidance · `app/src/main/java/com/watersupply/ui/onboarding`
- [Dashboard](https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/ui/dashboard): summary ui · High-level overview and navigation hub · `app/src/main/java/com/watersupply/ui/dashboard`
- [Farmers](https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/ui/farmers): farmer workflow · Farmer list, detail, add, and edit screens · `app/src/main/java/com/watersupply/ui/farmers`
- [Supply](https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/ui/supply): billing workflow · Supply entry creation, selection, and detail views · `app/src/main/java/com/watersupply/ui/supply`
- [Payments](https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/ui/payments): payment workflow · Payment entry, listing, and detail dialogs · `app/src/main/java/com/watersupply/ui/payments`
- [Reports](https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/ui/reports): analytics ui · Aggregated reporting and export views · `app/src/main/java/com/watersupply/ui/reports`
- [Profile](https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/ui/profile): user ui · User profile and account view · `app/src/main/java/com/watersupply/ui/profile`
- [Settings](https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/ui/settings): preferences ui · App configuration and theme controls · `app/src/main/java/com/watersupply/ui/settings`

### Data

Repositories, models, Firebase access, and migration

- [Repositories](https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/data/repository): data access · Domain repositories for farmers, supply, payments, auth, and settings · `app/src/main/java/com/watersupply/data/repository`
- [Models](https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/data/models): domain models · AppSettings, Farmer, Payment, SupplyEntry, and User models · `app/src/main/java/com/watersupply/data/models`
- [Firebase](https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/data/firebase): backend adapter · Firestore manager and LiveData query/document wrappers · `app/src/main/java/com/watersupply/data/firebase`
- [Migration](https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/data/migration): upgrade support · Data migration and schema evolution manager · `app/src/main/java/com/watersupply/data/migration`

### Shared

Cross-cutting utilities and app-wide helpers

- [Utilities](https://github.com/aasavchauhan/water-supply-management-system/tree/main/app/src/main/java/com/watersupply/utils): shared logic · Billing, formatting, constants, themes, and report generation · `app/src/main/java/com/watersupply/utils`

## Connections

- WaterSupplyApp → Main Activity: launches · Application starts the main Android flow
- Main Activity → Auth: routes to · Entry point can send users into access control
- Main Activity → Onboarding: opens · First-run setup and business configuration
- Main Activity → Dashboard: hosts · Main navigation shell shows dashboard views
- Auth → Repositories: auth data · Login and registration rely on auth repository operations
- Onboarding → Repositories: setup data · Business setup persists configuration through repositories
- Dashboard → Farmers: navigates · Dashboard links into farmer management
- Dashboard → Supply: navigates · Dashboard links into supply workflows
- Dashboard → Payments: navigates · Dashboard links into payment workflows
- Dashboard → Reports: summarizes · Dashboard surfaces aggregated reporting
- Dashboard → Profile: opens · Dashboard exposes user profile
- Dashboard → Settings: opens · Dashboard exposes app settings
- Farmers → Repositories: reads/writes · Farmer screens use farmer repository operations
- Supply → Repositories: reads/writes · Supply screens create and query supply entries
- Payments → Repositories: reads/writes · Payment screens manage payment records
- Reports → Repositories: aggregates · Reports build summaries from domain data
- Settings → Repositories: stores · Settings persist app preferences and configuration
- Repositories → Firebase: backed by · Repositories delegate persistence and sync to Firebase
- Repositories → Models: operates on · Repositories persist and hydrate domain models
- Firebase → Migration: evolves with · Firebase-backed data is managed alongside migration support
- Supply → Utilities: calculates with · Supply billing uses shared calculation and formatting logic
- Payments → Utilities: formats with · Payment UI uses shared formatting and constants
- Reports → Utilities: generates with · Report export relies on shared report generation utilities
- Profile → Utilities: themes with · Profile and preferences use theme storage helpers
