How minhtoan-nmt/web-programming-project works
Project type and purpose
• This is a full-stack e-commerce web application built on Next.js 13 (App Router).
• It contains three “zones” or domains:
– Client-facing storefront ((client))
– Authentication flows ((auth))
– Admin panel for managing products, posts, users, invoices ((admin))
• It exposes REST-style API endpoints via Next.js route handlers under src/app/api.
File structure
• Top-level config & scripts:
– Dockerfile, .env, next.config.mjs, postcss.config.mjs, jsconfig.json
• Public assets: public/image/**
• Source code (src/app):
– (client), (auth), (admin) sub-folders each with nested route folders and page.js files
– _component and _comhome shared React components (Navbar, Footer, Banner, etc.)
– API folder (src/app/api) with sub-folders per resource (products, post, cart, user, comment, invoice status) each implementing a route.js handler
• Global styles: globals.css
• Package & lock files: package.json, package-lock.json
README
• Confirms this is a Next.js “create-next-app” boilerplate with integrated font optimization.
Main components & their interactions
a. Browser clients (desktop/mobile)
– Render React components delivered by Next.js
– Call internal API endpoints (fetch) for data
b. Next.js server (Node.js)
– Serves Server Components (SSR) from app/**/*.js
– Serves Client Components for browser interactivity
– Hosts RESTful route handlers under src/app/api/** (serverless functions)
– Reads environment variables from .env (e.g., DB URL, JWT secret)
c. Data store
– A relational (MySQL/Postgres) or NoSQL (MongoDB) database (connection code resides inside API route handlers)
d. Static assets
– Hosted from public/image
e. External services (optional)
– Email service for contact form
– Payment gateway (Stripe/PayPal) invoked in checkout flow
– Authentication provider (custom JWT or third-party OTP)
Interactions:
• Client UI → Next.js Server Components → API → Database
• Admin UI ↔ API ↔ Database
• Auth UI ↔ API ↔ Database / JWT issuance
• External payment gateway ↔ API ↔ Database
Architectural patterns & design principles
• Monolithic Next.js App Router combining front- and back-end in one codebase
• Domain-driven folder structure ((client), (auth), (admin))
• Separation of concerns:
– Server Components for data-fetching and SSR
– Client Components for interactive bits (modals, confirm dialogs)
– API route handlers encapsulate CRUD operations
• Shared UI components under _component and _comhome
• CSS Modules and global CSS for styling
• Containerization via Dockerfile