# modest12345678/cropsdoctorai architecture

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

- Interactive diagram: https://gitdiagram.com/modest12345678/cropsdoctorai
- Repository: https://github.com/modest12345678/cropsdoctorai

## Overview

Crop Doctor AI is a bilingual agricultural-advisory app for Bangladesh, delivered through the web/PWA and Android. The documented farmer workflow spans photo-based disease diagnosis, input calculations, soil/weather intelligence, dated crop planning, and saved farm records. The graph includes the evidenced web/API entry path and core domain services; additional documented capabilities are represented where paths are supported. Some frontend routes and backend integrations are unsampled, so those connections are omitted rather than inferred.

Main entry points: [`server/routes.ts`](https://github.com/modest12345678/cropsdoctorai/blob/main/server/routes.ts) (API routes), [`server/services/soilService.ts`](https://github.com/modest12345678/cropsdoctorai/blob/main/server/services/soilService.ts) (Soil assessment), [`client/src/App.tsx`](https://github.com/modest12345678/cropsdoctorai/blob/main/client/src/App.tsx) (Web and PWA), [`client/src/lib/queryClient.ts`](https://github.com/modest12345678/cropsdoctorai/blob/main/client/src/lib/queryClient.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Farmer experience"]
  node_webapp["Web and PWA<br/>[App.tsx]"]
  node_api_client["API client<br/>[queryClient.ts]"]
end

subgraph group_api["API and records"]
  node_routes["API routes<br/>[routes.ts]"]
  node_app["HTTP app<br/>[app.ts]"]
  node_storage["Storage interface<br/>[storage.ts]"]
  node_db_storage["Postgres storage<br/>[dbStorage.ts]"]
  node_database[("Postgres records<br/>[schema.ts]")]
end

subgraph group_advisory["Agronomic advisory"]
  node_ai_diagnosis["Disease and chat AI<br/>[openai.ts]"]
  node_fertilizer["Fertilizer advice<br/>[fertilizerBD.ts]"]
  node_fertilizer_reference["FRG fertilizer data"]
  node_pesticides["Pesticide advice<br/>[pesticideBD.ts]"]
  node_pesticide_registry["Pesticide registry<br/>[pesticideData.ts]"]
  node_soil["Soil assessment<br/>[soilService.ts]"]
  node_earth_engine["Satellite moisture<br/>[earthEngine.ts]"]
  node_land_type["Land classification<br/>[landTypeService.ts]"]
  node_soil_baseline["AEZ soil baseline"]
  node_microbiology["Soil microbiology"]
  node_weather["Field weather<br/>[weatherService.ts]"]
end

subgraph group_planning["Farm planning"]
  node_crop_stages["Crop operation stages<br/>[cropStages.ts]"]
  node_crop_schedule["Dated crop schedule<br/>[cropSchedule.ts]"]
end

node_farmer(("Farmer"))
node_weather_provider(("Weather data"))
node_soil_provider(("Earth Engine"))

node_farmer -->|"uses"| node_webapp
node_webapp -->|"requests data"| node_api_client
node_api_client -->|"sends HTTP"| node_app
node_app -->|"registers routes"| node_routes
node_routes -->|"analyzes crop"| node_ai_diagnosis
node_routes -->|"requests rates"| node_fertilizer
node_fertilizer -->|"reads standards"| node_fertilizer_reference
node_routes -->|"requests dose"| node_pesticides
node_pesticides -->|"reads registry"| node_pesticide_registry
node_routes -->|"requests assessment"| node_soil
node_soil -->|"fetches moisture"| node_earth_engine
node_earth_engine -->|"queries satellite"| node_soil_provider
node_soil -->|"detects land type"| node_land_type
node_soil -->|"loads baseline"| node_soil_baseline
node_soil -->|"loads profile"| node_microbiology
node_routes -->|"requests forecast"| node_weather
node_weather -.->|"gets forecast"| node_weather_provider
node_crop_schedule -->|"resolves offsets"| node_crop_stages
node_routes -->|"reads and writes"| node_storage
node_storage -->|"delegates persistence"| node_db_storage
node_db_storage -->|"queries schema"| node_database
node_routes -->|"builds crop plan"| node_crop_schedule

click node_webapp "https://github.com/modest12345678/cropsdoctorai/blob/main/client/src/App.tsx"
click node_api_client "https://github.com/modest12345678/cropsdoctorai/blob/main/client/src/lib/queryClient.ts"
click node_routes "https://github.com/modest12345678/cropsdoctorai/blob/main/server/routes.ts"
click node_app "https://github.com/modest12345678/cropsdoctorai/blob/main/server/app.ts"
click node_ai_diagnosis "https://github.com/modest12345678/cropsdoctorai/blob/main/server/openai.ts"
click node_fertilizer "https://github.com/modest12345678/cropsdoctorai/blob/main/server/services/fertilizerBD.ts"
click node_fertilizer_reference "https://github.com/modest12345678/cropsdoctorai/blob/main/server/services/research/frgFertilizerData.ts"
click node_pesticides "https://github.com/modest12345678/cropsdoctorai/blob/main/server/services/pesticideBD.ts"
click node_pesticide_registry "https://github.com/modest12345678/cropsdoctorai/blob/main/server/services/pesticideData.ts"
click node_soil "https://github.com/modest12345678/cropsdoctorai/blob/main/server/services/soilService.ts"
click node_earth_engine "https://github.com/modest12345678/cropsdoctorai/blob/main/server/services/earthEngine.ts"
click node_land_type "https://github.com/modest12345678/cropsdoctorai/blob/main/server/services/landTypeService.ts"
click node_soil_baseline "https://github.com/modest12345678/cropsdoctorai/blob/main/server/services/research/dataSources/bdSoilAezBaseline.ts"
click node_microbiology "https://github.com/modest12345678/cropsdoctorai/blob/main/server/services/research/dataSources/bdSoilMicrobiology.ts"
click node_weather "https://github.com/modest12345678/cropsdoctorai/blob/main/server/services/weatherService.ts"
click node_crop_stages "https://github.com/modest12345678/cropsdoctorai/blob/main/shared/cropStages.ts"
click node_crop_schedule "https://github.com/modest12345678/cropsdoctorai/blob/main/shared/cropSchedule.ts"
click node_storage "https://github.com/modest12345678/cropsdoctorai/blob/main/server/storage.ts"
click node_db_storage "https://github.com/modest12345678/cropsdoctorai/blob/main/server/dbStorage.ts"
click node_database "https://github.com/modest12345678/cropsdoctorai/blob/main/shared/schema.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_webapp,node_api_client toneBlue
class node_routes,node_app,node_storage,node_db_storage,node_database toneAmber
class node_ai_diagnosis,node_fertilizer,node_fertilizer_reference,node_pesticides,node_pesticide_registry,node_soil,node_earth_engine,node_land_type,node_soil_baseline,node_microbiology,node_weather toneMint
class node_crop_stages,node_crop_schedule toneRose
class node_farmer,node_weather_provider,node_soil_provider toneIndigo
```

## Components

### Farmer experience

- [Web and PWA](https://github.com/modest12345678/cropsdoctorai/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [API client](https://github.com/modest12345678/cropsdoctorai/blob/main/client/src/lib/queryClient.ts): `client/src/lib/queryClient.ts`

### API and records

- [API routes](https://github.com/modest12345678/cropsdoctorai/blob/main/server/routes.ts): `server/routes.ts`
- [HTTP app](https://github.com/modest12345678/cropsdoctorai/blob/main/server/app.ts): `server/app.ts`
- [Storage interface](https://github.com/modest12345678/cropsdoctorai/blob/main/server/storage.ts): `server/storage.ts`
- [Postgres storage](https://github.com/modest12345678/cropsdoctorai/blob/main/server/dbStorage.ts): `server/dbStorage.ts`
- [Postgres records](https://github.com/modest12345678/cropsdoctorai/blob/main/shared/schema.ts): `shared/schema.ts`

### Agronomic advisory

- [Disease and chat AI](https://github.com/modest12345678/cropsdoctorai/blob/main/server/openai.ts): `server/openai.ts`
- [Fertilizer advice](https://github.com/modest12345678/cropsdoctorai/blob/main/server/services/fertilizerBD.ts): `server/services/fertilizerBD.ts`
- [FRG fertilizer data](https://github.com/modest12345678/cropsdoctorai/blob/main/server/services/research/frgFertilizerData.ts): `server/services/research/frgFertilizerData.ts`
- [Pesticide advice](https://github.com/modest12345678/cropsdoctorai/blob/main/server/services/pesticideBD.ts): `server/services/pesticideBD.ts`
- [Pesticide registry](https://github.com/modest12345678/cropsdoctorai/blob/main/server/services/pesticideData.ts): `server/services/pesticideData.ts`
- [Soil assessment](https://github.com/modest12345678/cropsdoctorai/blob/main/server/services/soilService.ts): `server/services/soilService.ts`
- [Satellite moisture](https://github.com/modest12345678/cropsdoctorai/blob/main/server/services/earthEngine.ts): `server/services/earthEngine.ts`
- [Land classification](https://github.com/modest12345678/cropsdoctorai/blob/main/server/services/landTypeService.ts): `server/services/landTypeService.ts`
- [AEZ soil baseline](https://github.com/modest12345678/cropsdoctorai/blob/main/server/services/research/dataSources/bdSoilAezBaseline.ts): `server/services/research/dataSources/bdSoilAezBaseline.ts`
- [Soil microbiology](https://github.com/modest12345678/cropsdoctorai/blob/main/server/services/research/dataSources/bdSoilMicrobiology.ts): `server/services/research/dataSources/bdSoilMicrobiology.ts`
- [Field weather](https://github.com/modest12345678/cropsdoctorai/blob/main/server/services/weatherService.ts): `server/services/weatherService.ts`

### Farm planning

- [Crop operation stages](https://github.com/modest12345678/cropsdoctorai/blob/main/shared/cropStages.ts): `shared/cropStages.ts`
- [Dated crop schedule](https://github.com/modest12345678/cropsdoctorai/blob/main/shared/cropSchedule.ts): `shared/cropSchedule.ts`

### Other components

- **Farmer**
- **Weather data**
- **Earth Engine**

## Connections

- Farmer → Web and PWA: uses
- Web and PWA → API client: requests data (evidence: `client/src/App.tsx`)
- API client → HTTP app: sends HTTP (evidence: `client/src/lib/queryClient.ts`)
- HTTP app → API routes: registers routes (evidence: `server/app.ts`)
- API routes → Disease and chat AI: analyzes crop (evidence: `server/routes.ts`)
- API routes → Fertilizer advice: requests rates (evidence: `server/routes.ts`)
- Fertilizer advice → FRG fertilizer data: reads standards (evidence: `server/services/fertilizerBD.ts`)
- API routes → Pesticide advice: requests dose (evidence: `server/routes.ts`)
- Pesticide advice → Pesticide registry: reads registry (evidence: `server/services/pesticideBD.ts`)
- API routes → Soil assessment: requests assessment (evidence: `server/routes.ts`)
- Soil assessment → Satellite moisture: fetches moisture (evidence: `server/services/soilService.ts`)
- Satellite moisture → Earth Engine: queries satellite (evidence: `server/services/earthEngine.ts`)
- Soil assessment → Land classification: detects land type (evidence: `server/services/soilService.ts`)
- Soil assessment → AEZ soil baseline: loads baseline (evidence: `server/services/soilService.ts`)
- Soil assessment → Soil microbiology: loads profile (evidence: `server/services/soilService.ts`)
- API routes → Field weather: requests forecast (evidence: `server/routes.ts`)
- Field weather → Weather data: gets forecast
- Dated crop schedule → Crop operation stages: resolves offsets (evidence: `shared/cropSchedule.ts`)
- API routes → Storage interface: reads and writes (evidence: `server/routes.ts`)
- Storage interface → Postgres storage: delegates persistence (evidence: `server/storage.ts`)
- Postgres storage → Postgres records: queries schema (evidence: `server/dbStorage.ts`)
- API routes → Dated crop schedule: builds crop plan (evidence: `server/routes.ts`)
