# keralia/nectar_ingredients architecture

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

- Interactive diagram: https://gitdiagram.com/keralia/nectar_ingredients
- Repository: https://github.com/keralia/nectar_ingredients

## Overview

Nectar Ingredients is a B2B catalog, sample-request, and direct-order platform for wholesale food powders. Customers discover products, build a sample basket or submit an inquiry, and can authenticate, check out, and pay; a chatbot also advises customers and supports order intake and tracking. Supporting capabilities include product certificates, account and admin order views, invoice delivery, and payment administration. The graph reflects explicit imports and documented integrations; several UI and API internals were not sampled, so those links are limited to README evidence.

Main entry points: [`app/api/chatbot/route.ts`](https://github.com/keralia/nectar_ingredients/blob/main/app/api/chatbot/route.ts) (AI sales assistant), [`components/checkout/CheckoutFlow.tsx`](https://github.com/keralia/nectar_ingredients/blob/main/components/checkout/CheckoutFlow.tsx) (Checkout flow), [`app/api/payment/initiate/route.ts`](https://github.com/keralia/nectar_ingredients/blob/main/app/api/payment/initiate/route.ts) (Payment initiation), [`app/products/ProductsClient.tsx`](https://github.com/keralia/nectar_ingredients/blob/main/app/products/ProductsClient.tsx) (Product catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discovery["Product discovery"]
  node_home["Company site<br/>[page.tsx]"]
  node_catalog["Product catalog<br/>[ProductsClient.tsx]"]
  node_product_data["Product data<br/>[data.ts]"]
  node_certificates["COA hub"]
end

subgraph group_sales["Sales and assistance"]
  node_sample_basket["Sample basket"]
  node_contact["Sales inquiry<br/>[ContactClient.tsx]"]
  node_form_router["Form router<br/>[route.ts]"]
  node_chat_ui["Chat widget<br/>[ChatWidget.jsx]"]
  node_chat_api["AI sales assistant<br/>[route.ts]"]
  node_validation["Input validation<br/>[validation.ts]"]
  node_groq["Groq model pool<br/>[groqPool.ts]"]
end

subgraph group_commerce["Ordering and payment"]
  node_checkout["Checkout flow<br/>[CheckoutFlow.tsx]"]
  node_order_types["Order model<br/>[index.ts]"]
  node_pricing["Pricing rules<br/>[pricing.ts]"]
  node_payment_init["Payment initiation<br/>[route.ts]"]
  node_paytm["Paytm gateway"]
end

subgraph group_operations["Order operations"]
  node_sheets[("Google Sheets")]
  node_payment_hook["Payment webhook<br/>[route.ts]"]
  node_supabase[("Supabase orders")]
  node_invoice["Invoice email service<br/>[email-service.ts]"]
  node_account_admin["Account and admin<br/>[page.tsx]"]
  node_bill_viewer["Bill viewer<br/>[BillViewer.tsx]"]
end

node_customer(("Customer"))

node_customer -->|"browses"| node_home
node_customer -->|"browses"| node_catalog
node_catalog -->|"reads"| node_product_data
node_catalog -->|"renders"| node_certificates
node_customer -->|"selects samples"| node_sample_basket
node_customer -->|"submits inquiry"| node_contact
node_contact -.->|"routes inquiry"| node_form_router
node_customer -->|"asks"| node_chat_ui
node_chat_ui -.->|"sends message"| node_chat_api
node_chat_api -->|"retrieves catalog"| node_product_data
node_chat_api -->|"validates details"| node_validation
node_chat_api -->|"calls models"| node_groq
node_chat_api -.->|"looks up or logs orders"| node_sheets
node_customer -->|"checks out"| node_checkout
node_checkout -->|"uses"| node_order_types
node_checkout -.->|"calculates totals"| node_pricing
node_checkout -.->|"initiates payment"| node_payment_init
node_payment_init -.->|"creates order"| node_supabase
node_payment_init -->|"applies pricing"| node_pricing
node_payment_init -.->|"starts transaction"| node_paytm
node_paytm -.->|"posts result"| node_payment_hook
node_payment_hook -->|"updates order"| node_supabase
node_payment_hook -->|"sends invoice"| node_invoice
node_invoice -.->|"emails receipt"| node_paytm
node_customer -.->|"views orders"| node_account_admin
node_account_admin -.->|"reads orders"| node_supabase
node_account_admin -->|"renders bill"| node_bill_viewer

click node_home "https://github.com/keralia/nectar_ingredients/blob/main/app/page.tsx"
click node_catalog "https://github.com/keralia/nectar_ingredients/blob/main/app/products/ProductsClient.tsx"
click node_product_data "https://github.com/keralia/nectar_ingredients/blob/main/lib/data.ts"
click node_certificates "https://github.com/keralia/nectar_ingredients/blob/main/components/products/CertificatesSection.tsx"
click node_sample_basket "https://github.com/keralia/nectar_ingredients/blob/main/context/SampleBasketContext.tsx"
click node_contact "https://github.com/keralia/nectar_ingredients/blob/main/app/contact/ContactClient.tsx"
click node_form_router "https://github.com/keralia/nectar_ingredients/blob/main/app/api/web-form-router/route.ts"
click node_chat_ui "https://github.com/keralia/nectar_ingredients/blob/main/components/ChatWidget.jsx"
click node_chat_api "https://github.com/keralia/nectar_ingredients/blob/main/app/api/chatbot/route.ts"
click node_validation "https://github.com/keralia/nectar_ingredients/blob/main/lib/validation.ts"
click node_groq "https://github.com/keralia/nectar_ingredients/blob/main/lib/groqPool.ts"
click node_checkout "https://github.com/keralia/nectar_ingredients/blob/main/components/checkout/CheckoutFlow.tsx"
click node_order_types "https://github.com/keralia/nectar_ingredients/blob/main/types/index.ts"
click node_pricing "https://github.com/keralia/nectar_ingredients/blob/main/lib/pricing.ts"
click node_payment_init "https://github.com/keralia/nectar_ingredients/blob/main/app/api/payment/initiate/route.ts"
click node_payment_hook "https://github.com/keralia/nectar_ingredients/blob/main/app/api/payment/webhook/route.ts"
click node_invoice "https://github.com/keralia/nectar_ingredients/blob/main/lib/email-service.ts"
click node_account_admin "https://github.com/keralia/nectar_ingredients/blob/main/app/account/page.tsx"
click node_bill_viewer "https://github.com/keralia/nectar_ingredients/blob/main/components/orders/BillViewer.tsx"

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_catalog,node_product_data,node_certificates toneBlue
class node_sample_basket,node_contact,node_form_router,node_chat_ui,node_chat_api,node_validation,node_groq toneAmber
class node_checkout,node_order_types,node_pricing,node_payment_init,node_paytm toneMint
class node_sheets,node_payment_hook,node_supabase,node_invoice,node_account_admin,node_bill_viewer toneRose
class node_customer toneIndigo
```

## Components

### Product discovery

- [Company site](https://github.com/keralia/nectar_ingredients/blob/main/app/page.tsx): `app/page.tsx`
- [Product catalog](https://github.com/keralia/nectar_ingredients/blob/main/app/products/ProductsClient.tsx): `app/products/ProductsClient.tsx`
- [Product data](https://github.com/keralia/nectar_ingredients/blob/main/lib/data.ts): `lib/data.ts`
- [COA hub](https://github.com/keralia/nectar_ingredients/blob/main/components/products/CertificatesSection.tsx): `components/products/CertificatesSection.tsx`

### Sales and assistance

- [Sample basket](https://github.com/keralia/nectar_ingredients/blob/main/context/SampleBasketContext.tsx): `context/SampleBasketContext.tsx`
- [Sales inquiry](https://github.com/keralia/nectar_ingredients/blob/main/app/contact/ContactClient.tsx): `app/contact/ContactClient.tsx`
- [Form router](https://github.com/keralia/nectar_ingredients/blob/main/app/api/web-form-router/route.ts): `app/api/web-form-router/route.ts`
- [Chat widget](https://github.com/keralia/nectar_ingredients/blob/main/components/ChatWidget.jsx): `components/ChatWidget.jsx`
- [AI sales assistant](https://github.com/keralia/nectar_ingredients/blob/main/app/api/chatbot/route.ts): `app/api/chatbot/route.ts`
- [Input validation](https://github.com/keralia/nectar_ingredients/blob/main/lib/validation.ts): `lib/validation.ts`
- [Groq model pool](https://github.com/keralia/nectar_ingredients/blob/main/lib/groqPool.ts): `lib/groqPool.ts`

### Ordering and payment

- [Checkout flow](https://github.com/keralia/nectar_ingredients/blob/main/components/checkout/CheckoutFlow.tsx): `components/checkout/CheckoutFlow.tsx`
- [Order model](https://github.com/keralia/nectar_ingredients/blob/main/types/index.ts): `types/index.ts`
- [Pricing rules](https://github.com/keralia/nectar_ingredients/blob/main/lib/pricing.ts): `lib/pricing.ts`
- [Payment initiation](https://github.com/keralia/nectar_ingredients/blob/main/app/api/payment/initiate/route.ts): `app/api/payment/initiate/route.ts`
- **Paytm gateway**

### Order operations

- **Google Sheets**
- [Payment webhook](https://github.com/keralia/nectar_ingredients/blob/main/app/api/payment/webhook/route.ts): `app/api/payment/webhook/route.ts`
- **Supabase orders**
- [Invoice email service](https://github.com/keralia/nectar_ingredients/blob/main/lib/email-service.ts): `lib/email-service.ts`
- [Account and admin](https://github.com/keralia/nectar_ingredients/blob/main/app/account/page.tsx): `app/account/page.tsx`
- [Bill viewer](https://github.com/keralia/nectar_ingredients/blob/main/components/orders/BillViewer.tsx): `components/orders/BillViewer.tsx`

### Other components

- **Customer**

## Connections

- Customer → Company site: browses (evidence: `README.md`)
- Customer → Product catalog: browses (evidence: `README.md`)
- Product catalog → Product data: reads (evidence: `app/products/ProductsClient.tsx`)
- Product catalog → COA hub: renders (evidence: `app/products/ProductsClient.tsx`)
- Customer → Sample basket: selects samples (evidence: `README.md`)
- Customer → Sales inquiry: submits inquiry (evidence: `README.md`)
- Sales inquiry → Form router: routes inquiry (evidence: `README.md`)
- Customer → Chat widget: asks (evidence: `README.md`)
- Chat widget → AI sales assistant: sends message (evidence: `README.md`)
- AI sales assistant → Product data: retrieves catalog (evidence: `app/api/chatbot/route.ts`)
- AI sales assistant → Input validation: validates details (evidence: `app/api/chatbot/route.ts`)
- AI sales assistant → Groq model pool: calls models (evidence: `app/api/chatbot/route.ts`)
- AI sales assistant → Google Sheets: looks up or logs orders (evidence: `README.md`)
- Customer → Checkout flow: checks out (evidence: `README.md`)
- Checkout flow → Order model: uses (evidence: `components/checkout/CheckoutFlow.tsx`)
- Checkout flow → Pricing rules: calculates totals (evidence: `README.md`)
- Checkout flow → Payment initiation: initiates payment (evidence: `README.md`)
- Payment initiation → Supabase orders: creates order (evidence: `README.md`)
- Payment initiation → Pricing rules: applies pricing (evidence: `app/api/payment/initiate/route.ts`)
- Payment initiation → Paytm gateway: starts transaction (evidence: `README.md`)
- Paytm gateway → Payment webhook: posts result (evidence: `README.md`)
- Payment webhook → Supabase orders: updates order (evidence: `app/api/payment/webhook/route.ts`)
- Payment webhook → Invoice email service: sends invoice (evidence: `app/api/payment/webhook/route.ts`)
- Invoice email service → Paytm gateway: emails receipt (evidence: `README.md`)
- Customer → Account and admin: views orders (evidence: `README.md`)
- Account and admin → Supabase orders: reads orders (evidence: `README.md`)
- Account and admin → Bill viewer: renders bill (evidence: `app/account/page.tsx`)
