# rakshitkashyap1/farmer-marketplace architecture

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

- Interactive diagram: https://gitdiagram.com/rakshitkashyap1/farmer-marketplace
- Repository: https://github.com/rakshitkashyap1/farmer-marketplace

## Overview

HERM Agro is a frontend-only farmer marketplace prototype. Buyers browse and filter produce, add items to a persistent cart, and place mock orders; farmers manage produce and fulfil orders, while buyers and farmers also use role-specific dashboards. A separate expert directory supports consultation requests, and a keyword-based AI widget is a mock assistant. README documents a service layer over in-memory mock data; source excerpts confirm some service and persistence details, but do not establish every dashboard interaction.

Main entry points: [`src/services/productService.ts`](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/services/productService.ts) (Product service), [`src/services/expertService.ts`](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/services/expertService.ts) (Expert service), [`src/app/dashboard/farmer/page.tsx`](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/dashboard/farmer/page.tsx) (Farmer dashboard), [`src/app/marketplace/page.tsx`](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/marketplace/page.tsx) (Browse produce)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_market["Marketplace"]
  node_market_routes["Browse produce<br/>[page.tsx]"]
  node_product_detail["Product details<br/>[page.tsx]"]
  node_farmer_store["Farmer storefront<br/>[page.tsx]"]
  node_product_card["Product cards<br/>[ProductCard.tsx]"]
  node_search["Search bar<br/>[SearchBar.tsx]"]
  node_product_service["Product service<br/>[productService.ts]"]
  node_product_data["Product seeds<br/>[products.ts]"]
end

subgraph group_commerce["Commerce"]
  node_cart["Cart state<br/>[CartContext.tsx]"]
  node_cart_page["Cart<br/>[page.tsx]"]
  node_checkout["Checkout<br/>[page.tsx]"]
  node_order_service["Order service<br/>[orderService.ts]"]
end

subgraph group_dashboards["Role dashboards"]
  node_buyer_dashboard["Buyer dashboard<br/>[page.tsx]"]
  node_buyer_orders["Buyer orders<br/>[page.tsx]"]
  node_farmer_dashboard["Farmer dashboard<br/>[page.tsx]"]
  node_produce_form["Produce editor<br/>[ProduceForm.tsx]"]
  node_farmer_orders["Order fulfilment<br/>[page.tsx]"]
  node_farmer_earnings["Earnings<br/>[page.tsx]"]
end

subgraph group_experts["Expert consultations"]
  node_expert_directory["Expert directory<br/>[page.tsx]"]
  node_expert_profile["Expert profile<br/>[page.tsx]"]
  node_consultation["Booking modal"]
  node_expert_service["Expert service<br/>[expertService.ts]"]
  node_expert_data["Expert seeds<br/>[experts.ts]"]
end

subgraph group_platform["Shared platform"]
  node_ai_widget["HERM AI widget<br/>[HERMChat.tsx]"]
  node_auth_pages["Login and register<br/>[page.tsx]"]
  node_auth_context["Session state<br/>[AuthContext.tsx]"]
  node_auth_service["Auth service<br/>[authService.ts]"]
  node_mock_db[("In-memory database<br/>[db.ts]")]
  node_toast["Notifications<br/>[ToastContext.tsx]"]
end

node_buyer(("Buyer"))
node_farmer(("Farmer"))

node_buyer -->|"browses"| node_market_routes
node_search -->|"navigates to"| node_market_routes
node_market_routes -->|"queries listings"| node_product_service
node_market_routes -->|"renders"| node_product_card
node_product_detail -->|"loads product"| node_product_service
node_farmer_store -.->|"loads farmer data"| node_product_service
node_product_service -->|"seeds listings"| node_product_data
node_product_service -->|"reads and mutates"| node_mock_db
node_product_detail -.->|"adds items"| node_cart
node_cart -->|"supplies items"| node_cart_page
node_cart -->|"supplies items"| node_checkout
node_checkout -->|"places order"| node_order_service
node_order_service -->|"reads and writes"| node_mock_db
node_buyer -->|"submits purchase"| node_checkout
node_buyer -->|"manages account"| node_buyer_dashboard
node_buyer_dashboard -->|"tracks orders"| node_buyer_orders
node_farmer -->|"manages sales"| node_farmer_dashboard
node_farmer_dashboard -->|"edits produce"| node_produce_form
node_produce_form -->|"saves produce"| node_product_service
node_farmer_dashboard -->|"fulfils orders"| node_farmer_orders
node_farmer_dashboard -->|"reviews payouts"| node_farmer_earnings
node_buyer -->|"finds experts"| node_expert_directory
node_expert_directory -->|"searches experts"| node_expert_service
node_expert_profile -->|"loads profile"| node_expert_service
node_expert_profile -->|"opens booking"| node_consultation
node_consultation -->|"requests consultation"| node_expert_service
node_expert_service -->|"seeds directory"| node_expert_data
node_expert_service -->|"reads and writes"| node_mock_db
node_buyer -.->|"asks questions"| node_ai_widget
node_auth_pages -.->|"submits credentials"| node_auth_context
node_auth_context -->|"authenticates"| node_auth_service
node_auth_service -->|"uses delay helper"| node_mock_db
node_checkout -->|"shows feedback"| node_toast

