# atharvaingle/smart-grow architecture

> Architecture diagram of the GitHub repository atharvaingle/smart-grow, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/atharvaingle/smart-grow
- Repository: https://github.com/atharvaingle/smart-grow

## Overview

#### Purpose and Runtime
Smart Grow/Farmassist is a Flutter mobile application for authenticated farm management, IoT telemetry monitoring, and on-device plant disease classification. Android and iOS hosts bootstrap Flutter; web scaffolding is also present. The TensorFlow Lite model is bundled at `model.tflite`.

#### Application Shell and Navigation
The UI is organized by feature under `ui/`, with the home shell and bottom navigation selecting major workflows. Key entry-facing paths are `ui/home_page.dart`, `ui/bottom_navigation_bar/bottom_navigation_bar.dart`, and platform launchers `android/app/src/main/kotlin/com/example/farmassist/MainActivity.kt` and `ios/Runner/AppDelegate.swift`.

#### Identity and User Boundary
Authentication uses Firebase Authentication with Bloc/Cubit state transitions for session, login, and signup. User profile records are handled separately through user repositories, forming the boundary between Firebase identity and app-owned user data in Cloud Firestore.
- `bloc/authentication/bloc/authentication_bloc.dart`
- `bloc/login/login_cubit.dart`
- `data/authentication/repositories/authentication_repository.dart`
- `data/user/repositories/user_repository.dart`

#### Farm Management and External Content
Planting and harvesting screens write/read user-scoped farm records through repositories, intended for Cloud Firestore. Farm views also compose weather forecasts and science news from external HTTP APIs; these are independent service boundaries rather than local domain state.
- `ui/farm/farm_management_page.dart`
- `data/farm/repositories/storeData.dart`
- `data/farm/repositories/harvest_storeData.dart`
- `data/farm/api/openweathermap_weather_api.dart`
- `data/farm/resources/newsAPI.dart`

#### IoT Telemetry Pipeline
The app reads per-user telemetry from Firebase Realtime Database via the telemetry repository, converts it into domain/chart models, and renders current readings and time-series charts. The upstream producer is an external IoT simulator/device. Alert evaluation and push delivery occur outside this repo: Realtime Database writes trigger Firebase Cloud Functions, which use Firebase Cloud Messaging.
- `data/IoT/repositories/telemetry_data_repository.dart`
- `data/IoT/models/telemetry_data.dart`
- `ui/IoT/IoT_monitoring_page.dart`
- `ui/IoT/telemetry_data_chart.dart`

#### Disease Detection Pipeline
Users capture/select plant imagery through the disease-detection UI. Classification code loads and executes the local TFLite model, returning one of the trained disease categories for presentation in diagnostic cards/views. Model inference is on-device; model training was externalized to Google Cloud AutoML Vision.
- `ui/diseases/disease_detection_page.dart`
- `ui/diseases/diagnosis.dart`
- `data/diseases/classifier.dart`
- `data/diseases/disease_detection_model.dart`
- `model.tflite`

#### State and Data Architecture
The repository mixes feature-local presentation state (Bloc/Cubit in authentication and news) with repository/service-based data access for Firebase and HTTP integrations. Domain models isolate UI from serialized backend/API data, notably weather, farm records, news, and telemetry.
- `ui/farm/news/bloc/nBloc.dart`
- `data/farm/services/forecast_service.dart`
- `data/farm/models/Planting.dart`
- `data/farm/models/Weather.dart`
- `data/IoT/models/line_chart_spots.dart`

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Flutter Mobile App"]
  node_platform_hosts["Android / iOS Hosts<br/>platform launchers<br/>[MainActivity.kt]"]
  node_app_shell["Home Shell<br/>navigation shell<br/>[home_page.dart]"]
  node_bottom_nav["Bottom Navigation"]
  node_auth_state["Auth Bloc / Login Cubit<br/>presentation state"]
  node_auth_repository["Authentication Repository<br/>identity repository"]
  node_user_repository["User Repository<br/>profile repository"]
  node_farm_management["Farm Management<br/>feature UI"]
  node_farm_repositories["Planting / Harvest Repositories<br/>farm data access<br/>[storeData.dart]"]
  node_forecast_service["Forecast Service<br/>weather service"]
  node_news_state["News Bloc<br/>presentation state<br/>[nBloc.dart]"]
  node_iot_monitoring["IoT Monitoring<br/>feature UI"]
  node_telemetry_repository["Telemetry Repository<br/>telemetry data access"]
  node_telemetry_models["Telemetry / Chart Models<br/>domain models"]
  node_disease_ui["Disease Detection UI<br/>feature UI"]
end

subgraph group_firebase["Firebase"]
  node_firebase_auth["Firebase Authentication<br/>identity provider"]
  node_cloud_firestore[("Cloud Firestore<br/>user and farm store")]
  node_realtime_db[("Realtime Database<br/>telemetry store")]
  node_functions_fcm["Cloud Functions + FCM<br/>external alert delivery"]
