# suchithrasaravanan05-afk/kisansense-ai architecture

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

- Interactive diagram: https://gitdiagram.com/suchithrasaravanan05-afk/kisansense-ai
- Repository: https://github.com/suchithrasaravanan05-afk/kisansense-ai

## Overview

KisanSense AI is a multilingual farm-advisory web app. A farmer enters through the app, manages field and crop records, and can request a crop-image assessment; the app also presents irrigation, fertilizer, weather, activity-history, and expert-review capabilities. The central page coordinates state and services, while browser storage supports offline records and queued synchronization. Vision analysis has a server API entry point and a provider-selection layer with validation and demo fallback. The README is empty, so capability scope comes from the source tree; unsampled view-to-service connections are not inferred.

Main entry points: [`src/app/page.tsx`](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/app/page.tsx) (App coordinator), [`src/services/vision/index.ts`](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/vision/index.ts) (Vision dispatcher), [`src/services/imageAnalysisService.ts`](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/imageAnalysisService.ts) (Image analysis), [`src/components/views/ScanView.tsx`](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/components/views/ScanView.tsx) (Crop scanning)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_app["App coordinator<br/>[page.tsx]"]
  node_settings["Settings<br/>[SettingsView.tsx]"]
end

subgraph group_farm["Farm workflows"]
  node_scanview["Crop scanning<br/>[ScanView.tsx]"]
  node_scanresult["Scan results<br/>[ScanResultView.tsx]"]
  node_dashboard["Farm dashboard<br/>[DashboardView.tsx]"]
  node_water["Water planning<br/>[WaterView.tsx]"]
  node_fertilizer["Fertilizer advice<br/>[FertilizerView.tsx]"]
  node_timeline["Field timeline<br/>[TimelineView.tsx]"]
  node_expert["Expert review<br/>[ExpertView.tsx]"]
end

subgraph group_advice["Advisory services"]
  node_imageanalysis["Image analysis"]
  node_visionapi["Scan API<br/>[route.ts]"]
  node_vision["Vision dispatcher<br/>[index.ts]"]
  node_demo["Demo provider<br/>[demoProvider.ts]"]
  node_gemini["Gemini provider<br/>[geminiProvider.ts]"]
  node_openai["OpenAI provider<br/>[openaiProvider.ts]"]
  node_validator["Response validator<br/>[validator.ts]"]
  node_irrigation["Irrigation services"]
  node_irrigationcalc["Irrigation calculator"]
  node_fertilizersvc["Fertilizer service"]
  node_weather["Weather service<br/>[weatherService.ts]"]
  node_weatherapi["Weather API<br/>[route.ts]"]
end

subgraph group_data["Data and platform"]
  node_storage[("Farm data storage<br/>[storageService.ts]")]
  node_types["Domain types<br/>[index.ts]"]
  node_translations["Translations<br/>[translations.ts]"]
  node_mockdata["Demo farm data<br/>[mockData.ts]"]
  node_samples["Sample scan images<br/>[sampleImages.ts]"]
  node_serviceworker["Offline worker<br/>[sw.js]"]
end

node_farmer(("Farmer"))

node_farmer -->|"uses"| node_app
node_app -->|"reads and updates"| node_storage
node_app -->|"fetches weather"| node_weather
node_app -->|"translates labels"| node_translations
node_app -.->|"renders"| node_dashboard
node_app -.->|"renders"| node_scanview
node_app -.->|"renders"| node_scanresult
node_app -.->|"renders"| node_water
node_app -.->|"renders"| node_fertilizer
node_app -.->|"renders"| node_timeline
node_app -.->|"renders"| node_expert
node_app -.->|"renders"| node_settings
node_scanview -->|"requests analysis"| node_imageanalysis
node_imageanalysis -->|"checks samples"| node_samples
node_imageanalysis -->|"posts image"| node_visionapi
node_visionapi -->|"analyzes crop"| node_vision
node_vision -->|"selects or falls back"| node_demo
node_vision -->|"dispatches"| node_gemini
node_vision -->|"dispatches"| node_openai
node_demo -->|"validates output"| node_validator
node_gemini -.->|"validates output"| node_validator
node_openai -.->|"validates output"| node_validator
node_water -->|"calculates needs"| node_irrigationcalc
node_irrigation -->|"uses calculations"| node_irrigationcalc
node_app -.->|"fetches recommendations"| node_irrigation
node_app -.->|"fetches advice"| node_fertilizersvc
node_weather -->|"caches weather"| node_storage
node_storage -->|"loads defaults"| node_mockdata
node_scanview -.->|"compresses images"| node_imageanalysis
node_app -.->|"registers worker"| node_serviceworker

