# jeevansrinivasan/uzhavar-market architecture

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

- Interactive diagram: https://gitdiagram.com/jeevansrinivasan/uzhavar-market
- Repository: https://github.com/jeevansrinivasan/uzhavar-market

## Overview

Uzhavar Market is a farmer-to-customer marketplace with customer shopping and ordering, farmer product and order management, and admin oversight. The visible shopping flow runs from browsing the storefront to product details and cart preparation, then checkout and payment/order handling, with customer order history afterward. Separate branches cover account access, farmer operations, admin notifications, and push alerts. Evidence is limited to the supplied excerpts and SOURCE INDEX references; unsampled route behavior and some service wiring are not asserted.

Main entry points: [`app/checkout/page.js`](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/checkout/page.js) (Checkout), [`app/products/[id]/ProductDetailsClient.js`](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/products/%5Bid%5D/ProductDetailsClient.js) (Product details), [`app/admin/page.js`](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/admin/page.js) (Admin console), [`lib/supabase.js`](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/lib/supabase.js) (Supabase)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shopping["Marketplace shopping"]
  node_storefront["Browse storefront<br/>[page.js]"]
  node_product["Product details"]
  node_product_view["Product presentation<br/>[ProductView.js]"]
  node_cart["Cart<br/>[page.js]"]
  node_checkout["Checkout<br/>[page.js]"]
  node_create_payment["Create payment<br/>[route.js]"]
  node_verify_payment["Verify payment<br/>[route.js]"]
  node_stock_control["Stock adjustment<br/>[route.js]"]
  node_stock_restore["Restore stock<br/>[route.js]"]
  node_customer_orders["Customer orders<br/>[page.js]"]
end

subgraph group_operations["Farmer operations"]
  node_farmer_products["Product management<br/>[page.js]"]
  node_farmer_add["Add product<br/>[page.js]"]
  node_farmer_orders["Farmer orders<br/>[page.js]"]
  node_farmer_earnings["Farmer earnings<br/>[page.js]"]
  node_farmer_profile["Farmer profile<br/>[page.js]"]
end

subgraph group_admin["Admin oversight"]
  node_admin["Admin console<br/>[page.js]"]
  node_admin_products["Product administration<br/>[page.js]"]
  node_admin_categories["Category administration<br/>[page.js]"]
  node_admin_notifications["Admin notifications"]
end

subgraph group_platform["Shared platform services"]
  node_pricing["Pricing and delivery<br/>[pricing.js]"]
  node_login["Sign in and register<br/>[page.js]"]
  node_farmer_auth["Role and profile sync<br/>[farmerAuth.js]"]
  node_notifications["Farmer notifications<br/>[notifications.js]"]
  node_push_client["Browser push client<br/>[pushClient.js]"]
  node_push_manager["Notification manager"]
  node_push_send["Push delivery endpoint<br/>[route.js]"]
  node_push_subscribe["Push subscription endpoint<br/>[route.js]"]
  node_database[("Supabase<br/>[supabase.js]")]
  node_language["Language context<br/>[LanguageContext.js]"]
end

node_customer(("Customer"))
node_farmer(("Farmer"))

node_customer -->|"browses"| node_storefront
node_storefront -->|"opens product"| node_product
node_product -->|"reads product data"| node_database
node_product -->|"gets delivery price"| node_pricing
node_product -->|"renders"| node_product_view
node_product -->|"stores cart item"| node_cart
node_storefront -->|"calculates display prices"| node_pricing
node_customer -.->|"reviews cart"| node_cart
node_cart -.->|"proceeds to checkout"| node_checkout
node_checkout -->|"reads marketplace data"| node_database
node_checkout -->|"uses pricing"| node_pricing
node_checkout -.->|"requests payment"| node_create_payment
node_create_payment -->|"calculates order price"| node_pricing
node_customer -.->|"confirms payment"| node_verify_payment
node_checkout -.->|"updates stock"| node_stock_control
node_checkout -.->|"restores stock"| node_stock_restore
node_customer -.->|"views orders"| node_customer_orders
node_farmer -.->|"manages products"| node_farmer_products
node_farmer -.->|"creates listing"| node_farmer_add
node_farmer -.->|"handles orders"| node_farmer_orders
node_farmer -.->|"views earnings"| node_farmer_earnings
node_farmer -.->|"manages profile"| node_farmer_profile
node_login -->|"resolves role"| node_farmer_auth
node_farmer_auth -->|"syncs profile"| node_database
node_farmer_profile -->|"checks access"| node_farmer_auth
node_admin -->|"reads marketplace data"| node_database
node_admin -->|"records admin alerts"| node_admin_notifications
node_admin -->|"uses pricing"| node_pricing
node_admin -.->|"manages products"| node_admin_products
node_admin -.->|"manages categories"| node_admin_categories
node_push_manager -->|"checks role"| node_farmer_auth
node_push_manager -->|"fetches alerts"| node_notifications
node_notifications -->|"reads notifications"| node_database
node_push_manager -->|"subscribes and displays"| node_push_client
node_push_client -->|"saves subscription"| node_database
node_push_client -->|"requests delivery"| node_push_send
node_push_client -.->|"registers subscription"| node_push_subscribe
node_push_manager -.->|"may trigger alert"| node_push_send
node_language -.->|"provides translations"| node_storefront
node_language -->|"provides translations"| node_product
node_language -->|"provides translations"| node_checkout

