How arkshgroup/food_new works
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: db.ts Prisma database client · page.tsx Storefront routes · layout.tsx Customer access boundary · product.service.ts Catalog and content reads
Components 25
Next.js route domains
- App composition
src/app/layout.tsx - Storefront routes · Public catalog/content and protected customer pages.
src/app/(marketing)/(pages)/(public)/page.tsx - Customer access boundary
src/app/(marketing)/(pages)/(protected)/layout.tsx - Authentication pages
src/app/(auth)/(pages)/auth/login/page.tsx - NextAuth endpoint
src/app/api/auth/[...nextauth]/route.ts - Auth configuration
src/lib/auth.ts
Commerce application
- Catalog and content reads · Provides products, search, and content to storefront pages.
src/app/(marketing)/_services/product.service.ts - Product discovery
src/app/(marketing)/_services/product-search.service.ts - Product detail page
src/app/(marketing)/(pages)/(public)/products/[slug]/page.tsx - Landing composition
src/app/(marketing)/_components/landing/home-deferred-sections.tsx - Bulk inquiry writes
src/app/(marketing)/_mutation/bulk-order-inquiry.mutation.ts - Cart reads
src/app/(marketing)/_services/cart.service.ts - Cart writes
src/app/(marketing)/_mutation/cart.mutation.ts - Checkout and order submit
src/app/(marketing)/_components/checkout/place-order-form.tsx - Order writes
src/app/(marketing)/_mutation/order.mutation.ts - Payment proof · Supports manual or QR-mediated payment processing.
src/app/(marketing)/_mutation/payment.mutation.ts
Admin operations
- Admin control plane
src/app/(admin)/(pages)/admin/page.tsx - Admin authorization
src/app/(admin)/_helper/only-admin.tsx - Catalog operations · Reads, validates, and updates catalog data.
src/app/(admin)/_services/products.service.ts - Delivery fulfillment
src/app/(admin)/_components/order/create-pathoo-order.tsx
External integrations
- Operational APIs · Merchant feed, flash-sale cron, QR, exports, uploads, and delivery pricing.
src/app/api/feed/google-merchant/route.ts - Pathao delivery · Token-managed delivery lookup, pricing, and fulfillment.
src/config/pathao.config.ts - Email and object storage
src/lib/nodemailer.ts
Other components
- PostgreSQL commerce data · Users, catalog, carts, orders, content, and delivery records.
prisma/schema/schema.prisma - Prisma database client
src/lib/db.ts
Connections 31
- 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