# ahadalireach/kisanbazar architecture

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

- Interactive diagram: https://gitdiagram.com/ahadalireach/kisanbazar
- Repository: https://github.com/ahadalireach/kisanbazar

## Overview

KisanBazar is a farmer–consumer marketplace. Consumers browse farmer profiles and produce, communicate with farmers, then place and track order requests; farmers maintain profiles and listings and handle orders/messages, while administrators manage marketplace records. The React client routes role-specific pages through Redux state to the Express API, whose controllers enforce business operations over MongoDB models. Messaging, categories, administration, and account management are retained as distinct capability branches. Some client slices and backend subsystems were not excerpted, so their internal links are omitted where the supplied evidence does not establish them.

Main entry points: [`client/src/App.jsx`](https://github.com/ahadalireach/kisanbazar/blob/master/client/src/App.jsx) (Role-based pages), [`api/index.js`](https://github.com/ahadalireach/kisanbazar/blob/master/api/index.js) (API server), [`api/utils/authMiddleware.js`](https://github.com/ahadalireach/kisanbazar/blob/master/api/utils/authMiddleware.js) (JWT role checks), [`api/controllers/orderController.js`](https://github.com/ahadalireach/kisanbazar/blob/master/api/controllers/orderController.js) (Order requests)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Marketplace client"]
  node_app["Role-based pages<br/>[App.jsx]"]
  node_authstate["Account state<br/>[authSlice.js]"]
  node_checkout["Checkout<br/>[CheckoutPage.jsx]"]
  node_orderdetail["Order detail"]
  node_profile["Profile management<br/>[ProfilePage.jsx]"]
  node_farmerpages["Farmer workspace"]
  node_adminpages["Admin workspace"]
  node_catalogpages["Catalog and farmers"]
  node_messagingpages["Messaging pages"]
end

subgraph group_api["API and access"]
  node_server["API server<br/>[index.js]"]
  node_authroutes["Authentication routes<br/>[authRoutes.js]"]
  node_useroutes["User routes<br/>[userRoutes.js]"]
  node_productroutes["Product routes<br/>[productRoutes.js]"]
  node_orderroutes["Order routes<br/>[orderRoutes.js]"]
  node_messageroutes["Message routes<br/>[messageRoutes.js]"]
  node_categoryroutes["Category routes<br/>[categoryRoutes.js]"]
  node_access["JWT role checks<br/>[authMiddleware.js]"]
end

subgraph group_domain["Marketplace operations"]
  node_accounts["Accounts and profiles<br/>[userController.js]"]
  node_catalog["Product listings"]
  node_orders["Order requests<br/>[orderController.js]"]
  node_messages["Conversations"]
  node_categories["Categories"]
end

subgraph group_storage["Persistent data"]
  node_usersdb[("User records<br/>[UserModel.js]")]
  node_farmerdb[("Farmer profiles")]
  node_productsdb[("Product records<br/>[ProductModel.js]")]
  node_ordersdb[("Order records<br/>[OrderModel.js]")]
  node_messagesdb[("Message records<br/>[MessageModel.js]")]
  node_categoriesdb[("Category records<br/>[CategoryModel.js]")]
end

node_consumer(("Consumer"))
node_farmer(("Farmer"))
node_admin(("Administrator"))
node_mongo[("MongoDB")]

node_consumer -->|"uses"| node_app
node_farmer -->|"uses"| node_app
node_admin -->|"uses"| node_app
node_app -->|"loads account"| node_authstate
node_app -->|"routes to"| node_checkout
node_app -->|"routes to"| node_orderdetail
node_app -->|"routes to"| node_profile
node_app -->|"routes to"| node_farmerpages
node_app -->|"routes to"| node_adminpages
node_app -->|"routes to"| node_catalogpages
node_app -->|"routes to"| node_messagingpages
node_checkout -->|"requests orders"| node_orders
node_orderdetail -->|"loads order state"| node_orders
node_profile -->|"updates account"| node_authstate
node_server -->|"mounts routes"| node_authroutes
node_server -->|"mounts routes"| node_useroutes
node_server -->|"mounts routes"| node_productroutes
node_server -->|"mounts routes"| node_orderroutes
node_server -->|"mounts routes"| node_messageroutes
node_server -->|"mounts routes"| node_categoryroutes
node_orderroutes -->|"dispatches"| node_orders
node_orderroutes -->|"checks access"| node_access
node_productroutes -->|"dispatches"| node_catalog
node_productroutes -->|"checks access"| node_access
node_useroutes -->|"dispatches"| node_accounts
node_useroutes -->|"checks access"| node_access
node_authroutes -->|"checks access"| node_access
node_messageroutes -->|"dispatches"| node_messages
node_messageroutes -->|"checks access"| node_access
node_categoryroutes -->|"dispatches"| node_categories
node_categoryroutes -->|"checks access"| node_access
node_orders -->|"reads prices"| node_productsdb
node_orders -->|"creates and updates"| node_ordersdb
node_catalog -->|"reads and writes"| node_productsdb
node_accounts -->|"reads and writes"| node_usersdb
node_accounts -->|"reads and writes"| node_farmerdb
node_messages -->|"reads and writes"| node_messagesdb
node_messages -->|"looks up receiver"| node_usersdb
node_access -->|"loads user"| node_usersdb
node_server -->|"connects"| node_mongo

click node_app "https://github.com/ahadalireach/kisanbazar/blob/master/client/src/App.jsx"
click node_authstate "https://github.com/ahadalireach/kisanbazar/blob/master/client/src/redux/slices/authSlice.js"
click node_checkout "https://github.com/ahadalireach/kisanbazar/blob/master/client/src/pages/CheckoutPage.jsx"
click node_orderdetail "https://github.com/ahadalireach/kisanbazar/blob/master/client/src/pages/OrderDetailPage.jsx"
click node_profile "https://github.com/ahadalireach/kisanbazar/blob/master/client/src/pages/ProfilePage.jsx"
click node_farmerpages "https://github.com/ahadalireach/kisanbazar/tree/master/client/src/pages/farmer"
click node_adminpages "https://github.com/ahadalireach/kisanbazar/tree/master/client/src/pages/admin"
click node_catalogpages "https://github.com/ahadalireach/kisanbazar/tree/master/client/src/pages"
click node_messagingpages "https://github.com/ahadalireach/kisanbazar/blob/master/client/src/pages/ConversationPage.jsx"
click node_server "https://github.com/ahadalireach/kisanbazar/blob/master/api/index.js"
click node_authroutes "https://github.com/ahadalireach/kisanbazar/blob/master/api/routes/authRoutes.js"
click node_useroutes "https://github.com/ahadalireach/kisanbazar/blob/master/api/routes/userRoutes.js"
click node_productroutes "https://github.com/ahadalireach/kisanbazar/blob/master/api/routes/productRoutes.js"
click node_orderroutes "https://github.com/ahadalireach/kisanbazar/blob/master/api/routes/orderRoutes.js"
click node_messageroutes "https://github.com/ahadalireach/kisanbazar/blob/master/api/routes/messageRoutes.js"
click node_categoryroutes "https://github.com/ahadalireach/kisanbazar/blob/master/api/routes/categoryRoutes.js"
click node_access "https://github.com/ahadalireach/kisanbazar/blob/master/api/utils/authMiddleware.js"
click node_accounts "https://github.com/ahadalireach/kisanbazar/blob/master/api/controllers/userController.js"
click node_catalog "https://github.com/ahadalireach/kisanbazar/blob/master/api/controllers/productController.js"
click node_orders "https://github.com/ahadalireach/kisanbazar/blob/master/api/controllers/orderController.js"
click node_messages "https://github.com/ahadalireach/kisanbazar/blob/master/api/controllers/messageController.js"
click node_categories "https://github.com/ahadalireach/kisanbazar/blob/master/api/controllers/categoryController.js"
click node_usersdb "https://github.com/ahadalireach/kisanbazar/blob/master/api/models/UserModel.js"
click node_farmerdb "https://github.com/ahadalireach/kisanbazar/blob/master/api/models/FarmerProfileModel.js"
click node_productsdb "https://github.com/ahadalireach/kisanbazar/blob/master/api/models/ProductModel.js"
click node_ordersdb "https://github.com/ahadalireach/kisanbazar/blob/master/api/models/OrderModel.js"
click node_messagesdb "https://github.com/ahadalireach/kisanbazar/blob/master/api/models/MessageModel.js"
click node_categoriesdb "https://github.com/ahadalireach/kisanbazar/blob/master/api/models/CategoryModel.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_authstate,node_checkout,node_orderdetail,node_profile,node_farmerpages,node_adminpages,node_catalogpages,node_messagingpages toneBlue
class node_server,node_authroutes,node_useroutes,node_productroutes,node_orderroutes,node_messageroutes,node_categoryroutes,node_access,node_mongo toneAmber
class node_accounts,node_catalog,node_orders,node_messages,node_categories toneMint
class node_usersdb,node_farmerdb,node_productsdb,node_ordersdb,node_messagesdb,node_categoriesdb toneRose
class node_consumer,node_farmer,node_admin toneIndigo
```

## Components

### Marketplace client

- [Role-based pages](https://github.com/ahadalireach/kisanbazar/blob/master/client/src/App.jsx): `client/src/App.jsx`
- [Account state](https://github.com/ahadalireach/kisanbazar/blob/master/client/src/redux/slices/authSlice.js): `client/src/redux/slices/authSlice.js`
- [Checkout](https://github.com/ahadalireach/kisanbazar/blob/master/client/src/pages/CheckoutPage.jsx): `client/src/pages/CheckoutPage.jsx`
- [Order detail](https://github.com/ahadalireach/kisanbazar/blob/master/client/src/pages/OrderDetailPage.jsx): `client/src/pages/OrderDetailPage.jsx`
- [Profile management](https://github.com/ahadalireach/kisanbazar/blob/master/client/src/pages/ProfilePage.jsx): `client/src/pages/ProfilePage.jsx`
- [Farmer workspace](https://github.com/ahadalireach/kisanbazar/tree/master/client/src/pages/farmer): `client/src/pages/farmer`
- [Admin workspace](https://github.com/ahadalireach/kisanbazar/tree/master/client/src/pages/admin): `client/src/pages/admin`
- [Catalog and farmers](https://github.com/ahadalireach/kisanbazar/tree/master/client/src/pages): `client/src/pages`
- [Messaging pages](https://github.com/ahadalireach/kisanbazar/blob/master/client/src/pages/ConversationPage.jsx): `client/src/pages/ConversationPage.jsx`

### API and access

- [API server](https://github.com/ahadalireach/kisanbazar/blob/master/api/index.js): `api/index.js`
- [Authentication routes](https://github.com/ahadalireach/kisanbazar/blob/master/api/routes/authRoutes.js): `api/routes/authRoutes.js`
- [User routes](https://github.com/ahadalireach/kisanbazar/blob/master/api/routes/userRoutes.js): `api/routes/userRoutes.js`
- [Product routes](https://github.com/ahadalireach/kisanbazar/blob/master/api/routes/productRoutes.js): `api/routes/productRoutes.js`
- [Order routes](https://github.com/ahadalireach/kisanbazar/blob/master/api/routes/orderRoutes.js): `api/routes/orderRoutes.js`
- [Message routes](https://github.com/ahadalireach/kisanbazar/blob/master/api/routes/messageRoutes.js): `api/routes/messageRoutes.js`
- [Category routes](https://github.com/ahadalireach/kisanbazar/blob/master/api/routes/categoryRoutes.js): `api/routes/categoryRoutes.js`
- [JWT role checks](https://github.com/ahadalireach/kisanbazar/blob/master/api/utils/authMiddleware.js): `api/utils/authMiddleware.js`

### Marketplace operations

- [Accounts and profiles](https://github.com/ahadalireach/kisanbazar/blob/master/api/controllers/userController.js): `api/controllers/userController.js`
- [Product listings](https://github.com/ahadalireach/kisanbazar/blob/master/api/controllers/productController.js): `api/controllers/productController.js`
- [Order requests](https://github.com/ahadalireach/kisanbazar/blob/master/api/controllers/orderController.js): `api/controllers/orderController.js`
- [Conversations](https://github.com/ahadalireach/kisanbazar/blob/master/api/controllers/messageController.js): `api/controllers/messageController.js`
- [Categories](https://github.com/ahadalireach/kisanbazar/blob/master/api/controllers/categoryController.js): `api/controllers/categoryController.js`

### Persistent data

- [User records](https://github.com/ahadalireach/kisanbazar/blob/master/api/models/UserModel.js): `api/models/UserModel.js`
- [Farmer profiles](https://github.com/ahadalireach/kisanbazar/blob/master/api/models/FarmerProfileModel.js): `api/models/FarmerProfileModel.js`
- [Product records](https://github.com/ahadalireach/kisanbazar/blob/master/api/models/ProductModel.js): `api/models/ProductModel.js`
- [Order records](https://github.com/ahadalireach/kisanbazar/blob/master/api/models/OrderModel.js): `api/models/OrderModel.js`
- [Message records](https://github.com/ahadalireach/kisanbazar/blob/master/api/models/MessageModel.js): `api/models/MessageModel.js`
- [Category records](https://github.com/ahadalireach/kisanbazar/blob/master/api/models/CategoryModel.js): `api/models/CategoryModel.js`

### Other components

- **Consumer**
- **Farmer**
- **Administrator**
- **MongoDB**

## Connections

- Consumer → Role-based pages: uses
- Farmer → Role-based pages: uses
- Administrator → Role-based pages: uses
- Role-based pages → Account state: loads account (evidence: `client/src/App.jsx`)
- Role-based pages → Checkout: routes to (evidence: `client/src/App.jsx`)
- Role-based pages → Order detail: routes to (evidence: `client/src/App.jsx`)
- Role-based pages → Profile management: routes to (evidence: `client/src/App.jsx`)
- Role-based pages → Farmer workspace: routes to (evidence: `client/src/App.jsx`)
- Role-based pages → Admin workspace: routes to (evidence: `client/src/App.jsx`)
- Role-based pages → Catalog and farmers: routes to (evidence: `client/src/App.jsx`)
- Role-based pages → Messaging pages: routes to (evidence: `client/src/App.jsx`)
- Checkout → Order requests: requests orders (evidence: `client/src/pages/CheckoutPage.jsx`)
- Order detail → Order requests: loads order state (evidence: `client/src/pages/OrderDetailPage.jsx`)
- Profile management → Account state: updates account (evidence: `client/src/pages/ProfilePage.jsx`)
- API server → Authentication routes: mounts routes (evidence: `api/index.js`)
- API server → User routes: mounts routes (evidence: `api/index.js`)
- API server → Product routes: mounts routes (evidence: `api/index.js`)
- API server → Order routes: mounts routes (evidence: `api/index.js`)
- API server → Message routes: mounts routes (evidence: `api/index.js`)
- API server → Category routes: mounts routes (evidence: `api/index.js`)
- Order routes → Order requests: dispatches (evidence: `api/routes/orderRoutes.js`)
- Order routes → JWT role checks: checks access (evidence: `api/routes/orderRoutes.js`)
- Product routes → Product listings: dispatches (evidence: `api/routes/productRoutes.js`)
- Product routes → JWT role checks: checks access (evidence: `api/routes/productRoutes.js`)
- User routes → Accounts and profiles: dispatches (evidence: `api/routes/userRoutes.js`)
- User routes → JWT role checks: checks access (evidence: `api/routes/userRoutes.js`)
- Authentication routes → JWT role checks: checks access (evidence: `api/routes/authRoutes.js`)
- Message routes → Conversations: dispatches (evidence: `api/routes/messageRoutes.js`)
- Message routes → JWT role checks: checks access (evidence: `api/routes/messageRoutes.js`)
- Category routes → Categories: dispatches (evidence: `api/routes/categoryRoutes.js`)
- Category routes → JWT role checks: checks access (evidence: `api/routes/categoryRoutes.js`)
- Order requests → Product records: reads prices (evidence: `api/controllers/orderController.js`)
- Order requests → Order records: creates and updates (evidence: `api/controllers/orderController.js`)
- Product listings → Product records: reads and writes (evidence: `api/controllers/productController.js`)
- Accounts and profiles → User records: reads and writes (evidence: `api/controllers/userController.js`)
- Accounts and profiles → Farmer profiles: reads and writes (evidence: `api/controllers/userController.js`)
- Conversations → Message records: reads and writes (evidence: `api/controllers/messageController.js`)
- Conversations → User records: looks up receiver (evidence: `api/controllers/messageController.js`)
- JWT role checks → User records: loads user (evidence: `api/utils/authMiddleware.js`)
- API server → MongoDB: connects (evidence: `api/index.js`)
