# kmbandillo/farm-to-table architecture

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

- Interactive diagram: https://gitdiagram.com/kmbandillo/farm-to-table
- Repository: https://github.com/kmbandillo/farm-to-table

## Overview

AgriLink is a farm-products storefront with customer and administrator experiences. Customers sign in, browse products, build a cart, check out, and manage orders and profiles; administrators manage the catalog and accounts, process orders, and review sales. The graph preserves these distinct workflows and the backend’s authentication, catalog, user, transaction, and persistence layers. Frontend-to-API calls are not shown in the sampled excerpts, so those links are omitted; UI composition and backend routing are supported by the source index and excerpts.

Main entry points: [`frontend/src/main.jsx`](https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/main.jsx) (Role-based routes), [`backend/router.js`](https://github.com/kmbandillo/farm-to-table/blob/main/backend/router.js) (API routes), [`backend/controllers/transactionController.js`](https://github.com/kmbandillo/farm-to-table/blob/main/backend/controllers/transactionController.js) (Transaction handlers), [`frontend/src/components/Customer/StorePage.jsx`](https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Customer/StorePage.jsx) (Product storefront)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_customer["Customer storefront"]
  node_customer_home["Customer home<br/>[CustomerHome.jsx]"]
  node_store["Product storefront<br/>[StorePage.jsx]"]
  node_product_card["Product card<br/>[ProductCard.jsx]"]
  node_cart["Shopping cart<br/>[ShoppingCart.jsx]"]
  node_checkout["Checkout<br/>[CheckoutPage.jsx]"]
  node_customer_orders["Customer orders<br/>[CustomerOrders.jsx]"]
  node_profile["Customer profile<br/>[ProfilePage.jsx]"]
end

subgraph group_admin["Admin console"]
  node_admin_home["Admin dashboard<br/>[AdminHome.jsx]"]
  node_catalog["Catalog management<br/>[AdminCatalog.jsx]"]
  node_product_form["Product form<br/>[ProductForm.jsx]"]
  node_products_page["Product listings<br/>[ProductsPage.jsx]"]
  node_accounts["Account management<br/>[AdminAccounts.jsx]"]
  node_admin_orders["Order processing<br/>[AdminOrders.jsx]"]
  node_sales["Sales reporting<br/>[AdminSales.jsx]"]
end

subgraph group_identity["Identity and access"]
  node_signin["Sign in<br/>[SignIn.jsx]"]
  node_signup["Sign up<br/>[SignUp.jsx]"]
  node_routes["Role-based routes<br/>[main.jsx]"]
end

subgraph group_backend["Backend API"]
  node_server["HTTP server<br/>[server.js]"]
  node_router["API routes<br/>[router.js]"]
  node_auth_controller["Authentication handlers<br/>[authController.js]"]
  node_product_controller["Product handlers"]
  node_user_controller["User handlers<br/>[userController.js]"]
  node_transaction_controller["Transaction handlers"]
end

subgraph group_data["Domain data"]
  node_user_model[("User records<br/>[User.js]")]
  node_product_model[("Product records<br/>[Product.js]")]
  node_transaction_model[("Transaction records<br/>[Transaction.js]")]
end

node_visitor(("Shopper or admin"))
node_mongodb[("MongoDB")]

node_visitor -->|"opens"| node_signin
node_visitor -->|"opens"| node_signup
node_signin -.->|"authenticates via"| node_routes
node_signup -.->|"registers via"| node_routes
node_routes -->|"routes to"| node_customer_home
node_routes -->|"routes to"| node_store
node_routes -->|"routes to"| node_checkout
node_routes -->|"routes to"| node_customer_orders
node_routes -->|"routes to"| node_profile
node_routes -->|"routes to"| node_admin_home
node_routes -->|"routes to"| node_catalog
node_routes -->|"routes to"| node_accounts
node_routes -->|"routes to"| node_admin_orders
node_routes -->|"routes to"| node_sales
node_store -->|"renders"| node_product_card
node_store -->|"renders"| node_cart
node_cart -.->|"proceeds to"| node_checkout
node_catalog -->|"renders"| node_product_form
node_catalog -->|"renders"| node_products_page
node_server -->|"mounts"| node_router
node_router -->|"routes auth to"| node_auth_controller
node_router -->|"routes products to"| node_product_controller
node_router -->|"routes users to"| node_user_controller
node_router -->|"routes transactions to"| node_transaction_controller
node_auth_controller -->|"reads and writes"| node_user_model
node_product_controller -->|"reads and writes"| node_product_model
node_user_controller -->|"reads and writes"| node_user_model
node_transaction_controller -->|"reads and writes"| node_transaction_model
node_transaction_controller -->|"updates"| node_user_model
node_transaction_controller -->|"updates"| node_product_model
node_server -->|"connects to"| node_mongodb

click node_signin "https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/SignIn.jsx"
click node_signup "https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/SignUp.jsx"
click node_routes "https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/main.jsx"
click node_customer_home "https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Customer/CustomerHome.jsx"
click node_store "https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Customer/StorePage.jsx"
click node_product_card "https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Customer/ProductCard.jsx"
click node_cart "https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Customer/ShoppingCart.jsx"
click node_checkout "https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Customer/CheckoutPage.jsx"
click node_customer_orders "https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Customer/CustomerOrders.jsx"
click node_profile "https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Customer/ProfilePage.jsx"
click node_admin_home "https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Admin/AdminHome.jsx"
click node_catalog "https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Admin/AdminCatalog.jsx"
click node_product_form "https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Admin/ProductForm.jsx"
click node_products_page "https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Admin/ProductsPage.jsx"
click node_accounts "https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Admin/AdminAccounts.jsx"
click node_admin_orders "https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Admin/AdminOrders.jsx"
click node_sales "https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Admin/AdminSales.jsx"
click node_server "https://github.com/kmbandillo/farm-to-table/blob/main/backend/server.js"
click node_router "https://github.com/kmbandillo/farm-to-table/blob/main/backend/router.js"
click node_auth_controller "https://github.com/kmbandillo/farm-to-table/blob/main/backend/controllers/authController.js"
click node_product_controller "https://github.com/kmbandillo/farm-to-table/blob/main/backend/controllers/productController.js"
click node_user_controller "https://github.com/kmbandillo/farm-to-table/blob/main/backend/controllers/userController.js"
click node_transaction_controller "https://github.com/kmbandillo/farm-to-table/blob/main/backend/controllers/transactionController.js"
click node_user_model "https://github.com/kmbandillo/farm-to-table/blob/main/backend/models/User.js"
click node_product_model "https://github.com/kmbandillo/farm-to-table/blob/main/backend/models/Product.js"
click node_transaction_model "https://github.com/kmbandillo/farm-to-table/blob/main/backend/models/Transaction.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_customer_home,node_store,node_product_card,node_cart,node_checkout,node_customer_orders,node_profile toneBlue
class node_admin_home,node_catalog,node_product_form,node_products_page,node_accounts,node_admin_orders,node_sales,node_mongodb toneAmber
class node_signin,node_signup,node_routes toneMint
class node_server,node_router,node_auth_controller,node_product_controller,node_user_controller,node_transaction_controller toneRose
class node_user_model,node_product_model,node_transaction_model,node_visitor toneIndigo
```

## Components

### Customer storefront

- [Customer home](https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Customer/CustomerHome.jsx): `frontend/src/components/Customer/CustomerHome.jsx`
- [Product storefront](https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Customer/StorePage.jsx): `frontend/src/components/Customer/StorePage.jsx`
- [Product card](https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Customer/ProductCard.jsx): `frontend/src/components/Customer/ProductCard.jsx`
- [Shopping cart](https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Customer/ShoppingCart.jsx): `frontend/src/components/Customer/ShoppingCart.jsx`
- [Checkout](https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Customer/CheckoutPage.jsx): `frontend/src/components/Customer/CheckoutPage.jsx`
- [Customer orders](https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Customer/CustomerOrders.jsx): `frontend/src/components/Customer/CustomerOrders.jsx`
- [Customer profile](https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Customer/ProfilePage.jsx): `frontend/src/components/Customer/ProfilePage.jsx`

### Admin console

- [Admin dashboard](https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Admin/AdminHome.jsx): `frontend/src/components/Admin/AdminHome.jsx`
- [Catalog management](https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Admin/AdminCatalog.jsx): `frontend/src/components/Admin/AdminCatalog.jsx`
- [Product form](https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Admin/ProductForm.jsx): `frontend/src/components/Admin/ProductForm.jsx`
- [Product listings](https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Admin/ProductsPage.jsx): `frontend/src/components/Admin/ProductsPage.jsx`
- [Account management](https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Admin/AdminAccounts.jsx): `frontend/src/components/Admin/AdminAccounts.jsx`
- [Order processing](https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Admin/AdminOrders.jsx): `frontend/src/components/Admin/AdminOrders.jsx`
- [Sales reporting](https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/Admin/AdminSales.jsx): `frontend/src/components/Admin/AdminSales.jsx`

### Identity and access

- [Sign in](https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/SignIn.jsx): `frontend/src/components/SignIn.jsx`
- [Sign up](https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/components/SignUp.jsx): `frontend/src/components/SignUp.jsx`
- [Role-based routes](https://github.com/kmbandillo/farm-to-table/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`

### Backend API

- [HTTP server](https://github.com/kmbandillo/farm-to-table/blob/main/backend/server.js): `backend/server.js`
- [API routes](https://github.com/kmbandillo/farm-to-table/blob/main/backend/router.js): `backend/router.js`
- [Authentication handlers](https://github.com/kmbandillo/farm-to-table/blob/main/backend/controllers/authController.js): `backend/controllers/authController.js`
- [Product handlers](https://github.com/kmbandillo/farm-to-table/blob/main/backend/controllers/productController.js): `backend/controllers/productController.js`
- [User handlers](https://github.com/kmbandillo/farm-to-table/blob/main/backend/controllers/userController.js): `backend/controllers/userController.js`
- [Transaction handlers](https://github.com/kmbandillo/farm-to-table/blob/main/backend/controllers/transactionController.js): `backend/controllers/transactionController.js`

### Domain data

- [User records](https://github.com/kmbandillo/farm-to-table/blob/main/backend/models/User.js): `backend/models/User.js`
- [Product records](https://github.com/kmbandillo/farm-to-table/blob/main/backend/models/Product.js): `backend/models/Product.js`
- [Transaction records](https://github.com/kmbandillo/farm-to-table/blob/main/backend/models/Transaction.js): `backend/models/Transaction.js`

### Other components

- **Shopper or admin**
- **MongoDB**

## Connections

- Shopper or admin → Sign in: opens
- Shopper or admin → Sign up: opens
- Sign in → Role-based routes: authenticates via (evidence: `frontend/src/main.jsx`)
- Sign up → Role-based routes: registers via (evidence: `frontend/src/main.jsx`)
- Role-based routes → Customer home: routes to (evidence: `frontend/src/main.jsx`)
- Role-based routes → Product storefront: routes to (evidence: `frontend/src/main.jsx`)
- Role-based routes → Checkout: routes to (evidence: `frontend/src/main.jsx`)
- Role-based routes → Customer orders: routes to (evidence: `frontend/src/main.jsx`)
- Role-based routes → Customer profile: routes to (evidence: `frontend/src/main.jsx`)
- Role-based routes → Admin dashboard: routes to (evidence: `frontend/src/main.jsx`)
- Role-based routes → Catalog management: routes to (evidence: `frontend/src/main.jsx`)
- Role-based routes → Account management: routes to (evidence: `frontend/src/main.jsx`)
- Role-based routes → Order processing: routes to (evidence: `frontend/src/main.jsx`)
- Role-based routes → Sales reporting: routes to (evidence: `frontend/src/main.jsx`)
- Product storefront → Product card: renders (evidence: `frontend/src/components/Customer/StorePage.jsx`)
- Product storefront → Shopping cart: renders (evidence: `frontend/src/components/Customer/StorePage.jsx`)
- Shopping cart → Checkout: proceeds to
- Catalog management → Product form: renders (evidence: `frontend/src/components/Admin/AdminCatalog.jsx`)
- Catalog management → Product listings: renders (evidence: `frontend/src/components/Admin/AdminCatalog.jsx`)
- HTTP server → API routes: mounts (evidence: `backend/server.js`)
- API routes → Authentication handlers: routes auth to (evidence: `backend/router.js`)
- API routes → Product handlers: routes products to (evidence: `backend/router.js`)
- API routes → User handlers: routes users to (evidence: `backend/router.js`)
- API routes → Transaction handlers: routes transactions to (evidence: `backend/router.js`)
- Authentication handlers → User records: reads and writes (evidence: `backend/controllers/authController.js`)
- Product handlers → Product records: reads and writes (evidence: `backend/controllers/productController.js`)
- User handlers → User records: reads and writes (evidence: `backend/controllers/userController.js`)
- Transaction handlers → Transaction records: reads and writes (evidence: `backend/controllers/transactionController.js`)
- Transaction handlers → User records: updates (evidence: `backend/controllers/transactionController.js`)
- Transaction handlers → Product records: updates (evidence: `backend/controllers/transactionController.js`)
- HTTP server → MongoDB: connects to (evidence: `backend/server.js`)
