# programing360/fresh-root architecture

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

- Interactive diagram: https://gitdiagram.com/programing360/fresh-root
- Repository: https://github.com/programing360/fresh-root

## Overview

Fresh Root is an organic-food e-commerce application. Shoppers browse and filter products, inspect product details, and use the shopping and order flows; authenticated users can manage products through a dashboard. The map includes the documented search, inventory, and product-card capabilities, plus the homepage content subsystem. Some backend behavior is described only in the README, and several routes and helpers were not sampled, so those connections are omitted or marked unverified rather than inferred.

Main entry points: [`src/lib/api/products.ts`](https://github.com/programing360/fresh-root/blob/main/src/lib/api/products.ts) (Product API), [`src/lib/core/server.ts`](https://github.com/programing360/fresh-root/blob/main/src/lib/core/server.ts) (Server Requests), [`src/lib/auth-client.ts`](https://github.com/programing360/fresh-root/blob/main/src/lib/auth-client.ts) (Auth Client), [`src/app/(public)/page.tsx`](https://github.com/programing360/fresh-root/blob/main/src/app/(public)/page.tsx) (Home Page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_home["Home Page<br/>[page.tsx]"]
  node_home_sections["Home Sections"]
  node_site_nav["Site Navigation<br/>[Navbar.tsx]"]
end

subgraph group_shopping["Product Shopping"]
  node_shop["Product Search<br/>[shop.tsx]"]
  node_product_card["Product Cards<br/>[ProductCard.tsx]"]
  node_product_page["Product Detail Route<br/>[page.tsx]"]
  node_product_details["Product Details<br/>[ProductDetails.tsx]"]
  node_product_api["Product API<br/>[products.ts]"]
  node_cart_api["Cart API<br/>[cart.ts]"]
  node_orders["Orders Page<br/>[page.tsx]"]
  node_product_type["Product Model<br/>[product.ts]"]
end

subgraph group_identity["Identity &amp; Access"]
  node_login["Login Page<br/>[Login.tsx]"]
  node_register["Registration Page<br/>[Register.tsx]"]
  node_auth_client["Auth Client<br/>[auth-client.ts]"]
  node_session_client["Client Session<br/>[session-client.ts]"]
  node_auth_route["Auth Route<br/>[route.ts]"]
  node_auth_service["Auth Service<br/>[auth.ts]"]
  node_auth_store[("MongoDB Auth Store")]
  node_server_helpers["Server Requests<br/>[server.ts]"]
  node_server_session["Server Session<br/>[session.ts]"]
end

subgraph group_operations["Catalog Operations"]
  node_dashboard["Dashboard Home<br/>[page.tsx]"]
  node_dashboard_home["Dashboard Overview"]
  node_add_product["Add Product Form<br/>[page.tsx]"]
  node_product_action["Product Add Action<br/>[product-add.ts]"]
  node_item_management["Item Management"]
end

node_shopper(("Shopper"))
node_backend{{"Commerce Backend"}}

node_shopper -->|"browses"| node_home
node_home -->|"renders"| node_home_sections
node_home -->|"loads products"| node_product_api
node_shopper -.->|"searches catalog"| node_shop
node_shop -->|"queries products"| node_product_api
node_shop -->|"renders items"| node_product_card
node_product_card -->|"opens preview"| node_product_page
node_product_page -->|"renders details"| node_product_details
node_product_page -->|"loads product"| node_product_api
node_product_api -->|"requests catalog data"| node_backend
node_product_api -->|"uses protected requests"| node_server_helpers
node_product_api -->|"types product data"| node_product_type
node_shopper -.->|"views orders"| node_orders
node_product_card -.->|"cart actions"| node_cart_api
node_shopper -->|"signs in"| node_login
node_shopper -.->|"registers"| node_register
node_login -.->|"authenticates"| node_auth_client
node_register -.->|"creates account"| node_auth_client
node_site_nav -->|"uses auth"| node_auth_client
node_site_nav -->|"reads session"| node_session_client
node_session_client -->|"reads session"| node_auth_client
node_auth_route -->|"dispatches requests"| node_auth_service
node_auth_service -->|"persists auth data"| node_auth_store
node_shopper -.->|"manages catalog"| node_dashboard
node_dashboard -->|"renders overview"| node_dashboard_home
node_dashboard -->|"loads products"| node_product_api
node_add_product -->|"submits product"| node_product_action
node_product_action -->|"posts product"| node_server_helpers
node_item_management -->|"updates catalog"| node_product_api
node_server_helpers -->|"gets user token"| node_server_session
node_server_helpers -->|"sends requests"| node_backend
node_server_session -->|"reads auth session"| node_auth_service

click node_home "https://github.com/programing360/fresh-root/blob/main/src/app/(public)/page.tsx"
click node_home_sections "https://github.com/programing360/fresh-root/tree/main/src/components/sections"
click node_site_nav "https://github.com/programing360/fresh-root/blob/main/src/components/Global/Navbar.tsx"
click node_shop "https://github.com/programing360/fresh-root/blob/main/src/app/(public)/shop/shop.tsx"
click node_product_card "https://github.com/programing360/fresh-root/blob/main/src/components/ProductCard.tsx"
click node_product_page "https://github.com/programing360/fresh-root/blob/main/src/app/(public)/shop/%5Bid%5D/page.tsx"
click node_product_details "https://github.com/programing360/fresh-root/blob/main/src/app/(public)/shop/%5Bid%5D/ProductDetails.tsx"
click node_product_api "https://github.com/programing360/fresh-root/blob/main/src/lib/api/products.ts"
click node_cart_api "https://github.com/programing360/fresh-root/blob/main/src/lib/api/cart.ts"
click node_orders "https://github.com/programing360/fresh-root/blob/main/src/app/(public)/orders/page.tsx"
click node_login "https://github.com/programing360/fresh-root/blob/main/src/app/auth/login/Login.tsx"
click node_register "https://github.com/programing360/fresh-root/blob/main/src/app/auth/register/Register.tsx"
click node_auth_client "https://github.com/programing360/fresh-root/blob/main/src/lib/auth-client.ts"
click node_session_client "https://github.com/programing360/fresh-root/blob/main/src/lib/core/session-client.ts"
click node_auth_route "https://github.com/programing360/fresh-root/blob/main/src/app/api/auth/%5B...all%5D/route.ts"
click node_auth_service "https://github.com/programing360/fresh-root/blob/main/src/lib/auth.ts"
click node_dashboard "https://github.com/programing360/fresh-root/blob/main/src/app/(userDashboard)/dashboard/page.tsx"
click node_dashboard_home "https://github.com/programing360/fresh-root/blob/main/src/components/dashboard/UserDashboardHome.tsx"
click node_add_product "https://github.com/programing360/fresh-root/blob/main/src/app/(userDashboard)/dashboard/item/add/page.tsx"
click node_product_action "https://github.com/programing360/fresh-root/blob/main/src/lib/action/product-add.ts"
click node_item_management "https://github.com/programing360/fresh-root/blob/main/src/components/dashboard/ItemManagementTable.tsx"
click node_product_type "https://github.com/programing360/fresh-root/blob/main/src/types/product.ts"
click node_server_helpers "https://github.com/programing360/fresh-root/blob/main/src/lib/core/server.ts"
click node_server_session "https://github.com/programing360/fresh-root/blob/main/src/lib/core/session.ts"

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_home,node_home_sections,node_site_nav toneBlue
class node_shop,node_product_card,node_product_page,node_product_details,node_product_api,node_cart_api,node_orders,node_product_type toneAmber
class node_login,node_register,node_auth_client,node_session_client,node_auth_route,node_auth_service,node_auth_store,node_server_helpers,node_server_session toneMint
class node_dashboard,node_dashboard_home,node_add_product,node_product_action,node_item_management toneRose
class node_shopper,node_backend toneIndigo
```

## Components

### Storefront

- [Home Page](https://github.com/programing360/fresh-root/blob/main/src/app/(public)/page.tsx): `src/app/(public)/page.tsx`
- [Home Sections](https://github.com/programing360/fresh-root/tree/main/src/components/sections): `src/components/sections`
- [Site Navigation](https://github.com/programing360/fresh-root/blob/main/src/components/Global/Navbar.tsx): `src/components/Global/Navbar.tsx`

### Product Shopping

- [Product Search](https://github.com/programing360/fresh-root/blob/main/src/app/(public)/shop/shop.tsx): `src/app/(public)/shop/shop.tsx`
- [Product Cards](https://github.com/programing360/fresh-root/blob/main/src/components/ProductCard.tsx): `src/components/ProductCard.tsx`
- [Product Detail Route](https://github.com/programing360/fresh-root/blob/main/src/app/(public)/shop/%5Bid%5D/page.tsx): `src/app/(public)/shop/[id]/page.tsx`
- [Product Details](https://github.com/programing360/fresh-root/blob/main/src/app/(public)/shop/%5Bid%5D/ProductDetails.tsx): `src/app/(public)/shop/[id]/ProductDetails.tsx`
- [Product API](https://github.com/programing360/fresh-root/blob/main/src/lib/api/products.ts): `src/lib/api/products.ts`
- [Cart API](https://github.com/programing360/fresh-root/blob/main/src/lib/api/cart.ts): `src/lib/api/cart.ts`
- [Orders Page](https://github.com/programing360/fresh-root/blob/main/src/app/(public)/orders/page.tsx): `src/app/(public)/orders/page.tsx`
- [Product Model](https://github.com/programing360/fresh-root/blob/main/src/types/product.ts): `src/types/product.ts`

### Identity & Access

- [Login Page](https://github.com/programing360/fresh-root/blob/main/src/app/auth/login/Login.tsx): `src/app/auth/login/Login.tsx`
- [Registration Page](https://github.com/programing360/fresh-root/blob/main/src/app/auth/register/Register.tsx): `src/app/auth/register/Register.tsx`
- [Auth Client](https://github.com/programing360/fresh-root/blob/main/src/lib/auth-client.ts): `src/lib/auth-client.ts`
- [Client Session](https://github.com/programing360/fresh-root/blob/main/src/lib/core/session-client.ts): `src/lib/core/session-client.ts`
- [Auth Route](https://github.com/programing360/fresh-root/blob/main/src/app/api/auth/%5B...all%5D/route.ts): `src/app/api/auth/[...all]/route.ts`
- [Auth Service](https://github.com/programing360/fresh-root/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- **MongoDB Auth Store**
- [Server Requests](https://github.com/programing360/fresh-root/blob/main/src/lib/core/server.ts): `src/lib/core/server.ts`
- [Server Session](https://github.com/programing360/fresh-root/blob/main/src/lib/core/session.ts): `src/lib/core/session.ts`

### Catalog Operations

- [Dashboard Home](https://github.com/programing360/fresh-root/blob/main/src/app/(userDashboard)/dashboard/page.tsx): `src/app/(userDashboard)/dashboard/page.tsx`
- [Dashboard Overview](https://github.com/programing360/fresh-root/blob/main/src/components/dashboard/UserDashboardHome.tsx): `src/components/dashboard/UserDashboardHome.tsx`
- [Add Product Form](https://github.com/programing360/fresh-root/blob/main/src/app/(userDashboard)/dashboard/item/add/page.tsx): `src/app/(userDashboard)/dashboard/item/add/page.tsx`
- [Product Add Action](https://github.com/programing360/fresh-root/blob/main/src/lib/action/product-add.ts): `src/lib/action/product-add.ts`
- [Item Management](https://github.com/programing360/fresh-root/blob/main/src/components/dashboard/ItemManagementTable.tsx): `src/components/dashboard/ItemManagementTable.tsx`

### Other components

- **Shopper**
- **Commerce Backend**

## Connections

- Shopper → Home Page: browses
- Home Page → Home Sections: renders (evidence: `src/app/(public)/page.tsx`)
- Home Page → Product API: loads products (evidence: `src/app/(public)/page.tsx`)
- Shopper → Product Search: searches catalog
- Product Search → Product API: queries products (evidence: `src/app/(public)/shop/shop.tsx`)
- Product Search → Product Cards: renders items (evidence: `src/app/(public)/shop/shop.tsx`)
- Product Cards → Product Detail Route: opens preview (evidence: `src/components/ProductCard.tsx`)
- Product Detail Route → Product Details: renders details (evidence: `src/app/(public)/shop/[id]/page.tsx`)
- Product Detail Route → Product API: loads product (evidence: `src/app/(public)/shop/[id]/page.tsx`)
- Product API → Commerce Backend: requests catalog data (evidence: `src/lib/api/products.ts`)
- Product API → Server Requests: uses protected requests (evidence: `src/lib/api/products.ts`)
- Product API → Product Model: types product data (evidence: `src/lib/api/products.ts`)
- Shopper → Orders Page: views orders
- Product Cards → Cart API: cart actions
- Shopper → Login Page: signs in
- Shopper → Registration Page: registers
- Login Page → Auth Client: authenticates
- Registration Page → Auth Client: creates account
- Site Navigation → Auth Client: uses auth (evidence: `src/components/Global/Navbar.tsx`)
- Site Navigation → Client Session: reads session (evidence: `src/components/Global/Navbar.tsx`)
- Client Session → Auth Client: reads session (evidence: `src/lib/core/session-client.ts`)
- Auth Route → Auth Service: dispatches requests (evidence: `src/app/api/auth/[...all]/route.ts`)
- Auth Service → MongoDB Auth Store: persists auth data (evidence: `src/lib/auth.ts`)
- Shopper → Dashboard Home: manages catalog
- Dashboard Home → Dashboard Overview: renders overview (evidence: `src/app/(userDashboard)/dashboard/page.tsx`)
- Dashboard Home → Product API: loads products (evidence: `src/app/(userDashboard)/dashboard/page.tsx`)
- Add Product Form → Product Add Action: submits product (evidence: `src/app/(userDashboard)/dashboard/item/add/page.tsx`)
- Product Add Action → Server Requests: posts product (evidence: `src/lib/action/product-add.ts`)
- Item Management → Product API: updates catalog (evidence: `src/components/dashboard/ItemManagementTable.tsx`)
- Server Requests → Server Session: gets user token (evidence: `src/lib/core/server.ts`)
- Server Requests → Commerce Backend: sends requests (evidence: `src/lib/core/server.ts`)
- Server Session → Auth Service: reads auth session (evidence: `src/lib/core/session.ts`)