end

subgraph group_external["External Services"]
  node_iot_producer["IoT Device / Simulator<br/>telemetry producer"]
  node_weather_api["OpenWeather API<br/>forecast API"]
  node_news_api["Science News API<br/>content API"]
end

subgraph group_ml["On-device ML"]
  node_classifier["TFLite Classifier<br/>on-device inference<br/>[classifier.dart]"]
  node_tflite_model["Disease Model<br/>TensorFlow Lite model<br/>[model.tflite]"]
end

node_platform_hosts -->|"launches"| node_app_shell
node_app_shell -->|"uses"| node_bottom_nav
node_bottom_nav -->|"selects"| node_farm_management
node_bottom_nav -->|"selects"| node_iot_monitoring
node_bottom_nav -->|"selects"| node_disease_ui
node_auth_state -->|"authenticates through"| node_auth_repository
node_auth_repository -->|"uses"| node_firebase_auth
node_user_repository -->|"reads/writes profiles"| node_cloud_firestore
node_farm_management -->|"manages records through"| node_farm_repositories
node_farm_repositories -->|"reads/writes farm records"| node_cloud_firestore
node_farm_management -->|"shows forecast"| node_forecast_service
node_forecast_service -->|"requests"| node_weather_api
node_news_state -->|"fetches"| node_news_api
node_iot_monitoring -->|"loads telemetry"| node_telemetry_repository
node_telemetry_repository -->|"reads per-user data"| node_realtime_db
node_telemetry_repository -->|"maps to"| node_telemetry_models
node_telemetry_models -->|"renders readings and charts"| node_iot_monitoring
node_iot_producer -->|"writes telemetry"| node_realtime_db
node_realtime_db -.->|"triggers alerts"| node_functions_fcm
node_disease_ui -->|"submits image"| node_classifier
node_classifier -->|"loads and executes"| node_tflite_model
node_classifier -->|"returns diagnosis"| node_disease_ui

