# drona0113/agrimart architecture

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

- Interactive diagram: https://gitdiagram.com/drona0113/agrimart
- Repository: https://github.com/drona0113/agrimart

## Overview

AgriMart is a role-based, two-sided agricultural marketplace: farmers and suppliers sell while platform users can also buy. The main journey is browse products, authenticate, complete shipping and payment steps, place an order, then follow its status; sellers manage products and sales, while admins manage platform data and audit activity. A separate knowledge hub supports agricultural posts and comments. The map follows the documented React-to-Express/MongoDB structure and sampled controller ownership; some frontend page-to-API wiring and unsampled route/controller details are not shown.

Main entry points: [`frontend/src/main.jsx`](https://github.com/drona0113/agrimart/blob/main/frontend/src/main.jsx) (React app), [`backend/index.js`](https://github.com/drona0113/agrimart/blob/main/backend/index.js) (API server), [`frontend/src/pages/admin`](https://github.com/drona0113/agrimart/tree/main/frontend/src/pages/admin) (Admin workspace), [`frontend/src/pages`](https://github.com/drona0113/agrimart/tree/main/frontend/src/pages) (Checkout and orders)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Marketplace client"]
  node_app["React app<br/>[main.jsx]"]
  node_marketpages["Browse and cart"]
  node_checkoutpages["Checkout and orders"]
  node_sellerpages["Farmer workspace"]
  node_adminpages["Admin workspace"]
  node_knowledgepages["Knowledge pages"]
  node_userslices["User API state<br/>[usersApiSlice.js]"]
  node_productslices["Product API state"]
  node_orderslices["Order API state<br/>[ordersApiSlice.js]"]
  node_paymentslices["Payment API state"]
  node_knowledgeslices["Knowledge API state"]
end

subgraph group_commerce["Commerce services"]
  node_server["API server<br/>[index.js]"]
  node_productroutes["Product routes<br/>[productRoutes.js]"]
  node_productcontroller["Product management"]
  node_productstore[("Product records<br/>[productModel.js]")]
  node_orderroutes["Order routes<br/>[orderRoutes.js]"]
  node_ordercontroller["Order lifecycle<br/>[orderController.js]"]
  node_orderstore[("Order records<br/>[orderModel.js]")]
  node_paymentroutes["Payment routes<br/>[razorpayRoutes.js]"]
  node_paymentcontroller["Payment verification"]
end

subgraph group_identity["Identity and administration"]
  node_useroutes["User routes<br/>[userRoutes.js]"]
  node_usercontroller["Accounts and audit<br/>[userController.js]"]
  node_usermodel[("User records<br/>[userModel.js]")]
  node_auditmodel[("Audit records<br/>[auditLogModel.js]")]
  node_authmiddleware["Access control<br/>[authMiddleware.js]"]
end

subgraph group_knowledge["Knowledge hub"]
  node_knowledgeroutes["Knowledge routes<br/>[knowledgeRoutes.js]"]
  node_knowledgecontroller["Knowledge content"]
  node_knowledgemodel[("Knowledge records<br/>[knowledgeModel.js]")]
end

node_visitor(("Marketplace user"))
node_razorpay["Razorpay"]
node_mongodb[("MongoDB")]

node_visitor -->|"uses"| node_app
node_app -->|"routes to"| node_marketpages
node_app -->|"routes to"| node_checkoutpages
node_app -->|"routes to"| node_sellerpages
node_app -->|"routes to"| node_adminpages
node_app -->|"routes to"| node_knowledgepages
node_marketpages -->|"requests products"| node_productslices
node_checkoutpages -->|"requests orders"| node_orderslices
node_checkoutpages -->|"requests payment"| node_paymentslices
node_sellerpages -->|"manages products"| node_productslices
node_sellerpages -->|"requests sales"| node_orderslices
node_adminpages -->|"manages users"| node_userslices
node_adminpages -->|"manages products"| node_productslices
node_adminpages -->|"manages orders"| node_orderslices
node_knowledgepages -->|"requests content"| node_knowledgeslices
node_server -->|"mounts"| node_productroutes
node_server -->|"mounts"| node_orderroutes
node_server -->|"mounts"| node_paymentroutes
node_server -->|"mounts"| node_useroutes
node_server -->|"mounts"| node_knowledgeroutes
node_productroutes -->|"dispatches"| node_productcontroller
node_productcontroller -->|"reads and writes"| node_productstore
node_orderroutes -->|"dispatches"| node_ordercontroller
node_ordercontroller -->|"reads and writes"| node_orderstore
node_ordercontroller -->|"checks ownership"| node_productstore
node_paymentroutes -->|"dispatches"| node_paymentcontroller
node_paymentcontroller -.->|"creates payment orders"| node_razorpay
node_paymentcontroller -->|"updates payment"| node_orderstore
node_useroutes -->|"dispatches"| node_usercontroller
node_useroutes -->|"guards routes"| node_authmiddleware
node_usercontroller -->|"reads and writes"| node_usermodel
node_usercontroller -->|"records access"| node_auditmodel
node_knowledgeroutes -->|"dispatches"| node_knowledgecontroller
node_knowledgecontroller -->|"reads and writes"| node_knowledgemodel
node_productstore -->|"persists"| node_mongodb
node_orderstore -->|"persists"| node_mongodb
node_usermodel -->|"persists"| node_mongodb
node_auditmodel -->|"persists"| node_mongodb
node_knowledgemodel -->|"persists"| node_mongodb

click node_app "https://github.com/drona0113/agrimart/blob/main/frontend/src/main.jsx"
click node_marketpages "https://github.com/drona0113/agrimart/tree/main/frontend/src/pages"
click node_checkoutpages "https://github.com/drona0113/agrimart/tree/main/frontend/src/pages"
click node_sellerpages "https://github.com/drona0113/agrimart/tree/main/frontend/src/pages/farmer"
click node_adminpages "https://github.com/drona0113/agrimart/tree/main/frontend/src/pages/admin"
click node_knowledgepages "https://github.com/drona0113/agrimart/tree/main/frontend/src/pages"
click node_userslices "https://github.com/drona0113/agrimart/blob/main/frontend/src/slices/usersApiSlice.js"
click node_productslices "https://github.com/drona0113/agrimart/blob/main/frontend/src/slices/productsApiSlice.js"
click node_orderslices "https://github.com/drona0113/agrimart/blob/main/frontend/src/slices/ordersApiSlice.js"
click node_paymentslices "https://github.com/drona0113/agrimart/blob/main/frontend/src/slices/razorpayApiSlice.js"
click node_knowledgeslices "https://github.com/drona0113/agrimart/blob/main/frontend/src/slices/knowledgeApiSlice.js"
click node_server "https://github.com/drona0113/agrimart/blob/main/backend/index.js"
click node_productroutes "https://github.com/drona0113/agrimart/blob/main/backend/routes/productRoutes.js"
click node_productcontroller "https://github.com/drona0113/agrimart/blob/main/backend/controllers/productController.js"
click node_productstore "https://github.com/drona0113/agrimart/blob/main/backend/models/productModel.js"
click node_orderroutes "https://github.com/drona0113/agrimart/blob/main/backend/routes/orderRoutes.js"
click node_ordercontroller "https://github.com/drona0113/agrimart/blob/main/backend/controllers/orderController.js"
click node_orderstore "https://github.com/drona0113/agrimart/blob/main/backend/models/orderModel.js"
click node_paymentroutes "https://github.com/drona0113/agrimart/blob/main/backend/routes/razorpayRoutes.js"
click node_paymentcontroller "https://github.com/drona0113/agrimart/blob/main/backend/controllers/razorpayController.js"
click node_useroutes "https://github.com/drona0113/agrimart/blob/main/backend/routes/userRoutes.js"
click node_usercontroller "https://github.com/drona0113/agrimart/blob/main/backend/controllers/userController.js"
click node_usermodel "https://github.com/drona0113/agrimart/blob/main/backend/models/userModel.js"
click node_auditmodel "https://github.com/drona0113/agrimart/blob/main/backend/models/auditLogModel.js"
click node_authmiddleware "https://github.com/drona0113/agrimart/blob/main/backend/middleware/authMiddleware.js"
click node_knowledgeroutes "https://github.com/drona0113/agrimart/blob/main/backend/routes/knowledgeRoutes.js"
click node_knowledgecontroller "https://github.com/drona0113/agrimart/blob/main/backend/controllers/knowledgeController.js"
click node_knowledgemodel "https://github.com/drona0113/agrimart/blob/main/backend/models/knowledgeModel.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_marketpages,node_checkoutpages,node_sellerpages,node_adminpages,node_knowledgepages,node_userslices,node_productslices,node_orderslices,node_paymentslices,node_knowledgeslices,node_visitor toneBlue
class node_server,node_productroutes,node_productcontroller,node_productstore,node_orderroutes,node_ordercontroller,node_orderstore,node_paymentroutes,node_paymentcontroller,node_mongodb toneAmber
class node_useroutes,node_usercontroller,node_usermodel,node_auditmodel,node_authmiddleware toneMint
class node_knowledgeroutes,node_knowledgecontroller,node_knowledgemodel toneRose
class node_razorpay toneIndigo
```

## Components

### Marketplace client

- [React app](https://github.com/drona0113/agrimart/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`
- [Browse and cart](https://github.com/drona0113/agrimart/tree/main/frontend/src/pages): `frontend/src/pages`
- [Checkout and orders](https://github.com/drona0113/agrimart/tree/main/frontend/src/pages): `frontend/src/pages`
- [Farmer workspace](https://github.com/drona0113/agrimart/tree/main/frontend/src/pages/farmer): `frontend/src/pages/farmer`
- [Admin workspace](https://github.com/drona0113/agrimart/tree/main/frontend/src/pages/admin): `frontend/src/pages/admin`
- [Knowledge pages](https://github.com/drona0113/agrimart/tree/main/frontend/src/pages): `frontend/src/pages`
- [User API state](https://github.com/drona0113/agrimart/blob/main/frontend/src/slices/usersApiSlice.js): `frontend/src/slices/usersApiSlice.js`
- [Product API state](https://github.com/drona0113/agrimart/blob/main/frontend/src/slices/productsApiSlice.js): `frontend/src/slices/productsApiSlice.js`
- [Order API state](https://github.com/drona0113/agrimart/blob/main/frontend/src/slices/ordersApiSlice.js): `frontend/src/slices/ordersApiSlice.js`
- [Payment API state](https://github.com/drona0113/agrimart/blob/main/frontend/src/slices/razorpayApiSlice.js): `frontend/src/slices/razorpayApiSlice.js`
- [Knowledge API state](https://github.com/drona0113/agrimart/blob/main/frontend/src/slices/knowledgeApiSlice.js): `frontend/src/slices/knowledgeApiSlice.js`

### Commerce services

- [API server](https://github.com/drona0113/agrimart/blob/main/backend/index.js): `backend/index.js`
- [Product routes](https://github.com/drona0113/agrimart/blob/main/backend/routes/productRoutes.js): `backend/routes/productRoutes.js`
- [Product management](https://github.com/drona0113/agrimart/blob/main/backend/controllers/productController.js): `backend/controllers/productController.js`
- [Product records](https://github.com/drona0113/agrimart/blob/main/backend/models/productModel.js): `backend/models/productModel.js`
- [Order routes](https://github.com/drona0113/agrimart/blob/main/backend/routes/orderRoutes.js): `backend/routes/orderRoutes.js`
- [Order lifecycle](https://github.com/drona0113/agrimart/blob/main/backend/controllers/orderController.js): `backend/controllers/orderController.js`
- [Order records](https://github.com/drona0113/agrimart/blob/main/backend/models/orderModel.js): `backend/models/orderModel.js`
- [Payment routes](https://github.com/drona0113/agrimart/blob/main/backend/routes/razorpayRoutes.js): `backend/routes/razorpayRoutes.js`
- [Payment verification](https://github.com/drona0113/agrimart/blob/main/backend/controllers/razorpayController.js): `backend/controllers/razorpayController.js`

### Identity and administration

- [User routes](https://github.com/drona0113/agrimart/blob/main/backend/routes/userRoutes.js): `backend/routes/userRoutes.js`
- [Accounts and audit](https://github.com/drona0113/agrimart/blob/main/backend/controllers/userController.js): `backend/controllers/userController.js`
- [User records](https://github.com/drona0113/agrimart/blob/main/backend/models/userModel.js): `backend/models/userModel.js`
- [Audit records](https://github.com/drona0113/agrimart/blob/main/backend/models/auditLogModel.js): `backend/models/auditLogModel.js`
- [Access control](https://github.com/drona0113/agrimart/blob/main/backend/middleware/authMiddleware.js): `backend/middleware/authMiddleware.js`

### Knowledge hub

- [Knowledge routes](https://github.com/drona0113/agrimart/blob/main/backend/routes/knowledgeRoutes.js): `backend/routes/knowledgeRoutes.js`
- [Knowledge content](https://github.com/drona0113/agrimart/blob/main/backend/controllers/knowledgeController.js): `backend/controllers/knowledgeController.js`
- [Knowledge records](https://github.com/drona0113/agrimart/blob/main/backend/models/knowledgeModel.js): `backend/models/knowledgeModel.js`

### Other components

- **Marketplace user**
- **Razorpay**
- **MongoDB**

## Connections

- Marketplace user → React app: uses
- React app → Browse and cart: routes to
- React app → Checkout and orders: routes to
- React app → Farmer workspace: routes to
- React app → Admin workspace: routes to
- React app → Knowledge pages: routes to
- Browse and cart → Product API state: requests products
- Checkout and orders → Order API state: requests orders
- Checkout and orders → Payment API state: requests payment
- Farmer workspace → Product API state: manages products
- Farmer workspace → Order API state: requests sales
- Admin workspace → User API state: manages users
- Admin workspace → Product API state: manages products
- Admin workspace → Order API state: manages orders
- Knowledge pages → Knowledge API state: requests content
- API server → Product routes: mounts
- API server → Order routes: mounts
- API server → Payment routes: mounts
- API server → User routes: mounts
- API server → Knowledge routes: mounts
- Product routes → Product management: dispatches
- Product management → Product records: reads and writes
- Order routes → Order lifecycle: dispatches
- Order lifecycle → Order records: reads and writes
- Order lifecycle → Product records: checks ownership
- Payment routes → Payment verification: dispatches
- Payment verification → Razorpay: creates payment orders
- Payment verification → Order records: updates payment
- User routes → Accounts and audit: dispatches
- User routes → Access control: guards routes
- Accounts and audit → User records: reads and writes
- Accounts and audit → Audit records: records access
- Knowledge routes → Knowledge content: dispatches
- Knowledge content → Knowledge records: reads and writes
- Product records → MongoDB: persists
- Order records → MongoDB: persists
- User records → MongoDB: persists
- Audit records → MongoDB: persists
- Knowledge records → MongoDB: persists