click node_app "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/app/page.tsx"
click node_scanview "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/components/views/ScanView.tsx"
click node_scanresult "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/components/views/ScanResultView.tsx"
click node_dashboard "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/components/views/DashboardView.tsx"
click node_water "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/components/views/WaterView.tsx"
click node_fertilizer "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/components/views/FertilizerView.tsx"
click node_timeline "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/components/views/TimelineView.tsx"
click node_expert "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/components/views/ExpertView.tsx"
click node_settings "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/components/views/SettingsView.tsx"
click node_imageanalysis "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/imageAnalysisService.ts"
click node_visionapi "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/app/api/scan/route.ts"
click node_vision "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/vision/index.ts"
click node_demo "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/vision/providers/demoProvider.ts"
click node_gemini "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/vision/providers/geminiProvider.ts"
click node_openai "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/vision/providers/openaiProvider.ts"
click node_validator "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/vision/validator.ts"
click node_irrigation "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/irrigationService.ts"
click node_irrigationcalc "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/irrigationCalculator.ts"
click node_fertilizersvc "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/fertilizerService.ts"
click node_weather "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/weatherService.ts"
click node_weatherapi "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/app/api/weather/route.ts"
click node_storage "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/storageService.ts"
click node_types "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/types/index.ts"
click node_translations "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/i18n/translations.ts"
click node_mockdata "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/data/mockData.ts"
click node_samples "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/data/sampleImages.ts"
click node_serviceworker "https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/public/sw.js"

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_settings toneBlue
class node_scanview,node_scanresult,node_dashboard,node_water,node_fertilizer,node_timeline,node_expert toneAmber
class node_imageanalysis,node_visionapi,node_vision,node_demo,node_gemini,node_openai,node_validator,node_irrigation,node_irrigationcalc,node_fertilizersvc,node_weather,node_weatherapi toneMint
class node_storage,node_types,node_translations,node_mockdata,node_samples,node_serviceworker toneRose
class node_farmer toneIndigo
```

## Components

### Application

- [App coordinator](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Settings](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/components/views/SettingsView.tsx): `src/components/views/SettingsView.tsx`

### Farm workflows

- [Crop scanning](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/components/views/ScanView.tsx): `src/components/views/ScanView.tsx`
- [Scan results](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/components/views/ScanResultView.tsx): `src/components/views/ScanResultView.tsx`
- [Farm dashboard](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/components/views/DashboardView.tsx): `src/components/views/DashboardView.tsx`
- [Water planning](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/components/views/WaterView.tsx): `src/components/views/WaterView.tsx`
- [Fertilizer advice](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/components/views/FertilizerView.tsx): `src/components/views/FertilizerView.tsx`
- [Field timeline](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/components/views/TimelineView.tsx): `src/components/views/TimelineView.tsx`
- [Expert review](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/components/views/ExpertView.tsx): `src/components/views/ExpertView.tsx`

### Advisory services

- [Image analysis](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/imageAnalysisService.ts): `src/services/imageAnalysisService.ts`
- [Scan API](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/app/api/scan/route.ts): `src/app/api/scan/route.ts`
- [Vision dispatcher](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/vision/index.ts): `src/services/vision/index.ts`
- [Demo provider](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/vision/providers/demoProvider.ts): `src/services/vision/providers/demoProvider.ts`
- [Gemini provider](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/vision/providers/geminiProvider.ts): `src/services/vision/providers/geminiProvider.ts`
- [OpenAI provider](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/vision/providers/openaiProvider.ts): `src/services/vision/providers/openaiProvider.ts`
- [Response validator](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/vision/validator.ts): `src/services/vision/validator.ts`
- [Irrigation services](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/irrigationService.ts): `src/services/irrigationService.ts`
- [Irrigation calculator](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/irrigationCalculator.ts): `src/services/irrigationCalculator.ts`
- [Fertilizer service](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/fertilizerService.ts): `src/services/fertilizerService.ts`
- [Weather service](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/weatherService.ts): `src/services/weatherService.ts`
- [Weather API](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/app/api/weather/route.ts): `src/app/api/weather/route.ts`

### Data and platform

- [Farm data storage](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/services/storageService.ts): `src/services/storageService.ts`
- [Domain types](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/types/index.ts): `src/types/index.ts`
- [Translations](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/i18n/translations.ts): `src/i18n/translations.ts`
- [Demo farm data](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/data/mockData.ts): `src/data/mockData.ts`
- [Sample scan images](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/src/data/sampleImages.ts): `src/data/sampleImages.ts`
- [Offline worker](https://github.com/suchithrasaravanan05-afk/kisansense-ai/blob/main/public/sw.js): `public/sw.js`

### Other components

- **Farmer**

## Connections

- Farmer → App coordinator: uses
- App coordinator → Farm data storage: reads and updates (evidence: `src/app/page.tsx`)
- App coordinator → Weather service: fetches weather (evidence: `src/app/page.tsx`)
- App coordinator → Translations: translates labels (evidence: `src/app/page.tsx`)
- App coordinator → Farm dashboard: renders (evidence: `src/app/page.tsx`)
- App coordinator → Crop scanning: renders (evidence: `src/app/page.tsx`)
- App coordinator → Scan results: renders (evidence: `src/app/page.tsx`)
- App coordinator → Water planning: renders (evidence: `src/app/page.tsx`)
- App coordinator → Fertilizer advice: renders (evidence: `src/app/page.tsx`)
- App coordinator → Field timeline: renders (evidence: `src/app/page.tsx`)
- App coordinator → Expert review: renders (evidence: `src/app/page.tsx`)
- App coordinator → Settings: renders (evidence: `src/app/page.tsx`)
- Crop scanning → Image analysis: requests analysis (evidence: `src/components/views/ScanView.tsx`)
- Image analysis → Sample scan images: checks samples (evidence: `src/services/imageAnalysisService.ts`)
- Image analysis → Scan API: posts image (evidence: `src/services/imageAnalysisService.ts`)
- Scan API → Vision dispatcher: analyzes crop (evidence: `src/app/api/scan/route.ts`)
- Vision dispatcher → Demo provider: selects or falls back (evidence: `src/services/vision/index.ts`)
- Vision dispatcher → Gemini provider: dispatches (evidence: `src/services/vision/index.ts`)
- Vision dispatcher → OpenAI provider: dispatches (evidence: `src/services/vision/index.ts`)
- Demo provider → Response validator: validates output (evidence: `src/services/vision/providers/demoProvider.ts`)
- Gemini provider → Response validator: validates output (evidence: `src/services/vision/providers/geminiProvider.ts`)
- OpenAI provider → Response validator: validates output (evidence: `src/services/vision/providers/openaiProvider.ts`)
- Water planning → Irrigation calculator: calculates needs (evidence: `src/components/views/WaterView.tsx`)
- Irrigation services → Irrigation calculator: uses calculations (evidence: `src/services/irrigationService.ts`)
- App coordinator → Irrigation services: fetches recommendations (evidence: `src/app/page.tsx`)
- App coordinator → Fertilizer service: fetches advice
- Weather service → Farm data storage: caches weather (evidence: `src/services/weatherService.ts`)
- Farm data storage → Demo farm data: loads defaults (evidence: `src/services/storageService.ts`)
- Crop scanning → Image analysis: compresses images (evidence: `src/components/views/ScanView.tsx`)
- App coordinator → Offline worker: registers worker
