Cafe storefront and admin dashboard. Next.js 15 (App Router) talks to a separate Express + MongoDB API in api-server/ (git submodule).
| Path | Role |
|---|---|
app/(storefront)/ |
Public site: menu, product, orders, lunch, ASMR, about |
app/admin/ |
Protected admin UI (JWT in localStorage) |
components/ |
Shared React components |
lib/api.ts |
fetchAPI, endpoints, formatPrice (vi-VN), getImageUrl |
context/AuthContext.tsx |
Admin auth (vt_admin_token, vt_admin_user) |
api-server/ |
REST API (submodule: vitex-cafe-api) |
Frontend (repo root):
npm install
cp .env.example .env.local # then edit values
npm run dev # http://localhost:3000API (api-server/):
cd api-server
npm install
cp .env.example .env # MONGODB_URI, JWT_SECRET, ALLOWED_ORIGINS
npm run dev # http://localhost:5000Set NEXT_PUBLIC_API_URL=http://localhost:5000/api in .env.local. Timezone for business logic is Asia/Ho_Chi_Minh.
Optional: npm run seed in api-server/ for sample data.
- Imports:
@/alias → project root (tsconfig.json). - API calls: Use
fetchAPIandendpointsfrom@/lib/api— do not duplicate base URL logic. - Prices: Display with
formatPrice(Vietnamese locale). - Admin routes: Client-side guard in
app/admin/layout.tsx; token attached automatically byfetchAPI. - Styling: Tailwind CSS v4,
app/globals.css, Lucide icons,motionfor animations. - Submodule: Changes inside
api-server/may need a commit in the submodule repo, not only the parent.
| Command | Where | Purpose |
|---|---|---|
npm run dev |
root | Next dev server |
npm run build |
root | Production build |
npm run lint |
root | ESLint |
npm run dev |
api-server | API with nodemon |
npm run seed |
api-server | Seed MongoDB |
.env,.env.local, and any file with real API keys orJWT_SECRETnode_modules/,.next/
Project-specific guidance lives in .cursor/rules/ (overview, frontend, API). Prefer those over generic assumptions when editing matching files.