# daran-11/gi-e-commerce architecture

> Architecture diagram of the GitHub repository daran-11/gi-e-commerce, 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/daran-11/gi-e-commerce
- Repository: https://github.com/daran-11/gi-e-commerce

## Overview

This is a Next.js marketplace for GI produce, with role-based experiences for shoppers, farmers, municipal staff, and administrators. The principal shopper flow is product discovery and traceability, cart management, checkout and order creation, then purchase tracking. Farmer and municipal workflows cover product, certificate, and delivery administration; administrators have management and analytics screens. Edges are limited to relationships shown in excerpts, the source index, or README; unsampled capability links are marked unverified.

Main entry points: [`src/components/productDetails/productDetailsClient.js`](https://github.com/daran-11/gi-e-commerce/blob/main/src/components/productDetails/productDetailsClient.js) (Product detail), [`src/context/cartContext.js`](https://github.com/daran-11/gi-e-commerce/blob/main/src/context/cartContext.js) (Cart state), [`src/components/checkout/CheckoutClient.js`](https://github.com/daran-11/gi-e-commerce/blob/main/src/components/checkout/CheckoutClient.js) (Checkout), [`lib/prisma.js`](https://github.com/daran-11/gi-e-commerce/blob/main/lib/prisma.js) (Prisma client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shop["Shopping and checkout"]
  node_catalog["Product discovery<br/>[page.js]"]
  node_detail["Product detail"]
  node_cartui["Cart page<br/>[cartPageClient.js]"]
  node_cartitem["Cart items<br/>[cartItem.js]"]
  node_quantity["Quantity control<br/>[quantityhandler.js]"]
  node_cartstate["Cart state<br/>[cartContext.js]"]
  node_checkout["Checkout<br/>[CheckoutClient.js]"]
  node_orderapi["Order API<br/>[route.js]"]
  node_purchases["Purchase history"]
  node_payment["Payment processing<br/>[route.js]"]
  node_omise["Omise"]
end

subgraph group_identity["Identity and persistence"]
  node_auth["Authentication<br/>[route.js]"]
  node_dbclient["Prisma client<br/>[prisma.js]"]
  node_database[("Application database")]
end

subgraph group_farm["Farmer and municipal operations"]
  node_farmerui["Farmer dashboard<br/>[page.js]"]
  node_farmerapi["Farmer product and orders APIs"]
  node_municipal["Municipal operations"]
  node_approvals["Farmer and certificate approval"]
end

subgraph group_admin["Administration and analytics"]
  node_adminui["Admin dashboard"]
end

subgraph group_trace["Product data and traceability"]
  node_traceui["Traceability views"]
  node_productapi["Product API<br/>[route.js]"]
  node_reviewsapi["Reviews API<br/>[route.js]"]
  node_standardsapi["Standards API<br/>[route.js]"]
  node_cloudstorage[("Google Cloud Storage")]
end

node_shopper(("Shopper"))

node_shopper -.->|"browses"| node_catalog
node_catalog -.->|"opens product"| node_detail
node_detail -->|"adds to cart"| node_cartstate
node_detail -->|"fetches reviews"| node_reviewsapi
node_detail -.->|"fetches product data"| node_productapi
node_cartui -->|"renders"| node_cartitem
node_cartitem -->|"reads and updates"| node_cartstate
node_cartitem -->|"renders"| node_quantity
node_quantity -->|"updates quantity"| node_cartstate
node_cartstate -.->|"uses session"| node_auth
node_cartstate -.->|"syncs cart"| node_database
node_checkout -->|"creates orders"| node_orderapi
node_orderapi -->|"checks session"| node_auth
node_orderapi -->|"queries and writes"| node_dbclient
node_dbclient -.->|"connects"| node_database
node_checkout -.->|"leads to tracking"| node_purchases
node_shopper -.->|"checks out"| node_checkout
node_farmerui -.->|"manages products and orders"| node_farmerapi
node_municipal -.->|"reviews applications"| node_approvals
node_approvals -.->|"persists approvals"| node_dbclient
node_adminui -.->|"manages marketplace"| node_database
node_adminui -.->|"views analytics"| node_adminui
node_traceui -.->|"looks up products"| node_productapi
node_detail -.->|"loads standards"| node_standardsapi
node_standardsapi -->|"reads and writes"| node_dbclient
node_standardsapi -->|"stores logos"| node_cloudstorage
node_checkout -.->|"initiates payment"| node_payment
node_payment -.->|"charges through"| node_omise

click node_catalog "https://github.com/daran-11/gi-e-commerce/blob/main/src/app/page.js"
click node_detail "https://github.com/daran-11/gi-e-commerce/blob/main/src/components/productDetails/productDetailsClient.js"
click node_cartui "https://github.com/daran-11/gi-e-commerce/blob/main/src/components/cart/cartPageClient.js"
click node_cartitem "https://github.com/daran-11/gi-e-commerce/blob/main/src/components/cart/cartItem.js"
click node_quantity "https://github.com/daran-11/gi-e-commerce/blob/main/src/components/quantityhandler.js"
click node_cartstate "https://github.com/daran-11/gi-e-commerce/blob/main/src/context/cartContext.js"
click node_checkout "https://github.com/daran-11/gi-e-commerce/blob/main/src/components/checkout/CheckoutClient.js"
click node_orderapi "https://github.com/daran-11/gi-e-commerce/blob/main/src/app/api/orders/route.js"
click node_purchases "https://github.com/daran-11/gi-e-commerce/blob/main/src/components/PurchasesPageClient.js"
click node_auth "https://github.com/daran-11/gi-e-commerce/blob/main/src/app/api/auth/%5B...nextauth%5D/route.js"
click node_dbclient "https://github.com/daran-11/gi-e-commerce/blob/main/lib/prisma.js"
click node_farmerui "https://github.com/daran-11/gi-e-commerce/blob/main/src/app/dashboard/page.js"
click node_farmerapi "https://github.com/daran-11/gi-e-commerce/tree/main/src/app/api/users/%5BuserId%5D/farmer"
click node_municipal "https://github.com/daran-11/gi-e-commerce/tree/main/src/app/municipality-dashboard"
click node_approvals "https://github.com/daran-11/gi-e-commerce/tree/main/src/app/api/approve_farmer"
click node_adminui "https://github.com/daran-11/gi-e-commerce/tree/main/src/app/admin-dashboard"
click node_traceui "https://github.com/daran-11/gi-e-commerce/tree/main/src/app/trace"
click node_productapi "https://github.com/daran-11/gi-e-commerce/blob/main/src/app/api/product/route.js"
click node_reviewsapi "https://github.com/daran-11/gi-e-commerce/blob/main/src/app/api/product/%5BProductID%5D/reviews/route.js"
click node_standardsapi "https://github.com/daran-11/gi-e-commerce/blob/main/src/app/api/standards/route.js"
click node_payment "https://github.com/daran-11/gi-e-commerce/blob/main/src/app/api/process-payment/route.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_catalog,node_detail,node_cartui,node_cartitem,node_quantity,node_cartstate,node_checkout,node_orderapi,node_purchases,node_payment,node_omise toneBlue
class node_auth,node_dbclient,node_database toneAmber
class node_farmerui,node_farmerapi,node_municipal,node_approvals toneMint
class node_adminui toneRose
class node_traceui,node_productapi,node_reviewsapi,node_standardsapi,node_cloudstorage,node_shopper toneIndigo
```

## Components

### Shopping and checkout

- [Product discovery](https://github.com/daran-11/gi-e-commerce/blob/main/src/app/page.js): `src/app/page.js`
- [Product detail](https://github.com/daran-11/gi-e-commerce/blob/main/src/components/productDetails/productDetailsClient.js): `src/components/productDetails/productDetailsClient.js`
- [Cart page](https://github.com/daran-11/gi-e-commerce/blob/main/src/components/cart/cartPageClient.js): `src/components/cart/cartPageClient.js`
- [Cart items](https://github.com/daran-11/gi-e-commerce/blob/main/src/components/cart/cartItem.js): `src/components/cart/cartItem.js`
- [Quantity control](https://github.com/daran-11/gi-e-commerce/blob/main/src/components/quantityhandler.js): `src/components/quantityhandler.js`
- [Cart state](https://github.com/daran-11/gi-e-commerce/blob/main/src/context/cartContext.js): `src/context/cartContext.js`
- [Checkout](https://github.com/daran-11/gi-e-commerce/blob/main/src/components/checkout/CheckoutClient.js): `src/components/checkout/CheckoutClient.js`
- [Order API](https://github.com/daran-11/gi-e-commerce/blob/main/src/app/api/orders/route.js): `src/app/api/orders/route.js`
- [Purchase history](https://github.com/daran-11/gi-e-commerce/blob/main/src/components/PurchasesPageClient.js): `src/components/PurchasesPageClient.js`
- [Payment processing](https://github.com/daran-11/gi-e-commerce/blob/main/src/app/api/process-payment/route.js): `src/app/api/process-payment/route.js`
- **Omise**

### Identity and persistence

- [Authentication](https://github.com/daran-11/gi-e-commerce/blob/main/src/app/api/auth/%5B...nextauth%5D/route.js): `src/app/api/auth/[...nextauth]/route.js`
- [Prisma client](https://github.com/daran-11/gi-e-commerce/blob/main/lib/prisma.js): `lib/prisma.js`
- **Application database**

### Farmer and municipal operations

- [Farmer dashboard](https://github.com/daran-11/gi-e-commerce/blob/main/src/app/dashboard/page.js): `src/app/dashboard/page.js`
- [Farmer product and orders APIs](https://github.com/daran-11/gi-e-commerce/tree/main/src/app/api/users/%5BuserId%5D/farmer): `src/app/api/users/[userId]/farmer`
- [Municipal operations](https://github.com/daran-11/gi-e-commerce/tree/main/src/app/municipality-dashboard): `src/app/municipality-dashboard`
- [Farmer and certificate approval](https://github.com/daran-11/gi-e-commerce/tree/main/src/app/api/approve_farmer): `src/app/api/approve_farmer`

### Administration and analytics

- [Admin dashboard](https://github.com/daran-11/gi-e-commerce/tree/main/src/app/admin-dashboard): `src/app/admin-dashboard`

### Product data and traceability

- [Traceability views](https://github.com/daran-11/gi-e-commerce/tree/main/src/app/trace): `src/app/trace`
- [Product API](https://github.com/daran-11/gi-e-commerce/blob/main/src/app/api/product/route.js): `src/app/api/product/route.js`
- [Reviews API](https://github.com/daran-11/gi-e-commerce/blob/main/src/app/api/product/%5BProductID%5D/reviews/route.js): `src/app/api/product/[ProductID]/reviews/route.js`
- [Standards API](https://github.com/daran-11/gi-e-commerce/blob/main/src/app/api/standards/route.js): `src/app/api/standards/route.js`
- **Google Cloud Storage**

### Other components

- **Shopper**

## Connections

- Shopper → Product discovery: browses
- Product discovery → Product detail: opens product
- Product detail → Cart state: adds to cart (evidence: `src/components/productDetails/productDetailsClient.js`)
- Product detail → Reviews API: fetches reviews (evidence: `src/components/productDetails/productDetailsClient.js`)
- Product detail → Product API: fetches product data
- Cart page → Cart items: renders (evidence: `src/components/cart/cartPageClient.js`)
- Cart items → Cart state: reads and updates (evidence: `src/components/cart/cartItem.js`)
- Cart items → Quantity control: renders (evidence: `src/components/cart/cartItem.js`)
- Quantity control → Cart state: updates quantity (evidence: `src/components/quantityhandler.js`)
- Cart state → Authentication: uses session
- Cart state → Application database: syncs cart
- Checkout → Order API: creates orders (evidence: `src/components/checkout/CheckoutClient.js`)
- Order API → Authentication: checks session (evidence: `src/app/api/orders/route.js`)
- Order API → Prisma client: queries and writes (evidence: `src/app/api/orders/route.js`)
- Prisma client → Application database: connects
- Checkout → Purchase history: leads to tracking
- Shopper → Checkout: checks out
- Farmer dashboard → Farmer product and orders APIs: manages products and orders
- Municipal operations → Farmer and certificate approval: reviews applications
- Farmer and certificate approval → Prisma client: persists approvals (evidence: `src/app/api/approve_farmer/route.js`)
- Admin dashboard → Application database: manages marketplace
- Admin dashboard → Admin dashboard: views analytics
- Traceability views → Product API: looks up products
- Product detail → Standards API: loads standards
- Standards API → Prisma client: reads and writes (evidence: `src/app/api/standards/route.js`)
- Standards API → Google Cloud Storage: stores logos (evidence: `src/app/api/standards/route.js`)
- Checkout → Payment processing: initiates payment
- Payment processing → Omise: charges through
