# shegin733/smart-farming-application architecture

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

- Interactive diagram: https://gitdiagram.com/shegin733/smart-farming-application
- Repository: https://github.com/shegin733/smart-farming-application

## Overview

FarmAlly is a Flutter smart-farming app for greenhouse monitoring and agricultural services. The main user workflow is to open the app, authenticate, and use its screens to control or monitor greenhouse devices or access farming tools. The app’s distinct capabilities include manual and weather-assisted crop prediction, cultivation cost estimation, pest and weed classification, agricultural news, and notifications. The README describes Firebase, ESP8266, and Flask integrations; Flutter implementation details were not sampled, so relationships below rely on those documented statements.

Main entry points: [`lib/crop_prediction/crop_prediction.dart`](https://github.com/shegin733/smart-farming-application/blob/main/lib/crop_prediction/crop_prediction.dart) (Crop prediction), [`lib/iot_control/iot_control.dart`](https://github.com/shegin733/smart-farming-application/blob/main/lib/iot_control/iot_control.dart) (IoT controls), [`lib/crop_prediction/Automatic_climate.dart`](https://github.com/shegin733/smart-farming-application/blob/main/lib/crop_prediction/Automatic_climate.dart) (Automatic climate input), [`lib/screens/home.dart`](https://github.com/shegin733/smart-farming-application/blob/main/lib/screens/home.dart) (Home and navigation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Mobile app"]
  node_home["Home and navigation<br/>[home.dart]"]
  node_auth["Authentication<br/>[login.dart]"]
  node_registration["Registration<br/>[registration.dart]"]
  node_news["Agricultural news<br/>[home.dart]"]
end

subgraph group_greenhouse["Greenhouse IoT"]
  node_iot_ui["IoT controls<br/>[iot_control.dart]"]
  node_esp["ESP8266 controllers"]
end

subgraph group_farming["Farming tools"]
  node_crop["Crop prediction"]
  node_crop_auto["Automatic climate input"]
  node_crop_manual["Manual crop input"]
  node_crop_model["Crop model interface"]
  node_cost["Cost estimation"]
  node_pest["Pest classification"]
  node_weed["Weed classification"]
end

subgraph group_services["Cloud services"]
  node_firebase_db[("Realtime Database")]
  node_weather["Weather API"]
  node_flask["Flask model services"]
  node_firebase_auth["Firebase Authentication"]
  node_fcm["Cloud Messaging"]
  node_firebase_api["Firebase integration<br/>[firebase_api.dart]"]
  node_news_api["News API"]
end

node_user(("Farmer"))

node_user -->|"opens app"| node_home
node_home -->|"offers access"| node_auth
node_auth -->|"authenticates with"| node_firebase_auth
node_registration -->|"registers with"| node_firebase_auth
node_user -->|"controls devices"| node_iot_ui
node_iot_ui -->|"reads device data"| node_firebase_db
node_esp -->|"sends sensor data"| node_firebase_db
node_iot_ui -.->|"controls greenhouse"| node_esp
node_user -->|"requests prediction"| node_crop
node_crop_manual -->|"supplies parameters"| node_crop
node_crop_auto -->|"fetches climate"| node_weather
node_crop_auto -->|"supplies parameters"| node_crop
node_crop -->|"requests prediction"| node_flask
node_crop_model -->|"hosts classifier"| node_flask
node_user -->|"requests estimate"| node_cost
node_cost -->|"sends parameters"| node_flask
node_user -->|"submits image"| node_pest
node_pest -->|"sends image"| node_flask
node_user -->|"submits image"| node_weed
node_weed -->|"sends image"| node_flask
node_user -->|"views news"| node_news
node_news -->|"fetches articles"| node_news_api
node_firebase_api -->|"delivers alerts"| node_fcm
node_fcm -->|"notifies user"| node_user

click node_home "https://github.com/shegin733/smart-farming-application/blob/main/lib/screens/home.dart"
click node_auth "https://github.com/shegin733/smart-farming-application/blob/main/lib/authentication/login.dart"
click node_registration "https://github.com/shegin733/smart-farming-application/blob/main/lib/authentication/registration.dart"
click node_iot_ui "https://github.com/shegin733/smart-farming-application/blob/main/lib/iot_control/iot_control.dart"
click node_esp "https://github.com/shegin733/smart-farming-application/tree/main/IoT"
click node_crop "https://github.com/shegin733/smart-farming-application/blob/main/lib/crop_prediction/crop_prediction.dart"
click node_crop_auto "https://github.com/shegin733/smart-farming-application/blob/main/lib/crop_prediction/Automatic_climate.dart"
click node_crop_manual "https://github.com/shegin733/smart-farming-application/blob/main/lib/crop_prediction/crop_predictHome.dart"
click node_crop_model "https://github.com/shegin733/smart-farming-application/blob/main/lib/crop_prediction/crop_prediction_model.dart"
click node_cost "https://github.com/shegin733/smart-farming-application/blob/main/lib/cost_estimation/cost_estimation.dart"
click node_pest "https://github.com/shegin733/smart-farming-application/blob/main/lib/pest_classification/pest_identification.dart"
click node_weed "https://github.com/shegin733/smart-farming-application/blob/main/lib/weed_classification/weed_identification.dart"
click node_news "https://github.com/shegin733/smart-farming-application/blob/main/lib/screens/home.dart"
click node_firebase_api "https://github.com/shegin733/smart-farming-application/blob/main/lib/services/firebase_api.dart"

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_home,node_auth,node_registration,node_news toneBlue
class node_iot_ui,node_esp toneAmber
class node_crop,node_crop_auto,node_crop_manual,node_crop_model,node_cost,node_pest,node_weed toneMint
class node_firebase_db,node_weather,node_flask,node_firebase_auth,node_fcm,node_firebase_api,node_news_api toneRose
class node_user toneIndigo
```

## Components

### Mobile app

- [Home and navigation](https://github.com/shegin733/smart-farming-application/blob/main/lib/screens/home.dart): `lib/screens/home.dart`
- [Authentication](https://github.com/shegin733/smart-farming-application/blob/main/lib/authentication/login.dart): `lib/authentication/login.dart`
- [Registration](https://github.com/shegin733/smart-farming-application/blob/main/lib/authentication/registration.dart): `lib/authentication/registration.dart`
- [Agricultural news](https://github.com/shegin733/smart-farming-application/blob/main/lib/screens/home.dart): `lib/screens/home.dart`

### Greenhouse IoT

- [IoT controls](https://github.com/shegin733/smart-farming-application/blob/main/lib/iot_control/iot_control.dart): `lib/iot_control/iot_control.dart`
- [ESP8266 controllers](https://github.com/shegin733/smart-farming-application/tree/main/IoT): `IoT`

### Farming tools

- [Crop prediction](https://github.com/shegin733/smart-farming-application/blob/main/lib/crop_prediction/crop_prediction.dart): `lib/crop_prediction/crop_prediction.dart`
- [Automatic climate input](https://github.com/shegin733/smart-farming-application/blob/main/lib/crop_prediction/Automatic_climate.dart): `lib/crop_prediction/Automatic_climate.dart`
- [Manual crop input](https://github.com/shegin733/smart-farming-application/blob/main/lib/crop_prediction/crop_predictHome.dart): `lib/crop_prediction/crop_predictHome.dart`
- [Crop model interface](https://github.com/shegin733/smart-farming-application/blob/main/lib/crop_prediction/crop_prediction_model.dart): `lib/crop_prediction/crop_prediction_model.dart`
- [Cost estimation](https://github.com/shegin733/smart-farming-application/blob/main/lib/cost_estimation/cost_estimation.dart): `lib/cost_estimation/cost_estimation.dart`
- [Pest classification](https://github.com/shegin733/smart-farming-application/blob/main/lib/pest_classification/pest_identification.dart): `lib/pest_classification/pest_identification.dart`
- [Weed classification](https://github.com/shegin733/smart-farming-application/blob/main/lib/weed_classification/weed_identification.dart): `lib/weed_classification/weed_identification.dart`

### Cloud services

- **Realtime Database**
- **Weather API**
- **Flask model services**
- **Firebase Authentication**
- **Cloud Messaging**
- [Firebase integration](https://github.com/shegin733/smart-farming-application/blob/main/lib/services/firebase_api.dart): `lib/services/firebase_api.dart`
- **News API**

### Other components

- **Farmer**

## Connections

- Farmer → Home and navigation: opens app (evidence: `README.md`)
- Home and navigation → Authentication: offers access (evidence: `README.md`)
- Authentication → Firebase Authentication: authenticates with (evidence: `README.md`)
- Registration → Firebase Authentication: registers with (evidence: `README.md`)
- Farmer → IoT controls: controls devices (evidence: `README.md`)
- IoT controls → Realtime Database: reads device data (evidence: `README.md`)
- ESP8266 controllers → Realtime Database: sends sensor data (evidence: `README.md`)
- IoT controls → ESP8266 controllers: controls greenhouse
- Farmer → Crop prediction: requests prediction (evidence: `README.md`)
- Manual crop input → Crop prediction: supplies parameters (evidence: `README.md`)
- Automatic climate input → Weather API: fetches climate (evidence: `README.md`)
- Automatic climate input → Crop prediction: supplies parameters (evidence: `README.md`)
- Crop prediction → Flask model services: requests prediction (evidence: `README.md`)
- Crop model interface → Flask model services: hosts classifier (evidence: `README.md`)
- Farmer → Cost estimation: requests estimate (evidence: `README.md`)
- Cost estimation → Flask model services: sends parameters (evidence: `README.md`)
- Farmer → Pest classification: submits image (evidence: `README.md`)
- Pest classification → Flask model services: sends image (evidence: `README.md`)
- Farmer → Weed classification: submits image (evidence: `README.md`)
- Weed classification → Flask model services: sends image (evidence: `README.md`)
- Farmer → Agricultural news: views news (evidence: `README.md`)
- Agricultural news → News API: fetches articles (evidence: `README.md`)
- Firebase integration → Cloud Messaging: delivers alerts (evidence: `README.md`)
- Cloud Messaging → Farmer: notifies user (evidence: `README.md`)
