# yohan-987/cropwise architecture

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

- Interactive diagram: https://gitdiagram.com/yohan-987/cropwise
- Repository: https://github.com/yohan-987/cropwise

## Overview

CropWise is a full-stack farmer-to-market decision and linkage platform. Farmers compare market prices and transport-adjusted net returns, get explainable sell/hold advice and forecasts, then can find buyers, list produce, negotiate transport and track transactions. Buyers use demand and verification workflows; shared selling, storage, quality assessment, weather and multilingual voice/text assistance extend the product. The map preserves documented capabilities even where source was not sampled; those paths and relationships are limited to README and tree evidence.

Main entry points: [`backend/app/main.py`](https://github.com/yohan-987/cropwise/blob/main/backend/app/main.py) (Backend API), [`backend/app/routers/market.py`](https://github.com/yohan-987/cropwise/blob/main/backend/app/routers/market.py) (Market intelligence), [`backend/app/models.py`](https://github.com/yohan-987/cropwise/blob/main/backend/app/models.py) (Platform data store), [`backend/app/services/recommendation_engine.py`](https://github.com/yohan-987/cropwise/blob/main/backend/app/services/recommendation_engine.py) (Sell-hold advisor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Farmer and buyer app"]
  node_webapp["CropWise web app<br/>[App.jsx]"]
  node_api_client["API client<br/>[client.js]"]
  node_auth_ui["Session and roles<br/>[AuthContext.jsx]"]
  node_i18n_ui["Multilingual voice UI<br/>[I18nContext.jsx]"]
  node_farmer_app["Farmer"]
end

subgraph group_decision["Decision support"]
  node_market_intel["Market intelligence<br/>[market.py]"]
  node_market_data["Market data sources"]
  node_net_realization["Net realization"]
  node_advisor["Sell-hold advisor"]
  node_forecast["Price forecast<br/>[price_predictor.py]"]
  node_weather["Weather risk<br/>[weather_service.py]"]
  node_assistant["Multilingual assistant<br/>[assistant.py]"]
  node_quality["Produce quality<br/>[quality_grading.py]"]
end

subgraph group_marketplace["Trading and fulfillment"]
  node_listings["Produce listings<br/>[listings.py]"]
  node_buyer_match["Buyer matching<br/>[buyer_matcher.py]"]
  node_buyer_demand["Buyer demands<br/>[buyer_demands.py]"]
  node_verification["Buyer verification"]
  node_transactions["Transactions and payments<br/>[transactions.py]"]
  node_transport["Transport negotiation"]
  node_group_selling["FarmPool and group selling<br/>[group_selling.py]"]
  node_storage["Storage marketplace<br/>[storage.py]"]
end

subgraph group_platform["Platform services"]
  node_admin["Admin metrics<br/>[admin.py]"]
  node_api["Backend API<br/>[main.py]"]
  node_auth["Authentication<br/>[auth_utils.py]"]
  node_database[("Platform data store<br/>[models.py]")]
end

node_farmer(("Farmer"))
node_buyer(("Buyer"))
node_external_market["Government market data"]
node_external_weather["Open-Meteo"]

node_farmer -->|"uses"| node_webapp
node_buyer -->|"uses"| node_webapp
node_webapp -->|"requests"| node_api_client
node_api_client -->|"calls"| node_api
node_auth_ui -->|"authenticates through"| node_api_client
node_api -->|"routes to"| node_market_intel
node_market_intel -.->|"fetches prices"| node_market_data
node_market_data -.->|"queries"| node_external_market
node_market_intel -->|"ranks net returns"| node_net_realization
node_net_realization -->|"models transport cost"| node_transport
node_api -->|"routes to"| node_advisor
node_advisor -->|"uses market data"| node_market_intel
node_advisor -->|"uses trends"| node_forecast
node_advisor -->|"assesses risk"| node_weather
node_api -->|"routes to"| node_forecast
node_forecast -->|"reads prices"| node_market_intel
node_api -.->|"routes to"| node_weather
node_weather -->|"fetches forecasts"| node_external_weather
node_api -->|"routes to"| node_assistant
node_assistant -->|"answers with market data"| node_market_intel
node_assistant -->|"answers with forecasts"| node_forecast
node_assistant -->|"answers with weather"| node_weather
node_i18n_ui -->|"localizes"| node_webapp
node_api -->|"routes to"| node_listings
node_api -->|"routes to"| node_buyer_match
node_buyer_match -->|"uses market context"| node_market_intel
node_api -->|"routes to"| node_buyer_demand
node_api -->|"routes to"| node_verification
node_api -->|"routes to"| node_transactions
node_api -.->|"routes to"| node_transport
node_api -.->|"routes to"| node_group_selling
node_api -.->|"routes to"| node_storage
node_api -.->|"routes to"| node_quality
node_api -->|"routes to"| node_admin
node_market_intel -.->|"reads and writes"| node_database
node_transactions -.->|"reads and writes"| node_database
node_verification -->|"reads and writes"| node_database
node_storage -->|"books facilities"| node_database
node_auth -->|"resolves identities"| node_database
node_farmer_app -.->|"requests services"| node_api_client

click node_webapp "https://github.com/yohan-987/cropwise/blob/main/frontend/src/App.jsx"
click node_api_client "https://github.com/yohan-987/cropwise/blob/main/frontend/src/api/client.js"
click node_auth_ui "https://github.com/yohan-987/cropwise/blob/main/frontend/src/context/AuthContext.jsx"
click node_i18n_ui "https://github.com/yohan-987/cropwise/blob/main/frontend/src/i18n/I18nContext.jsx"
click node_market_intel "https://github.com/yohan-987/cropwise/blob/main/backend/app/routers/market.py"
click node_market_data "https://github.com/yohan-987/cropwise/blob/main/backend/app/services/agmarknet_service.py"
click node_net_realization "https://github.com/yohan-987/cropwise/blob/main/backend/app/services/transport_optimizer.py"
click node_advisor "https://github.com/yohan-987/cropwise/blob/main/backend/app/services/recommendation_engine.py"
click node_forecast "https://github.com/yohan-987/cropwise/blob/main/backend/app/services/price_predictor.py"
click node_weather "https://github.com/yohan-987/cropwise/blob/main/backend/app/services/weather_service.py"
click node_assistant "https://github.com/yohan-987/cropwise/blob/main/backend/app/routers/assistant.py"
click node_quality "https://github.com/yohan-987/cropwise/blob/main/backend/app/services/quality_grading.py"
click node_listings "https://github.com/yohan-987/cropwise/blob/main/backend/app/routers/listings.py"
click node_buyer_match "https://github.com/yohan-987/cropwise/blob/main/backend/app/services/buyer_matcher.py"
click node_buyer_demand "https://github.com/yohan-987/cropwise/blob/main/backend/app/routers/buyer_demands.py"
click node_verification "https://github.com/yohan-987/cropwise/blob/main/backend/app/routers/buyer_verification.py"
click node_transactions "https://github.com/yohan-987/cropwise/blob/main/backend/app/routers/transactions.py"
click node_transport "https://github.com/yohan-987/cropwise/blob/main/backend/app/routers/transport_negotiation.py"
click node_group_selling "https://github.com/yohan-987/cropwise/blob/main/backend/app/routers/group_selling.py"
click node_storage "https://github.com/yohan-987/cropwise/blob/main/backend/app/routers/storage.py"
click node_admin "https://github.com/yohan-987/cropwise/blob/main/backend/app/routers/admin.py"
click node_api "https://github.com/yohan-987/cropwise/blob/main/backend/app/main.py"
click node_auth "https://github.com/yohan-987/cropwise/blob/main/backend/app/auth_utils.py"
click node_database "https://github.com/yohan-987/cropwise/blob/main/backend/app/models.py"
click node_farmer_app "https://github.com/yohan-987/cropwise/blob/main/frontend/src/pages/FarmerDashboard.jsx"

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,node_auth_ui,node_i18n_ui,node_farmer_app toneBlue
class node_market_intel,node_market_data,node_net_realization,node_advisor,node_forecast,node_weather,node_assistant,node_quality toneAmber
class node_listings,node_buyer_match,node_buyer_demand,node_verification,node_transactions,node_transport,node_group_selling,node_storage toneMint
class node_admin,node_api,node_auth,node_database toneRose
class node_farmer,node_buyer,node_external_market,node_external_weather toneIndigo
```

## Components

### Farmer and buyer app

- [CropWise web app](https://github.com/yohan-987/cropwise/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [API client](https://github.com/yohan-987/cropwise/blob/main/frontend/src/api/client.js): `frontend/src/api/client.js`
- [Session and roles](https://github.com/yohan-987/cropwise/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Multilingual voice UI](https://github.com/yohan-987/cropwise/blob/main/frontend/src/i18n/I18nContext.jsx): `frontend/src/i18n/I18nContext.jsx`
- [Farmer](https://github.com/yohan-987/cropwise/blob/main/frontend/src/pages/FarmerDashboard.jsx): `frontend/src/pages/FarmerDashboard.jsx`

### Decision support

- [Market intelligence](https://github.com/yohan-987/cropwise/blob/main/backend/app/routers/market.py): `backend/app/routers/market.py`
- [Market data sources](https://github.com/yohan-987/cropwise/blob/main/backend/app/services/agmarknet_service.py): `backend/app/services/agmarknet_service.py`
- [Net realization](https://github.com/yohan-987/cropwise/blob/main/backend/app/services/transport_optimizer.py): `backend/app/services/transport_optimizer.py`
- [Sell-hold advisor](https://github.com/yohan-987/cropwise/blob/main/backend/app/services/recommendation_engine.py): `backend/app/services/recommendation_engine.py`
- [Price forecast](https://github.com/yohan-987/cropwise/blob/main/backend/app/services/price_predictor.py): `backend/app/services/price_predictor.py`
- [Weather risk](https://github.com/yohan-987/cropwise/blob/main/backend/app/services/weather_service.py): `backend/app/services/weather_service.py`
- [Multilingual assistant](https://github.com/yohan-987/cropwise/blob/main/backend/app/routers/assistant.py): `backend/app/routers/assistant.py`
- [Produce quality](https://github.com/yohan-987/cropwise/blob/main/backend/app/services/quality_grading.py): `backend/app/services/quality_grading.py`

### Trading and fulfillment

- [Produce listings](https://github.com/yohan-987/cropwise/blob/main/backend/app/routers/listings.py): `backend/app/routers/listings.py`
- [Buyer matching](https://github.com/yohan-987/cropwise/blob/main/backend/app/services/buyer_matcher.py): `backend/app/services/buyer_matcher.py`
- [Buyer demands](https://github.com/yohan-987/cropwise/blob/main/backend/app/routers/buyer_demands.py): `backend/app/routers/buyer_demands.py`
- [Buyer verification](https://github.com/yohan-987/cropwise/blob/main/backend/app/routers/buyer_verification.py): `backend/app/routers/buyer_verification.py`
- [Transactions and payments](https://github.com/yohan-987/cropwise/blob/main/backend/app/routers/transactions.py): `backend/app/routers/transactions.py`
- [Transport negotiation](https://github.com/yohan-987/cropwise/blob/main/backend/app/routers/transport_negotiation.py): `backend/app/routers/transport_negotiation.py`
- [FarmPool and group selling](https://github.com/yohan-987/cropwise/blob/main/backend/app/routers/group_selling.py): `backend/app/routers/group_selling.py`
- [Storage marketplace](https://github.com/yohan-987/cropwise/blob/main/backend/app/routers/storage.py): `backend/app/routers/storage.py`

### Platform services

- [Admin metrics](https://github.com/yohan-987/cropwise/blob/main/backend/app/routers/admin.py): `backend/app/routers/admin.py`
- [Backend API](https://github.com/yohan-987/cropwise/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication](https://github.com/yohan-987/cropwise/blob/main/backend/app/auth_utils.py): `backend/app/auth_utils.py`
- [Platform data store](https://github.com/yohan-987/cropwise/blob/main/backend/app/models.py): `backend/app/models.py`

### Other components

- **Farmer**
- **Buyer**
- **Government market data**
- **Open-Meteo**

## Connections

- Farmer → CropWise web app: uses (evidence: `README.md`)
- Buyer → CropWise web app: uses (evidence: `README.md`)
- CropWise web app → API client: requests (evidence: `frontend/src/App.jsx`)
- API client → Backend API: calls (evidence: `frontend/src/api/client.js`)
- Session and roles → API client: authenticates through (evidence: `frontend/src/context/AuthContext.jsx`)
- Backend API → Market intelligence: routes to (evidence: `backend/app/main.py`)
- Market intelligence → Market data sources: fetches prices
- Market data sources → Government market data: queries
- Market intelligence → Net realization: ranks net returns (evidence: `README.md`)
- Net realization → Transport negotiation: models transport cost (evidence: `README.md`)
- Backend API → Sell-hold advisor: routes to (evidence: `backend/app/main.py`)
- Sell-hold advisor → Market intelligence: uses market data (evidence: `backend/app/routers/advisor.py`)
- Sell-hold advisor → Price forecast: uses trends (evidence: `backend/app/routers/advisor.py`)
- Sell-hold advisor → Weather risk: assesses risk (evidence: `backend/app/services/recommendation_engine.py`)
- Backend API → Price forecast: routes to (evidence: `backend/app/main.py`)
- Price forecast → Market intelligence: reads prices (evidence: `backend/app/routers/forecast.py`)
- Backend API → Weather risk: routes to
- Weather risk → Open-Meteo: fetches forecasts (evidence: `backend/app/services/weather_service.py`)
- Backend API → Multilingual assistant: routes to (evidence: `backend/app/main.py`)
- Multilingual assistant → Market intelligence: answers with market data (evidence: `backend/app/routers/assistant.py`)
- Multilingual assistant → Price forecast: answers with forecasts (evidence: `backend/app/routers/assistant.py`)
- Multilingual assistant → Weather risk: answers with weather (evidence: `backend/app/routers/assistant.py`)
- Multilingual voice UI → CropWise web app: localizes (evidence: `frontend/src/main.jsx`)
- Backend API → Produce listings: routes to (evidence: `backend/app/main.py`)
- Backend API → Buyer matching: routes to (evidence: `backend/app/main.py`)
- Buyer matching → Market intelligence: uses market context (evidence: `backend/app/routers/matching.py`)
- Backend API → Buyer demands: routes to (evidence: `backend/app/main.py`)
- Backend API → Buyer verification: routes to (evidence: `backend/app/main.py`)
- Backend API → Transactions and payments: routes to (evidence: `backend/app/main.py`)
- Backend API → Transport negotiation: routes to (evidence: `backend/app/main.py`)
- Backend API → FarmPool and group selling: routes to (evidence: `backend/app/main.py`)
- Backend API → Storage marketplace: routes to (evidence: `backend/app/main.py`)
- Backend API → Produce quality: routes to
- Backend API → Admin metrics: routes to (evidence: `backend/app/main.py`)
- Market intelligence → Platform data store: reads and writes
- Transactions and payments → Platform data store: reads and writes
- Buyer verification → Platform data store: reads and writes (evidence: `backend/app/routers/buyer_verification.py`)
- Storage marketplace → Platform data store: books facilities (evidence: `backend/app/routers/storage.py`)
- Authentication → Platform data store: resolves identities (evidence: `backend/app/auth_utils.py`)
- Farmer → API client: requests services
