# arkshgroup/food_new architecture

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

- Interactive diagram: https://gitdiagram.com/arkshgroup/food_new
- Repository: https://github.com/arkshgroup/food_new

## Overview

#### 1. Purpose and runtime
A full-stack Next.js App Router e-commerce system for food products: storefront, authenticated customer area, operations admin, orders/cart/checkout, content, and catalog management. TypeScript React is the application runtime; PostgreSQL is the system of record through Prisma. Root application composition begins at `src/app/layout.tsx`, with route groups under `src/app/(marketing)`, `src/app/(admin)`, and `src/app/(auth)`.

#### 2. Route domains and access boundaries
Marketing routes expose catalog, product detail, blogs, informational pages, and wishlist; protected marketing routes contain cart, checkout, and customer dashboard. Admin routes are isolated in an admin layout and include dashboard plus operational CRUD. Authentication routes cover registration, login, password recovery, and reset.
- `src/app/(marketing)/(pages)/(public)/page.tsx`
- `src/app/(marketing)/(pages)/(protected)/layout.tsx`
- `src/app/(admin)/(pages)/admin/page.tsx`
- `src/app/(auth)/(pages)/auth/login/page.tsx`

Authentication is served through NextAuth at `src/app/api/auth/[...nextauth]/route.ts`, with shared auth configuration in `src/lib/auth.ts`; admin authorization has a dedicated guard at `src/app/(admin)/_helper/only-admin.tsx`.

#### 3. Persistence and domain model
Prisma schema fragments define the commerce core: users, products/images/categories/brands, carts, orders and shipping, discounts, reviews, blogs, inquiries, and delivery-path records. Seed inputs and TypeScript seed runners support initialized catalog/content data.
- `prisma/schema/schema.prisma`
- `prisma/schema/product.prisma`
- `prisma/schema/order.prisma`
- `prisma/schema/cart.prisma`
- `src/lib/db.ts`

The README documents direct PostgreSQL backup/restore and data migration operations; `backup.sql` is a repository-level database snapshot.

#### 4. Storefront catalog and content flow
Public pages obtain catalog/content through marketing services, then compose product grids/details and landing sections. Product discovery includes filtering, search, category/brand presentation, reviews, and bulk inquiries. Server-side data access is separated from mutation handlers and client state hooks.
- `src/app/(marketing)/_services/product.service.ts`
- `src/app/(marketing)/_services/product-search.service.ts`
- `src/app/(marketing)/(pages)/(public)/products/[slug]/page.tsx`
- `src/app/(marketing)/_components/landing/home-deferred-sections.tsx`
- `src/app/(marketing)/_mutation/bulk-order-inquiry.mutation.ts`

#### 5. Purchase lifecycle
Protected users mutate cart state, proceed through checkout with shipping/location and discount selection, submit an order, then view success and order-detail pages. Cart/order services represent the persistence-read boundary; mutations are the write boundary; React hooks coordinate client interaction.
- `src/app/(marketing)/_services/cart.service.ts`
- `src/app/(marketing)/_mutation/cart.mutation.ts`
- `src/app/(marketing)/_components/checkout/place-order-form.tsx`
- `src/app/(marketing)/_mutation/order.mutation.ts`
- `src/app/(marketing)/(pages)/(protected)/checkout/success/[id]/page.tsx`

Payment proof and QR behavior have dedicated mutation/API paths, suggesting manual or QR-mediated payment processing rather than a conventional payment gateway integration.
- `src/app/(marketing)/_mutation/payment.mutation.ts`
- `src/app/api/qr/route.ts`

#### 6. Admin operations pipeline
Admin pages read through per-domain services, render tables/forms, validate payloads, and execute server mutations for catalog, merchandising, promotions, content, customer service, and order fulfillment. This is the primary back-office control plane.
- `src/app/(admin)/_services/products.service.ts`
- `src/app/(admin)/_mutation/products.mutation.ts`
- `src/app/(admin)/_validation/products.validation.ts`
- `src/app/(admin)/_components/order/create-pathoo-order.tsx`
- `src/app/(admin)/_services/dashboard.service.ts`

#### 7. Integrations and operational APIs
Route handlers expose integration-facing functionality: Google Merchant product feeds, scheduled flash-sale work, product exports/files, uploads, and Pathao delivery lookup/pricing. Pathao configuration/token management, S3-compatible object storage, Nodemailer emails, and static/public assets sit outside the database boundary.
- `src/app/api/feed/google-merchant/route.ts`
- `src/app/api/cron/flash-sale/route.ts`
- `src/app/api/pathao/price-plan/route.ts`
- `src/config/pathao.config.ts`
- `src/lib/pathoo-token.ts`
- `src/lib/s3.ts`
- `src/lib/nodemailer.ts`