click node_market_routes "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/marketplace/page.tsx"
click node_product_detail "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/marketplace/%5Bid%5D/page.tsx"
click node_farmer_store "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/farmers/%5Bid%5D/page.tsx"
click node_product_card "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/components/marketplace/ProductCard.tsx"
click node_search "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/components/marketplace/SearchBar.tsx"
click node_product_service "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/services/productService.ts"
click node_product_data "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/data/products.ts"
click node_cart "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/context/CartContext.tsx"
click node_cart_page "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/cart/page.tsx"
click node_checkout "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/checkout/page.tsx"
click node_order_service "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/services/orderService.ts"
click node_buyer_dashboard "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/dashboard/buyer/page.tsx"
click node_buyer_orders "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/dashboard/buyer/orders/page.tsx"
click node_farmer_dashboard "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/dashboard/farmer/page.tsx"
click node_produce_form "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/components/dashboard/ProduceForm.tsx"
click node_farmer_orders "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/dashboard/farmer/orders/page.tsx"
click node_farmer_earnings "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/dashboard/farmer/earnings/page.tsx"
click node_expert_directory "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/experts/page.tsx"
click node_expert_profile "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/experts/%5Bid%5D/page.tsx"
click node_consultation "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/components/experts/ConsultationModal.tsx"
click node_expert_service "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/services/expertService.ts"
click node_expert_data "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/data/experts.ts"
click node_ai_widget "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/components/ai/HERMChat.tsx"
click node_auth_pages "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/login/page.tsx"
click node_auth_context "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/context/AuthContext.tsx"
click node_auth_service "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/services/authService.ts"
click node_mock_db "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/services/db.ts"
click node_toast "https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/context/ToastContext.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_market_routes,node_product_detail,node_farmer_store,node_product_card,node_search,node_product_service,node_product_data toneBlue
class node_cart,node_cart_page,node_checkout,node_order_service toneAmber
class node_buyer_dashboard,node_buyer_orders,node_farmer_dashboard,node_produce_form,node_farmer_orders,node_farmer_earnings toneMint
class node_expert_directory,node_expert_profile,node_consultation,node_expert_service,node_expert_data toneRose
class node_ai_widget,node_auth_pages,node_auth_context,node_auth_service,node_mock_db,node_toast,node_buyer,node_farmer toneIndigo
```

## Components

### Marketplace

- [Browse produce](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/marketplace/page.tsx): `src/app/marketplace/page.tsx`
- [Product details](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/marketplace/%5Bid%5D/page.tsx): `src/app/marketplace/[id]/page.tsx`
- [Farmer storefront](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/farmers/%5Bid%5D/page.tsx): `src/app/farmers/[id]/page.tsx`
- [Product cards](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/components/marketplace/ProductCard.tsx): `src/components/marketplace/ProductCard.tsx`
- [Search bar](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/components/marketplace/SearchBar.tsx): `src/components/marketplace/SearchBar.tsx`
- [Product service](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/services/productService.ts): `src/services/productService.ts`
- [Product seeds](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/data/products.ts): `src/data/products.ts`

### Commerce

- [Cart state](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/context/CartContext.tsx): `src/context/CartContext.tsx`
- [Cart](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/cart/page.tsx): `src/app/cart/page.tsx`
- [Checkout](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/checkout/page.tsx): `src/app/checkout/page.tsx`
- [Order service](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/services/orderService.ts): `src/services/orderService.ts`

### Role dashboards

- [Buyer dashboard](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/dashboard/buyer/page.tsx): `src/app/dashboard/buyer/page.tsx`
- [Buyer orders](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/dashboard/buyer/orders/page.tsx): `src/app/dashboard/buyer/orders/page.tsx`
- [Farmer dashboard](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/dashboard/farmer/page.tsx): `src/app/dashboard/farmer/page.tsx`
- [Produce editor](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/components/dashboard/ProduceForm.tsx): `src/components/dashboard/ProduceForm.tsx`
- [Order fulfilment](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/dashboard/farmer/orders/page.tsx): `src/app/dashboard/farmer/orders/page.tsx`
- [Earnings](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/dashboard/farmer/earnings/page.tsx): `src/app/dashboard/farmer/earnings/page.tsx`

### Expert consultations

- [Expert directory](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/experts/page.tsx): `src/app/experts/page.tsx`
- [Expert profile](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/experts/%5Bid%5D/page.tsx): `src/app/experts/[id]/page.tsx`
- [Booking modal](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/components/experts/ConsultationModal.tsx): `src/components/experts/ConsultationModal.tsx`
- [Expert service](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/services/expertService.ts): `src/services/expertService.ts`
- [Expert seeds](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/data/experts.ts): `src/data/experts.ts`

### Shared platform

- [HERM AI widget](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/components/ai/HERMChat.tsx): `src/components/ai/HERMChat.tsx`
- [Login and register](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/app/login/page.tsx): `src/app/login/page.tsx`
- [Session state](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/context/AuthContext.tsx): `src/context/AuthContext.tsx`
- [Auth service](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/services/authService.ts): `src/services/authService.ts`
- [In-memory database](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/services/db.ts): `src/services/db.ts`
- [Notifications](https://github.com/rakshitkashyap1/farmer-marketplace/blob/main/src/context/ToastContext.tsx): `src/context/ToastContext.tsx`

### Other components

- **Buyer**
- **Farmer**

## Connections

- Buyer → Browse produce: browses (evidence: `README.md`)
- Search bar → Browse produce: navigates to (evidence: `src/components/marketplace/SearchBar.tsx`)
- Browse produce → Product service: queries listings (evidence: `README.md`)
- Browse produce → Product cards: renders (evidence: `src/app/marketplace/page.tsx`)
- Product details → Product service: loads product (evidence: `src/app/marketplace/[id]/page.tsx`)
- Farmer storefront → Product service: loads farmer data
- Product service → Product seeds: seeds listings (evidence: `src/services/productService.ts`)
- Product service → In-memory database: reads and mutates (evidence: `src/services/productService.ts`)
- Product details → Cart state: adds items (evidence: `src/app/marketplace/[id]/page.tsx`)
- Cart state → Cart: supplies items (evidence: `src/app/cart/page.tsx`)
- Cart state → Checkout: supplies items (evidence: `src/app/checkout/page.tsx`)
- Checkout → Order service: places order (evidence: `README.md`)
- Order service → In-memory database: reads and writes (evidence: `src/services/orderService.ts`)
- Buyer → Checkout: submits purchase (evidence: `README.md`)
- Buyer → Buyer dashboard: manages account (evidence: `README.md`)
- Buyer dashboard → Buyer orders: tracks orders (evidence: `README.md`)
- Farmer → Farmer dashboard: manages sales (evidence: `README.md`)
- Farmer dashboard → Produce editor: edits produce (evidence: `README.md`)
- Produce editor → Product service: saves produce (evidence: `src/components/dashboard/ProduceForm.tsx`)
- Farmer dashboard → Order fulfilment: fulfils orders (evidence: `README.md`)
- Farmer dashboard → Earnings: reviews payouts (evidence: `README.md`)
- Buyer → Expert directory: finds experts (evidence: `README.md`)
- Expert directory → Expert service: searches experts (evidence: `src/app/experts/page.tsx`)
- Expert profile → Expert service: loads profile (evidence: `src/app/experts/[id]/page.tsx`)
- Expert profile → Booking modal: opens booking (evidence: `src/app/experts/[id]/page.tsx`)
- Booking modal → Expert service: requests consultation (evidence: `src/components/experts/ConsultationModal.tsx`)
- Expert service → Expert seeds: seeds directory (evidence: `src/services/expertService.ts`)
- Expert service → In-memory database: reads and writes (evidence: `src/services/expertService.ts`)
- Buyer → HERM AI widget: asks questions
- Login and register → Session state: submits credentials
- Session state → Auth service: authenticates (evidence: `src/context/AuthContext.tsx`)
- Auth service → In-memory database: uses delay helper (evidence: `src/services/authService.ts`)
- Checkout → Notifications: shows feedback (evidence: `src/app/checkout/page.tsx`)