click node_platform_hosts "https://github.com/atharvaingle/smart-grow/blob/main/android/app/src/main/kotlin/com/example/farmassist/MainActivity.kt"
click node_app_shell "https://github.com/atharvaingle/smart-grow/blob/main/ui/home_page.dart"
click node_bottom_nav "https://github.com/atharvaingle/smart-grow/blob/main/ui/bottom_navigation_bar/bottom_navigation_bar.dart"
click node_auth_state "https://github.com/atharvaingle/smart-grow/blob/main/bloc/authentication/bloc/authentication_bloc.dart"
click node_auth_repository "https://github.com/atharvaingle/smart-grow/blob/main/data/authentication/repositories/authentication_repository.dart"
click node_user_repository "https://github.com/atharvaingle/smart-grow/blob/main/data/user/repositories/user_repository.dart"
click node_farm_management "https://github.com/atharvaingle/smart-grow/blob/main/ui/farm/farm_management_page.dart"
click node_farm_repositories "https://github.com/atharvaingle/smart-grow/blob/main/data/farm/repositories/storeData.dart"
click node_forecast_service "https://github.com/atharvaingle/smart-grow/blob/main/data/farm/services/forecast_service.dart"
click node_news_state "https://github.com/atharvaingle/smart-grow/blob/main/ui/farm/news/bloc/nBloc.dart"
click node_iot_monitoring "https://github.com/atharvaingle/smart-grow/blob/main/ui/IoT/IoT_monitoring_page.dart"
click node_telemetry_repository "https://github.com/atharvaingle/smart-grow/blob/main/data/IoT/repositories/telemetry_data_repository.dart"
click node_telemetry_models "https://github.com/atharvaingle/smart-grow/blob/main/data/IoT/models/telemetry_data.dart"
click node_disease_ui "https://github.com/atharvaingle/smart-grow/blob/main/ui/diseases/disease_detection_page.dart"
click node_classifier "https://github.com/atharvaingle/smart-grow/blob/main/data/diseases/classifier.dart"
click node_tflite_model "https://github.com/atharvaingle/smart-grow/blob/main/model.tflite"

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_platform_hosts,node_app_shell,node_bottom_nav,node_auth_state,node_auth_repository,node_user_repository,node_farm_management,node_farm_repositories,node_forecast_service,node_news_state,node_iot_monitoring,node_telemetry_repository,node_telemetry_models,node_disease_ui toneBlue
class node_firebase_auth,node_cloud_firestore,node_realtime_db,node_functions_fcm toneAmber
class node_iot_producer,node_weather_api,node_news_api toneMint
class node_classifier,node_tflite_model toneRose
```

## Components

### Flutter Mobile App

- [Android / iOS Hosts](https://github.com/atharvaingle/smart-grow/blob/main/android/app/src/main/kotlin/com/example/farmassist/MainActivity.kt): platform launchers · Bootstraps the Flutter runtime. · `android/app/src/main/kotlin/com/example/farmassist/MainActivity.kt`
- [Home Shell](https://github.com/atharvaingle/smart-grow/blob/main/ui/home_page.dart): navigation shell · `ui/home_page.dart`
- [Bottom Navigation](https://github.com/atharvaingle/smart-grow/blob/main/ui/bottom_navigation_bar/bottom_navigation_bar.dart): navigation · `ui/bottom_navigation_bar/bottom_navigation_bar.dart`
- [Auth Bloc / Login Cubit](https://github.com/atharvaingle/smart-grow/blob/main/bloc/authentication/bloc/authentication_bloc.dart): presentation state · `bloc/authentication/bloc/authentication_bloc.dart`
- [Authentication Repository](https://github.com/atharvaingle/smart-grow/blob/main/data/authentication/repositories/authentication_repository.dart): identity repository · `data/authentication/repositories/authentication_repository.dart`
- [User Repository](https://github.com/atharvaingle/smart-grow/blob/main/data/user/repositories/user_repository.dart): profile repository · Separates app-owned profiles from Firebase identity. · `data/user/repositories/user_repository.dart`
- [Farm Management](https://github.com/atharvaingle/smart-grow/blob/main/ui/farm/farm_management_page.dart): feature UI · `ui/farm/farm_management_page.dart`
- [Planting / Harvest Repositories](https://github.com/atharvaingle/smart-grow/blob/main/data/farm/repositories/storeData.dart): farm data access · `data/farm/repositories/storeData.dart`
- [Forecast Service](https://github.com/atharvaingle/smart-grow/blob/main/data/farm/services/forecast_service.dart): weather service · `data/farm/services/forecast_service.dart`
- [News Bloc](https://github.com/atharvaingle/smart-grow/blob/main/ui/farm/news/bloc/nBloc.dart): presentation state · `ui/farm/news/bloc/nBloc.dart`
- [IoT Monitoring](https://github.com/atharvaingle/smart-grow/blob/main/ui/IoT/IoT_monitoring_page.dart): feature UI · `ui/IoT/IoT_monitoring_page.dart`
- [Telemetry Repository](https://github.com/atharvaingle/smart-grow/blob/main/data/IoT/repositories/telemetry_data_repository.dart): telemetry data access · `data/IoT/repositories/telemetry_data_repository.dart`
- [Telemetry / Chart Models](https://github.com/atharvaingle/smart-grow/blob/main/data/IoT/models/telemetry_data.dart): domain models · Converts database readings for current values and chart series. · `data/IoT/models/telemetry_data.dart`
- [Disease Detection UI](https://github.com/atharvaingle/smart-grow/blob/main/ui/diseases/disease_detection_page.dart): feature UI · `ui/diseases/disease_detection_page.dart`

### Firebase

- **Firebase Authentication**: identity provider
- **Cloud Firestore**: user and farm store
- **Realtime Database**: telemetry store
- **Cloud Functions + FCM**: external alert delivery · Evaluates telemetry-triggered alerts outside this repository.

### External Services

- **IoT Device / Simulator**: telemetry producer
- **OpenWeather API**: forecast API
- **Science News API**: content API

### On-device ML

- [TFLite Classifier](https://github.com/atharvaingle/smart-grow/blob/main/data/diseases/classifier.dart): on-device inference · `data/diseases/classifier.dart`
- [Disease Model](https://github.com/atharvaingle/smart-grow/blob/main/model.tflite): TensorFlow Lite model · Bundled trained disease-category model. · `model.tflite`

## Connections

- Android / iOS Hosts → Home Shell: launches
- Home Shell → Bottom Navigation: uses
- Bottom Navigation → Farm Management: selects
- Bottom Navigation → IoT Monitoring: selects
- Bottom Navigation → Disease Detection UI: selects
- Auth Bloc / Login Cubit → Authentication Repository: authenticates through
- Authentication Repository → Firebase Authentication: uses
- User Repository → Cloud Firestore: reads/writes profiles
- Farm Management → Planting / Harvest Repositories: manages records through
- Planting / Harvest Repositories → Cloud Firestore: reads/writes farm records
- Farm Management → Forecast Service: shows forecast
- Forecast Service → OpenWeather API: requests
- News Bloc → Science News API: fetches
- IoT Monitoring → Telemetry Repository: loads telemetry
- Telemetry Repository → Realtime Database: reads per-user data
- Telemetry Repository → Telemetry / Chart Models: maps to
- Telemetry / Chart Models → IoT Monitoring: renders readings and charts
- IoT Device / Simulator → Realtime Database: writes telemetry
- Realtime Database → Cloud Functions + FCM: triggers alerts
- Disease Detection UI → TFLite Classifier: submits image
- TFLite Classifier → Disease Model: loads and executes
- TFLite Classifier → Disease Detection UI: returns diagnosis
