# loghadharshanndevarasu/kisan-direct architecture

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

- Interactive diagram: https://gitdiagram.com/loghadharshanndevarasu/kisan-direct
- Repository: https://github.com/loghadharshanndevarasu/kisan-direct

## Overview

KisanDirect is a farm-to-consumer marketplace for loose regional produce, with farmer tools and delivery transparency. The main customer journey is browsing produce, assembling a cart, selecting a doorstep location, and following delivery through arrival inspection; the app is the coordinating UI. Farmer earnings and tax reporting, platform revenue and local advertising, agricultural policy analysis, provenance chat, and PWA support are distinct product branches. README capabilities are included where their implementation was not sampled; those links reflect documented behavior, not verified call wiring. Data is mock-backed, and the sampled server exposes chat and policy endpoints.

Main entry points: [`src/App.tsx`](https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/App.tsx) (App coordinator), [`server.ts`](https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/server.ts) (API server), [`src/components/ConsumerMarketplace.tsx`](https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/ConsumerMarketplace.tsx) (Consumer marketplace), [`src/components/FarmerDashboard.tsx`](https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/FarmerDashboard.tsx) (Farmer dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_market["Marketplace and delivery"]
  node_marketplace["Consumer marketplace"]
  node_cart["Cart modal<br/>[CartModal.tsx]"]
  node_location["Address picker"]
  node_tracking["Delivery tracking"]
  node_inspection["Doorstep inspection"]
  node_notifications["Notifications"]
end

subgraph group_farmer["Farmer and platform tools"]
  node_farmer_dash["Farmer dashboard"]
  node_revenue["Platform revenue"]
  node_ads["Local ad banner<br/>[LocalAdBanner.tsx]"]
end

subgraph group_insight["Transparency and policy"]
  node_provenance["Provenance chatbot"]
  node_policy_ui["Policy dashboard"]
end

subgraph group_runtime["App and runtime"]
  node_app["App coordinator<br/>[App.tsx]"]
  node_catalog["Produce catalog data<br/>[mockAgriData.ts]"]
  node_server["API server<br/>[server.ts]"]
  node_pwa["Service worker<br/>[sw.js]"]
  node_install["Install prompt"]
end

node_consumer(("Consumer"))
node_farmer_actor(("Farmer"))
node_gemini{{"Gemini API"}}

node_consumer -->|"browses"| node_marketplace
node_marketplace -->|"reads produce"| node_catalog
node_consumer -->|"manages cart"| node_cart
node_consumer -->|"sets address"| node_location
node_consumer -->|"tracks order"| node_tracking
node_tracking -->|"opens inspection"| node_inspection
node_consumer -->|"views alerts"| node_notifications
node_farmer_actor -->|"manages harvest"| node_farmer_dash
node_farmer_dash -->|"uses produce data"| node_catalog
node_farmer_actor -->|"asks about batches"| node_provenance
node_provenance -->|"posts chat"| node_server
node_server -.->|"generates response"| node_gemini
node_app -->|"renders policy tab"| node_policy_ui
node_policy_ui -->|"requests AI analysis"| node_server
node_server -.->|"analyzes policy"| node_gemini
node_app -->|"renders platform tab"| node_revenue
node_app -->|"registers worker"| node_pwa
node_consumer -->|"requests install"| node_install
node_install -.->|"uses PWA support"| node_pwa
node_app -->|"coordinates marketplace"| node_marketplace
node_app -->|"coordinates farmer tools"| node_farmer_dash
node_app -->|"renders ad placement"| node_ads

click node_app "https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/App.tsx"
click node_catalog "https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/data/mockAgriData.ts"
click node_marketplace "https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/ConsumerMarketplace.tsx"
click node_cart "https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/CartModal.tsx"
click node_location "https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/MapLocationPicker.tsx"
click node_tracking "https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/DeliveryTrackingModal.tsx"
click node_inspection "https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/DoorstepInspectionModal.tsx"
click node_notifications "https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/NotificationModal.tsx"
click node_farmer_dash "https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/FarmerDashboard.tsx"
click node_revenue "https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/PlatformRevenueManager.tsx"
click node_ads "https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/LocalAdBanner.tsx"
click node_provenance "https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/ProvenanceChatbot.tsx"
click node_policy_ui "https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/AgriPolicyDashboard.tsx"
click node_server "https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/server.ts"
click node_pwa "https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/public/sw.js"
click node_install "https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/MobileInstallModal.tsx"

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_marketplace,node_cart,node_location,node_tracking,node_inspection,node_notifications toneBlue
class node_farmer_dash,node_revenue,node_ads toneAmber
class node_provenance,node_policy_ui,node_gemini toneMint
class node_app,node_catalog,node_server,node_pwa,node_install toneRose
class node_consumer,node_farmer_actor toneIndigo
```

## Components

### Marketplace and delivery

- [Consumer marketplace](https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/ConsumerMarketplace.tsx): `src/components/ConsumerMarketplace.tsx`
- [Cart modal](https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/CartModal.tsx): `src/components/CartModal.tsx`
- [Address picker](https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/MapLocationPicker.tsx): `src/components/MapLocationPicker.tsx`
- [Delivery tracking](https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/DeliveryTrackingModal.tsx): `src/components/DeliveryTrackingModal.tsx`
- [Doorstep inspection](https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/DoorstepInspectionModal.tsx): `src/components/DoorstepInspectionModal.tsx`
- [Notifications](https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/NotificationModal.tsx): `src/components/NotificationModal.tsx`

### Farmer and platform tools

- [Farmer dashboard](https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/FarmerDashboard.tsx): `src/components/FarmerDashboard.tsx`
- [Platform revenue](https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/PlatformRevenueManager.tsx): `src/components/PlatformRevenueManager.tsx`
- [Local ad banner](https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/LocalAdBanner.tsx): `src/components/LocalAdBanner.tsx`

### Transparency and policy

- [Provenance chatbot](https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/ProvenanceChatbot.tsx): `src/components/ProvenanceChatbot.tsx`
- [Policy dashboard](https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/AgriPolicyDashboard.tsx): `src/components/AgriPolicyDashboard.tsx`

### App and runtime

- [App coordinator](https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/App.tsx): `src/App.tsx`
- [Produce catalog data](https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/data/mockAgriData.ts): `src/data/mockAgriData.ts`
- [API server](https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/server.ts): `server.ts`
- [Service worker](https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/public/sw.js): `public/sw.js`
- [Install prompt](https://github.com/loghadharshanndevarasu/kisan-direct/blob/main/src/components/MobileInstallModal.tsx): `src/components/MobileInstallModal.tsx`

### Other components

- **Consumer**
- **Farmer**
- **Gemini API**

## Connections

- Consumer → Consumer marketplace: browses
- Consumer marketplace → Produce catalog data: reads produce
- Consumer → Cart modal: manages cart
- Consumer → Address picker: sets address
- Consumer → Delivery tracking: tracks order
- Delivery tracking → Doorstep inspection: opens inspection
- Consumer → Notifications: views alerts
- Farmer → Farmer dashboard: manages harvest
- Farmer dashboard → Produce catalog data: uses produce data
- Farmer → Provenance chatbot: asks about batches
- Provenance chatbot → API server: posts chat
- API server → Gemini API: generates response
- App coordinator → Policy dashboard: renders policy tab
- Policy dashboard → API server: requests AI analysis
- API server → Gemini API: analyzes policy
- App coordinator → Platform revenue: renders platform tab
- App coordinator → Service worker: registers worker
- Consumer → Install prompt: requests install
- Install prompt → Service worker: uses PWA support
- App coordinator → Consumer marketplace: coordinates marketplace
- App coordinator → Farmer dashboard: coordinates farmer tools
- App coordinator → Local ad banner: renders ad placement
