# thouhidshaik-1920/crop-pro architecture

> Architecture diagram of the GitHub repository thouhidshaik-1920/crop-pro, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thouhidshaik-1920/crop-pro
- Repository: https://github.com/thouhidshaik-1920/crop-pro

## Overview

PAYIR is a browser-based crop monitoring and farm-management application, designed to work locally with optional Supabase integration. Users enter through the routed dashboard and manage fields, inspect telemetry and health, simulate sensor conditions, diagnose disease, control simulated irrigation, review alerts and reports, and configure settings. The shared context coordinates application state and persistence; domain engines handle health scoring, alerts, simulation, and irrigation. Source excerpts establish key orchestration links; some feature details and integrations are documented in the README but their full implementations were not sampled.

Main entry points: [`src/context/PayirContext.tsx`](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/context/PayirContext.tsx) (Application state), [`src/App.tsx`](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/App.tsx) (Routed application), [`src/pages/DashboardPage.tsx`](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/pages/DashboardPage.tsx) (Dashboard), [`src/pages/DiseaseDetectionPage.tsx`](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/pages/DiseaseDetectionPage.tsx) (Disease detection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application shell"]
  node_app["Routed application<br/>[App.tsx]"]
  node_layout["App layout<br/>[AppLayout.tsx]"]
  node_common["Shared interface"]
end

subgraph group_farm["Farm monitoring"]
  node_dashboard["Dashboard<br/>[DashboardPage.tsx]"]
  node_health["Health scoring<br/>[healthEngine.ts]"]
  node_fields["Field management<br/>[FieldsPage.tsx]"]
  node_fieldmap["Interactive field map<br/>[FieldMapPage.tsx]"]
  node_alerts["Alerts<br/>[AlertsPage.tsx]"]
  node_alertengine["Alert evaluation<br/>[alertEngine.ts]"]
end

subgraph group_operations["Farm operations"]
  node_simulator["Sensor simulator<br/>[SimulatorPage.tsx]"]
  node_simengine["Reading generation<br/>[simulatorEngine.ts]"]
  node_disease["Disease detection"]
  node_diseaseclassifier["Disease classifier"]
  node_diseasekb["Disease knowledge base"]
  node_irrigation["Irrigation management<br/>[IrrigationPage.tsx]"]
  node_irrigationengine["Irrigation simulation"]
  node_reports["Reports and analytics<br/>[ReportsPage.tsx]"]
  node_reportservice["Report aggregation<br/>[reportService.ts]"]
end

subgraph group_platform["State and services"]
  node_context["Application state<br/>[PayirContext.tsx]"]
  node_storage[("Local persistence<br/>[storageService.ts]")]
  node_supabase["Supabase integration<br/>[supabaseService.ts]"]
  node_settings["Settings and profile<br/>[SettingsPage.tsx]"]
  node_translations["Bilingual UI<br/>[useTranslation.ts]"]
  node_translationdata["Translation catalog<br/>[translations.ts]"]
end

node_farmer(("Farm user"))

node_farmer -->|"uses"| node_app
node_app -->|"provides state"| node_context
node_app -->|"renders"| node_layout
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_simulator
node_app -->|"routes to"| node_disease
node_app -->|"routes to"| node_irrigation
node_app -->|"routes to"| node_alerts
node_app -->|"routes to"| node_reports
node_app -->|"routes to"| node_fields
node_app -->|"routes to"| node_fieldmap
node_app -->|"routes to"| node_settings
node_layout -->|"uses"| node_common
node_dashboard -->|"reads state"| node_context
node_dashboard -->|"uses scoring"| node_health
node_dashboard -->|"uses aggregation"| node_reportservice
node_fields -->|"updates fields"| node_context
node_fieldmap -.->|"uses field data"| node_context
node_alerts -->|"reads alerts"| node_context
node_context -->|"evaluates alerts"| node_alertengine
node_alertengine -->|"evaluates health"| node_health
node_simulator -->|"controls simulation"| node_context
node_context -.->|"generates readings"| node_simengine
node_disease -->|"records diagnosis"| node_context
node_disease -->|"requests classification"| node_diseaseclassifier
node_disease -->|"uses profiles"| node_diseasekb
node_irrigation -->|"controls irrigation"| node_context
node_context -->|"steps sessions"| node_irrigationengine
node_reports -->|"reads records"| node_context
node_reports -->|"aggregates readings"| node_reportservice
node_settings -->|"updates settings"| node_context
node_settings -->|"manages backup"| node_storage
node_context -->|"loads and saves"| node_storage
node_context -->|"checks configuration"| node_supabase
node_supabase -.->|"optional sync"| node_farmer
node_dashboard -->|"renders components"| node_common
node_reports -->|"renders badges"| node_common
node_translations -->|"reads language"| node_context
node_translations -->|"looks up strings"| node_translationdata

click node_app "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/App.tsx"
click node_layout "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/layouts/AppLayout.tsx"
click node_common "https://github.com/thouhidshaik-1920/crop-pro/tree/main/src/components/common"
click node_dashboard "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/pages/DashboardPage.tsx"
click node_health "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/services/healthEngine.ts"
click node_fields "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/pages/FieldsPage.tsx"
click node_fieldmap "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/pages/FieldMapPage.tsx"
click node_alerts "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/pages/AlertsPage.tsx"
click node_alertengine "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/services/alertEngine.ts"
click node_simulator "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/pages/SimulatorPage.tsx"
click node_simengine "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/services/simulatorEngine.ts"
click node_disease "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/pages/DiseaseDetectionPage.tsx"
click node_diseaseclassifier "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/services/diseaseClassifier.ts"
click node_diseasekb "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/data/diseaseKnowledgeBase.ts"
click node_irrigation "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/pages/IrrigationPage.tsx"
click node_irrigationengine "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/services/irrigationEngine.ts"
click node_reports "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/pages/ReportsPage.tsx"
click node_reportservice "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/services/reportService.ts"
click node_context "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/context/PayirContext.tsx"
click node_storage "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/services/storageService.ts"
click node_supabase "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/services/supabaseService.ts"
click node_settings "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/pages/SettingsPage.tsx"
click node_translations "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/hooks/useTranslation.ts"
click node_translationdata "https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/data/translations.ts"

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_layout,node_common,node_farmer toneBlue
class node_dashboard,node_health,node_fields,node_fieldmap,node_alerts,node_alertengine toneAmber
class node_simulator,node_simengine,node_disease,node_diseaseclassifier,node_diseasekb,node_irrigation,node_irrigationengine,node_reports,node_reportservice toneMint
class node_context,node_storage,node_supabase,node_settings,node_translations,node_translationdata toneRose
```

## Components

### Application shell

- [Routed application](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/App.tsx): `src/App.tsx`
- [App layout](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/layouts/AppLayout.tsx): `src/layouts/AppLayout.tsx`
- [Shared interface](https://github.com/thouhidshaik-1920/crop-pro/tree/main/src/components/common): `src/components/common`

### Farm monitoring

- [Dashboard](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/pages/DashboardPage.tsx): `src/pages/DashboardPage.tsx`
- [Health scoring](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/services/healthEngine.ts): `src/services/healthEngine.ts`
- [Field management](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/pages/FieldsPage.tsx): `src/pages/FieldsPage.tsx`
- [Interactive field map](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/pages/FieldMapPage.tsx): `src/pages/FieldMapPage.tsx`
- [Alerts](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/pages/AlertsPage.tsx): `src/pages/AlertsPage.tsx`
- [Alert evaluation](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/services/alertEngine.ts): `src/services/alertEngine.ts`

### Farm operations

- [Sensor simulator](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/pages/SimulatorPage.tsx): `src/pages/SimulatorPage.tsx`
- [Reading generation](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/services/simulatorEngine.ts): `src/services/simulatorEngine.ts`
- [Disease detection](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/pages/DiseaseDetectionPage.tsx): `src/pages/DiseaseDetectionPage.tsx`
- [Disease classifier](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/services/diseaseClassifier.ts): `src/services/diseaseClassifier.ts`
- [Disease knowledge base](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/data/diseaseKnowledgeBase.ts): `src/data/diseaseKnowledgeBase.ts`
- [Irrigation management](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/pages/IrrigationPage.tsx): `src/pages/IrrigationPage.tsx`
- [Irrigation simulation](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/services/irrigationEngine.ts): `src/services/irrigationEngine.ts`
- [Reports and analytics](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/pages/ReportsPage.tsx): `src/pages/ReportsPage.tsx`
- [Report aggregation](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/services/reportService.ts): `src/services/reportService.ts`

### State and services

- [Application state](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/context/PayirContext.tsx): `src/context/PayirContext.tsx`
- [Local persistence](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/services/storageService.ts): `src/services/storageService.ts`
- [Supabase integration](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/services/supabaseService.ts): `src/services/supabaseService.ts`
- [Settings and profile](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/pages/SettingsPage.tsx): `src/pages/SettingsPage.tsx`
- [Bilingual UI](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/hooks/useTranslation.ts): `src/hooks/useTranslation.ts`
- [Translation catalog](https://github.com/thouhidshaik-1920/crop-pro/blob/main/src/data/translations.ts): `src/data/translations.ts`

### Other components

- **Farm user**

## Connections

- Farm user → Routed application: uses
- Routed application → Application state: provides state (evidence: `src/App.tsx`)
- Routed application → App layout: renders (evidence: `src/App.tsx`)
- Routed application → Dashboard: routes to (evidence: `src/App.tsx`)
- Routed application → Sensor simulator: routes to (evidence: `src/App.tsx`)
- Routed application → Disease detection: routes to (evidence: `src/App.tsx`)
- Routed application → Irrigation management: routes to (evidence: `src/App.tsx`)
- Routed application → Alerts: routes to (evidence: `src/App.tsx`)
- Routed application → Reports and analytics: routes to (evidence: `src/App.tsx`)
- Routed application → Field management: routes to (evidence: `src/App.tsx`)
- Routed application → Interactive field map: routes to (evidence: `src/App.tsx`)
- Routed application → Settings and profile: routes to (evidence: `src/App.tsx`)
- App layout → Shared interface: uses (evidence: `src/layouts/AppLayout.tsx`)
- Dashboard → Application state: reads state (evidence: `src/pages/DashboardPage.tsx`)
- Dashboard → Health scoring: uses scoring (evidence: `src/pages/DashboardPage.tsx`)
- Dashboard → Report aggregation: uses aggregation (evidence: `src/pages/DashboardPage.tsx`)
- Field management → Application state: updates fields (evidence: `src/pages/FieldsPage.tsx`)
- Interactive field map → Application state: uses field data
- Alerts → Application state: reads alerts (evidence: `src/pages/AlertsPage.tsx`)
- Application state → Alert evaluation: evaluates alerts (evidence: `src/context/PayirContext.tsx`)
- Alert evaluation → Health scoring: evaluates health (evidence: `src/services/alertEngine.ts`)
- Sensor simulator → Application state: controls simulation (evidence: `src/pages/SimulatorPage.tsx`)
- Application state → Reading generation: generates readings (evidence: `src/context/PayirContext.tsx`)
- Disease detection → Application state: records diagnosis (evidence: `src/pages/DiseaseDetectionPage.tsx`)
- Disease detection → Disease classifier: requests classification (evidence: `src/pages/DiseaseDetectionPage.tsx`)
- Disease detection → Disease knowledge base: uses profiles (evidence: `src/pages/DiseaseDetectionPage.tsx`)
- Irrigation management → Application state: controls irrigation (evidence: `src/pages/IrrigationPage.tsx`)
- Application state → Irrigation simulation: steps sessions (evidence: `src/context/PayirContext.tsx`)
- Reports and analytics → Application state: reads records (evidence: `src/pages/ReportsPage.tsx`)
- Reports and analytics → Report aggregation: aggregates readings (evidence: `src/pages/ReportsPage.tsx`)
- Settings and profile → Application state: updates settings (evidence: `src/pages/SettingsPage.tsx`)
- Settings and profile → Local persistence: manages backup (evidence: `src/pages/SettingsPage.tsx`)
- Application state → Local persistence: loads and saves (evidence: `src/context/PayirContext.tsx`)
- Application state → Supabase integration: checks configuration (evidence: `src/context/PayirContext.tsx`)
- Supabase integration → Farm user: optional sync
- Dashboard → Shared interface: renders components (evidence: `src/pages/DashboardPage.tsx`)
- Reports and analytics → Shared interface: renders badges (evidence: `src/pages/ReportsPage.tsx`)
- Bilingual UI → Application state: reads language (evidence: `src/hooks/useTranslation.ts`)
- Bilingual UI → Translation catalog: looks up strings (evidence: `src/hooks/useTranslation.ts`)