Transactional communication templates cover auth reset, contacts, inquiries, orders, and delivery tracking under `src/emails/`.

Main entry points: [`src/lib/db.ts`](https://github.com/arkshgroup/food_new/blob/main/src/lib/db.ts) (Prisma database client), [`src/app/(marketing)/(pages)/(public)/page.tsx`](https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/(pages)/(public)/page.tsx) (Storefront routes), [`src/app/(marketing)/(pages)/(protected)/layout.tsx`](https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/(pages)/(protected)/layout.tsx) (Customer access boundary), [`src/app/(marketing)/_services/product.service.ts`](https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/_services/product.service.ts) (Catalog and content reads)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_routes["Next.js route domains"]
  node_app_layout["App composition<br/>Next.js root layout<br/>[layout.tsx]"]
  node_marketing_routes["Storefront routes<br/>marketing pages<br/>[page.tsx]"]
  node_protected_layout["Customer access boundary<br/>protected layout<br/>[layout.tsx]"]
  node_auth_routes["Authentication pages<br/>auth pages<br/>[page.tsx]"]
  node_nextauth["NextAuth endpoint<br/>API route<br/>[route.ts]"]
  node_auth_config["Auth configuration<br/>auth library<br/>[auth.ts]"]
end

subgraph group_commerce["Commerce application"]
  node_catalog_content["Catalog and content reads<br/>marketing services<br/>[product.service.ts]"]
  node_product_search["Product discovery<br/>search service"]
  node_product_detail["Product detail page<br/>storefront page<br/>[page.tsx]"]
  node_landing_sections["Landing composition<br/>React sections"]
  node_bulk_inquiry["Bulk inquiry writes<br/>server mutation"]
  node_cart_service["Cart reads<br/>commerce service<br/>[cart.service.ts]"]
  node_cart_mutation["Cart writes<br/>server mutation<br/>[cart.mutation.ts]"]
  node_checkout["Checkout and order submit<br/>checkout form"]
  node_order_mutation["Order writes<br/>server mutation<br/>[order.mutation.ts]"]
  node_payment_proof["Payment proof<br/>payment mutation"]
end

subgraph group_admin["Admin operations"]
  node_admin_dashboard["Admin control plane<br/>admin dashboard<br/>[page.tsx]"]
  node_admin_guard["Admin authorization<br/>access guard<br/>[only-admin.tsx]"]
  node_admin_catalog_ops["Catalog operations<br/>admin service and mutation"]
  node_fulfillment["Delivery fulfillment<br/>admin order component"]
end

subgraph group_integrations["External integrations"]
  node_operational_apis["Operational APIs<br/>route handlers<br/>[route.ts]"]
  node_pathao{{"Pathao delivery<br/>delivery integration<br/>[pathao.config.ts]"}}
  node_messaging_storage{{"Email and object storage<br/>infrastructure adapters<br/>[nodemailer.ts]"}}
end

node_database[("PostgreSQL commerce data<br/>Prisma system of record<br/>[schema.prisma]")]
node_prisma_client["Prisma database client<br/>data access<br/>[db.ts]"]

node_app_layout --> node_marketing_routes
node_app_layout --> node_auth_routes
node_app_layout --> node_admin_dashboard
node_protected_layout -->|"requires session"| node_nextauth
node_auth_routes -->|"sign-in flows"| node_nextauth
node_nextauth -->|"uses"| node_auth_config
node_marketing_routes -->|"protected pages"| node_protected_layout
node_marketing_routes -->|"reads catalog/content"| node_catalog_content
node_catalog_content -->|"discovery"| node_product_search
node_catalog_content -->|"product data"| node_product_detail
node_marketing_routes -->|"composes"| node_landing_sections
node_marketing_routes -->|"submits"| node_bulk_inquiry
node_protected_layout -->|"reads cart"| node_cart_service
node_protected_layout -->|"updates cart"| node_cart_mutation
node_cart_service -->|"cart state"| node_checkout
node_cart_mutation -->|"updated cart"| node_checkout
node_checkout -->|"places order"| node_order_mutation
node_checkout -->|"payment proof"| node_payment_proof
node_admin_dashboard -->|"authorized by"| node_admin_guard
node_admin_dashboard -->|"operates catalog"| node_admin_catalog_ops
node_admin_dashboard -->|"fulfills orders"| node_fulfillment
node_catalog_content -->|"queries"| node_prisma_client
node_cart_service -->|"queries"| node_prisma_client
node_cart_mutation -->|"persists"| node_prisma_client
node_order_mutation -->|"persists"| node_prisma_client
node_admin_catalog_ops -->|"reads and writes"| node_prisma_client
node_prisma_client -->|"Prisma access"| node_database
node_fulfillment -->|"creates delivery"| node_pathao
node_operational_apis -->|"delivery pricing"| node_pathao
node_payment_proof -->|"QR flow"| node_operational_apis
node_order_mutation -->|"order communication"| node_messaging_storage

click node_app_layout "https://github.com/arkshgroup/food_new/blob/main/src/app/layout.tsx"
click node_marketing_routes "https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/(pages)/(public)/page.tsx"
click node_protected_layout "https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/(pages)/(protected)/layout.tsx"
click node_auth_routes "https://github.com/arkshgroup/food_new/blob/main/src/app/(auth)/(pages)/auth/login/page.tsx"
click node_nextauth "https://github.com/arkshgroup/food_new/blob/main/src/app/api/auth/%5B...nextauth%5D/route.ts"
click node_auth_config "https://github.com/arkshgroup/food_new/blob/main/src/lib/auth.ts"
click node_catalog_content "https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/_services/product.service.ts"
click node_product_search "https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/_services/product-search.service.ts"
click node_product_detail "https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/(pages)/(public)/products/%5Bslug%5D/page.tsx"
click node_landing_sections "https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/_components/landing/home-deferred-sections.tsx"
click node_bulk_inquiry "https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/_mutation/bulk-order-inquiry.mutation.ts"
click node_cart_service "https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/_services/cart.service.ts"
click node_cart_mutation "https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/_mutation/cart.mutation.ts"
click node_checkout "https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/_components/checkout/place-order-form.tsx"
click node_order_mutation "https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/_mutation/order.mutation.ts"
click node_payment_proof "https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/_mutation/payment.mutation.ts"
click node_admin_dashboard "https://github.com/arkshgroup/food_new/blob/main/src/app/(admin)/(pages)/admin/page.tsx"
click node_admin_guard "https://github.com/arkshgroup/food_new/blob/main/src/app/(admin)/_helper/only-admin.tsx"
click node_admin_catalog_ops "https://github.com/arkshgroup/food_new/blob/main/src/app/(admin)/_services/products.service.ts"
click node_fulfillment "https://github.com/arkshgroup/food_new/blob/main/src/app/(admin)/_components/order/create-pathoo-order.tsx"
click node_database "https://github.com/arkshgroup/food_new/blob/main/prisma/schema/schema.prisma"
click node_prisma_client "https://github.com/arkshgroup/food_new/blob/main/src/lib/db.ts"
click node_operational_apis "https://github.com/arkshgroup/food_new/blob/main/src/app/api/feed/google-merchant/route.ts"
click node_pathao "https://github.com/arkshgroup/food_new/blob/main/src/config/pathao.config.ts"
click node_messaging_storage "https://github.com/arkshgroup/food_new/blob/main/src/lib/nodemailer.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_app_layout,node_marketing_routes,node_protected_layout,node_auth_routes,node_nextauth,node_auth_config toneBlue
class node_catalog_content,node_product_search,node_product_detail,node_landing_sections,node_bulk_inquiry,node_cart_service,node_cart_mutation,node_checkout,node_order_mutation,node_payment_proof toneAmber
class node_admin_dashboard,node_admin_guard,node_admin_catalog_ops,node_fulfillment toneMint
class node_operational_apis,node_pathao,node_messaging_storage toneRose
class node_database,node_prisma_client toneNeutral
```

## Components

### Next.js route domains

- [App composition](https://github.com/arkshgroup/food_new/blob/main/src/app/layout.tsx): Next.js root layout · `src/app/layout.tsx`
- [Storefront routes](https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/(pages)/(public)/page.tsx): marketing pages · Public catalog/content and protected customer pages. · `src/app/(marketing)/(pages)/(public)/page.tsx`
- [Customer access boundary](https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/(pages)/(protected)/layout.tsx): protected layout · `src/app/(marketing)/(pages)/(protected)/layout.tsx`
- [Authentication pages](https://github.com/arkshgroup/food_new/blob/main/src/app/(auth)/(pages)/auth/login/page.tsx): auth pages · `src/app/(auth)/(pages)/auth/login/page.tsx`
- [NextAuth endpoint](https://github.com/arkshgroup/food_new/blob/main/src/app/api/auth/%5B...nextauth%5D/route.ts): API route · `src/app/api/auth/[...nextauth]/route.ts`
- [Auth configuration](https://github.com/arkshgroup/food_new/blob/main/src/lib/auth.ts): auth library · `src/lib/auth.ts`

### Commerce application

- [Catalog and content reads](https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/_services/product.service.ts): marketing services · Provides products, search, and content to storefront pages. · `src/app/(marketing)/_services/product.service.ts`
- [Product discovery](https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/_services/product-search.service.ts): search service · `src/app/(marketing)/_services/product-search.service.ts`
- [Product detail page](https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/(pages)/(public)/products/%5Bslug%5D/page.tsx): storefront page · `src/app/(marketing)/(pages)/(public)/products/[slug]/page.tsx`
- [Landing composition](https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/_components/landing/home-deferred-sections.tsx): React sections · `src/app/(marketing)/_components/landing/home-deferred-sections.tsx`
- [Bulk inquiry writes](https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/_mutation/bulk-order-inquiry.mutation.ts): server mutation · `src/app/(marketing)/_mutation/bulk-order-inquiry.mutation.ts`
- [Cart reads](https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/_services/cart.service.ts): commerce service · `src/app/(marketing)/_services/cart.service.ts`
- [Cart writes](https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/_mutation/cart.mutation.ts): server mutation · `src/app/(marketing)/_mutation/cart.mutation.ts`
- [Checkout and order submit](https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/_components/checkout/place-order-form.tsx): checkout form · `src/app/(marketing)/_components/checkout/place-order-form.tsx`
- [Order writes](https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/_mutation/order.mutation.ts): server mutation · `src/app/(marketing)/_mutation/order.mutation.ts`
- [Payment proof](https://github.com/arkshgroup/food_new/blob/main/src/app/(marketing)/_mutation/payment.mutation.ts): payment mutation · Supports manual or QR-mediated payment processing. · `src/app/(marketing)/_mutation/payment.mutation.ts`

### Admin operations

- [Admin control plane](https://github.com/arkshgroup/food_new/blob/main/src/app/(admin)/(pages)/admin/page.tsx): admin dashboard · `src/app/(admin)/(pages)/admin/page.tsx`
- [Admin authorization](https://github.com/arkshgroup/food_new/blob/main/src/app/(admin)/_helper/only-admin.tsx): access guard · `src/app/(admin)/_helper/only-admin.tsx`
- [Catalog operations](https://github.com/arkshgroup/food_new/blob/main/src/app/(admin)/_services/products.service.ts): admin service and mutation · Reads, validates, and updates catalog data. · `src/app/(admin)/_services/products.service.ts`
- [Delivery fulfillment](https://github.com/arkshgroup/food_new/blob/main/src/app/(admin)/_components/order/create-pathoo-order.tsx): admin order component · `src/app/(admin)/_components/order/create-pathoo-order.tsx`

### External integrations

- [Operational APIs](https://github.com/arkshgroup/food_new/blob/main/src/app/api/feed/google-merchant/route.ts): route handlers · Merchant feed, flash-sale cron, QR, exports, uploads, and delivery pricing. · `src/app/api/feed/google-merchant/route.ts`
- [Pathao delivery](https://github.com/arkshgroup/food_new/blob/main/src/config/pathao.config.ts): delivery integration · Token-managed delivery lookup, pricing, and fulfillment. · `src/config/pathao.config.ts`
- [Email and object storage](https://github.com/arkshgroup/food_new/blob/main/src/lib/nodemailer.ts): infrastructure adapters · `src/lib/nodemailer.ts`

### Other components

- [PostgreSQL commerce data](https://github.com/arkshgroup/food_new/blob/main/prisma/schema/schema.prisma): Prisma system of record · Users, catalog, carts, orders, content, and delivery records. · `prisma/schema/schema.prisma`
- [Prisma database client](https://github.com/arkshgroup/food_new/blob/main/src/lib/db.ts): data access · `src/lib/db.ts`

## Connections

- App composition → Storefront routes
- App composition → Authentication pages
- App composition → Admin control plane
- Customer access boundary → NextAuth endpoint: requires session
- Authentication pages → NextAuth endpoint: sign-in flows
- NextAuth endpoint → Auth configuration: uses
- Storefront routes → Customer access boundary: protected pages
- Storefront routes → Catalog and content reads: reads catalog/content
- Catalog and content reads → Product discovery: discovery
- Catalog and content reads → Product detail page: product data
- Storefront routes → Landing composition: composes
- Storefront routes → Bulk inquiry writes: submits
- Customer access boundary → Cart reads: reads cart
- Customer access boundary → Cart writes: updates cart
- Cart reads → Checkout and order submit: cart state
- Cart writes → Checkout and order submit: updated cart
- Checkout and order submit → Order writes: places order
- Checkout and order submit → Payment proof: payment proof
- Admin control plane → Admin authorization: authorized by
- Admin control plane → Catalog operations: operates catalog
- Admin control plane → Delivery fulfillment: fulfills orders
- Catalog and content reads → Prisma database client: queries
- Cart reads → Prisma database client: queries
- Cart writes → Prisma database client: persists
- Order writes → Prisma database client: persists
- Catalog operations → Prisma database client: reads and writes
- Prisma database client → PostgreSQL commerce data: Prisma access
- Delivery fulfillment → Pathao delivery: creates delivery
- Operational APIs → Pathao delivery: delivery pricing
- Payment proof → Operational APIs: QR flow
- Order writes → Email and object storage: order communication