click node_storefront "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/page.js"
click node_product "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/products/%5Bid%5D/ProductDetailsClient.js"
click node_product_view "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/components/ProductView.js"
click node_pricing "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/lib/pricing.js"
click node_cart "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/cart/page.js"
click node_checkout "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/checkout/page.js"
click node_create_payment "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/api/razorpay/create-order/route.js"
click node_verify_payment "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/api/razorpay/verify-payment/route.js"
click node_stock_control "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/api/orders/deduct-stock/route.js"
click node_stock_restore "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/api/orders/restore-stock/route.js"
click node_customer_orders "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/customer/orders/page.js"
click node_farmer_products "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/farmer/products/page.js"
click node_farmer_add "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/farmer/add-product/page.js"
click node_farmer_orders "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/farmer/orders/page.js"
click node_farmer_earnings "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/farmer/earnings/page.js"
click node_farmer_profile "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/farmer/profile/page.js"
click node_login "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/login/page.js"
click node_farmer_auth "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/lib/farmerAuth.js"
click node_admin "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/admin/page.js"
click node_admin_products "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/admin/products/page.js"
click node_admin_categories "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/admin/categories/page.js"
click node_admin_notifications "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/lib/adminNotifications.js"
click node_notifications "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/lib/notifications.js"
click node_push_client "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/lib/pushClient.js"
click node_push_manager "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/components/MobileNotificationManager.js"
click node_push_send "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/api/push/send/route.js"
click node_push_subscribe "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/api/push/subscribe/route.js"
click node_database "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/lib/supabase.js"
click node_language "https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/context/LanguageContext.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_storefront,node_product,node_product_view,node_cart,node_checkout,node_create_payment,node_verify_payment,node_stock_control,node_stock_restore,node_customer_orders toneBlue
class node_farmer_products,node_farmer_add,node_farmer_orders,node_farmer_earnings,node_farmer_profile toneAmber
class node_admin,node_admin_products,node_admin_categories,node_admin_notifications toneMint
class node_pricing,node_login,node_farmer_auth,node_notifications,node_push_client,node_push_manager,node_push_send,node_push_subscribe,node_database,node_language toneRose
class node_customer,node_farmer toneIndigo
```

## Components

### Marketplace shopping

- [Browse storefront](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/page.js): `app/page.js`
- [Product details](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/products/%5Bid%5D/ProductDetailsClient.js): `app/products/[id]/ProductDetailsClient.js`
- [Product presentation](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/components/ProductView.js): `app/components/ProductView.js`
- [Cart](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/cart/page.js): `app/cart/page.js`
- [Checkout](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/checkout/page.js): `app/checkout/page.js`
- [Create payment](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/api/razorpay/create-order/route.js): `app/api/razorpay/create-order/route.js`
- [Verify payment](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/api/razorpay/verify-payment/route.js): `app/api/razorpay/verify-payment/route.js`
- [Stock adjustment](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/api/orders/deduct-stock/route.js): `app/api/orders/deduct-stock/route.js`
- [Restore stock](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/api/orders/restore-stock/route.js): `app/api/orders/restore-stock/route.js`
- [Customer orders](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/customer/orders/page.js): `app/customer/orders/page.js`

### Farmer operations

- [Product management](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/farmer/products/page.js): `app/farmer/products/page.js`
- [Add product](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/farmer/add-product/page.js): `app/farmer/add-product/page.js`
- [Farmer orders](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/farmer/orders/page.js): `app/farmer/orders/page.js`
- [Farmer earnings](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/farmer/earnings/page.js): `app/farmer/earnings/page.js`
- [Farmer profile](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/farmer/profile/page.js): `app/farmer/profile/page.js`

### Admin oversight

- [Admin console](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/admin/page.js): `app/admin/page.js`
- [Product administration](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/admin/products/page.js): `app/admin/products/page.js`
- [Category administration](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/admin/categories/page.js): `app/admin/categories/page.js`
- [Admin notifications](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/lib/adminNotifications.js): `lib/adminNotifications.js`

### Shared platform services

- [Pricing and delivery](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/lib/pricing.js): `lib/pricing.js`
- [Sign in and register](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/login/page.js): `app/login/page.js`
- [Role and profile sync](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/lib/farmerAuth.js): `lib/farmerAuth.js`
- [Farmer notifications](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/lib/notifications.js): `lib/notifications.js`
- [Browser push client](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/lib/pushClient.js): `lib/pushClient.js`
- [Notification manager](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/components/MobileNotificationManager.js): `app/components/MobileNotificationManager.js`
- [Push delivery endpoint](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/api/push/send/route.js): `app/api/push/send/route.js`
- [Push subscription endpoint](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/api/push/subscribe/route.js): `app/api/push/subscribe/route.js`
- [Supabase](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/lib/supabase.js): `lib/supabase.js`
- [Language context](https://github.com/jeevansrinivasan/uzhavar-market/blob/main/app/context/LanguageContext.js): `app/context/LanguageContext.js`

### Other components

- **Customer**
- **Farmer**

## Connections

- Customer → Browse storefront: browses (evidence: `app/page.js`)
- Browse storefront → Product details: opens product (evidence: `app/page.js`)
- Product details → Supabase: reads product data (evidence: `app/products/[id]/ProductDetailsClient.js`)
- Product details → Pricing and delivery: gets delivery price (evidence: `app/products/[id]/ProductDetailsClient.js`)
- Product details → Product presentation: renders (evidence: `app/products/[id]/ProductDetailsClient.js`)
- Product details → Cart: stores cart item (evidence: `app/products/[id]/ProductDetailsClient.js`)
- Browse storefront → Pricing and delivery: calculates display prices (evidence: `app/page.js`)
- Customer → Cart: reviews cart
- Cart → Checkout: proceeds to checkout
- Checkout → Supabase: reads marketplace data (evidence: `app/checkout/page.js`)
- Checkout → Pricing and delivery: uses pricing (evidence: `app/checkout/page.js`)
- Checkout → Create payment: requests payment
- Create payment → Pricing and delivery: calculates order price (evidence: `app/api/razorpay/create-order/route.js`)
- Customer → Verify payment: confirms payment
- Checkout → Stock adjustment: updates stock
- Checkout → Restore stock: restores stock
- Customer → Customer orders: views orders
- Farmer → Product management: manages products
- Farmer → Add product: creates listing
- Farmer → Farmer orders: handles orders
- Farmer → Farmer earnings: views earnings
- Farmer → Farmer profile: manages profile
- Sign in and register → Role and profile sync: resolves role (evidence: `app/login/page.js`)
- Role and profile sync → Supabase: syncs profile (evidence: `lib/farmerAuth.js`)
- Farmer profile → Role and profile sync: checks access (evidence: `app/farmer/profile/page.js`)
- Admin console → Supabase: reads marketplace data (evidence: `app/admin/page.js`)
- Admin console → Admin notifications: records admin alerts (evidence: `app/admin/page.js`)
- Admin console → Pricing and delivery: uses pricing (evidence: `app/admin/page.js`)
- Admin console → Product administration: manages products
- Admin console → Category administration: manages categories
- Notification manager → Role and profile sync: checks role (evidence: `app/components/MobileNotificationManager.js`)
- Notification manager → Farmer notifications: fetches alerts (evidence: `app/components/MobileNotificationManager.js`)
- Farmer notifications → Supabase: reads notifications (evidence: `lib/notifications.js`)
- Notification manager → Browser push client: subscribes and displays (evidence: `app/components/MobileNotificationManager.js`)
- Browser push client → Supabase: saves subscription (evidence: `lib/pushClient.js`)
- Browser push client → Push delivery endpoint: requests delivery (evidence: `lib/pushClient.js`)
- Browser push client → Push subscription endpoint: registers subscription
- Notification manager → Push delivery endpoint: may trigger alert
- Language context → Browse storefront: provides translations (evidence: `app/page.js`)
- Language context → Product details: provides translations (evidence: `app/products/[id]/ProductDetailsClient.js`)
- Language context → Checkout: provides translations (evidence: `app/checkout/page.js`)
