English / Uzbek bilingual README — qisqacha loyiha mazmuni, ishga tushirish va arxitektura.
This is a Next.js (App Router) admin dashboard that uses a small local JSON backend for demo data.
-
Public demo (no login):
/demo— recruiter/Lighthouse-friendly read-only analytics view. -
UI: Tailwind CSS + small component library under
app/components/UI/. -
Routing & layouts: App Router under
app/with nested dashboard layout atapp/(dashboard)/dashboard/layout.tsx. -
API layer:
lib/api/*containsapiFetchand product helpers.API_BASE_URLis read fromNEXT_PUBLIC_API_URLor defaults tohttp://localhost:4000. -
Mock backend:
backend/db.jsonserved byjson-server(development only). -
Auth: lightweight mock auth under
app/authAPI/*(server routes set httpOnly cookies). There is also a client-sidelocalStoragetoken copy used for client guards.
Key behaviors:
- Dashboard is protected — server-side cookie check (via middleware and server layout) prevents unauthenticated access.
- Products page has a client component (
ProductsPageClient.tsx) that supports search, filters, add/edit/delete in-memory and can be wired tolib/api/products.tsfor persistent CRUD.
- Install dependencies:
npm install- Start both mock API and Next.js dev server (cross-platform):
npm run dev:all- Open the app:
http://localhost:3000
Public demo:
http://localhost:3000/demo
Notes:
dev:allusesconcurrentlyto runjson-serverandnext devtogether. You can still runnpm run jsonandnpm run devseparately.- To change the backend URL, set
NEXT_PUBLIC_API_URLin your environment. - For correct OpenGraph/sitemap/manifest URLs in production, set
NEXT_PUBLIC_SITE_URL.
Bu loyiha Next.js (App Router) asosida yozilgan admin dashboard bo'lib, demo ma'lumotlar uchun lokal JSON backend (json-server) ishlatadi.
-
Public demo (login shart emas):
/demo— recruiter/Lighthouse uchun read-only analytics sahifa. -
UI: Tailwind CSS va kichik UI komponentlari
app/components/UI/da joylashgan. -
Router va layoutlar:
app/ichida App Router; dashboard layout manzili:app/(dashboard)/dashboard/layout.tsx. -
API qatlami:
lib/api/*ichidaapiFetchva mahsulotlar uchun yordamchi funksiyalar bor.API_BASE_URLNEXT_PUBLIC_API_URLdan olinadi yokihttp://localhost:4000bo'ladi. -
Mock backend:
backend/db.json,json-serverorqali dev muhitida ishlaydi. -
Autentifikatsiya:
app/authAPI/*server route'lari httpOnly cookie o'rnatadi; mijoz tomonda esalocalStoragega token nusxasi saqlanadi, bu client-gard uchun ishlatiladi.
Asosiy xususiyatlar:
- Dashboard himoyalangan — server tarafdan cookie tekshiruvi (middleware va server layout orqali) autentifikatsiyasiz kirishni to'xtatadi.
- Mahsulotlar sahifasi client komponent sifatida ishlaydi (
ProductsPageClient.tsx) — qidiruv, filtr, qo'shish/tahrirlash/o'chirish (hozir asosan frontendda);lib/api/products.tsga ulansa serverga CRUD qiladi.
- Paketlarni o'rnating:
npm install- Ikkala xizmatni birgalikda ishga tushirish (cross-platform):
npm run dev:all- Brauzerda oching:
http://localhost:3000
Public demo:
http://localhost:3000/demo
Izohlar:
dev:allconcurrentlypaketidan foydalanadi vajson-serverhamdanext devni birgalikda ishga tushiradi. Xohlasangiz alohidanpm run jsonvanpm run devdan ham foydalanishingiz mumkin.- Agar backend URL ni o'zgartirmoqchi bo'lsangiz,
NEXT_PUBLIC_API_URLmuhit o'zgaruvchisidan foydalaning. - Production muhitida OpenGraph/sitemap/manifest URL'lar to'g'ri chiqishi uchun
NEXT_PUBLIC_SITE_URLni set qiling.
-
app/— Next.js App Router, layouts va sahifalar.app/(dashboard)/dashboard/layout.tsx— server-side layout; cookie orqali auth tekshiradi va agar token bo'lsa client layout (ClientDashboardLayout) ni render qiladi.app/components/auth/Protected.tsx— client-side guard, localStorage tekshiradi va loading ko'rsatadi.
-
app/authAPI/— server routes:login,register,logout(mock auth that sets httpOnly cookies and returns a token in JSON for client syncing). -
lib/api/config.ts—API_BASE_URLvaapiFetchutil. -
lib/api/products.ts— products CRUD helpers, shu jumladangetPaginatedmethod (uses directfetchto readX-Total-Countheader). -
lib/auth.ts— client helpers:login,register,logout(now store token inlocalStorageafter server response). -
backend/db.json— mock data used byjson-server.
- Auth flow: server sets an httpOnly cookie and authentication checks use
/authAPI/meon protected client surfaces.localStorageis only used to cache non-sensitive user profile data for UI convenience. - Server-side protection: layout and
middleware.tshandle redirects before pages render on the server, preventing flash of unauthenticated content. - Use
lib/api/*helpers for network calls — they centralize headers and error handling.
npm run dev— Next.js dev server only.npm run json— startjson-serveron port 4000.npm run dev:all— start both services together (usesconcurrently).npm run build/npm run start— build and start production server.npm run test— run unit tests.npm run test:watch— run tests in watch mode.
If you want to improve the project:
- Run
npm install. - Start dev servers:
npm run dev:all. - Make small, focused changes and follow existing patterns (App Router server/client split,
lib/api/*helpers, Tailwind UI components).
- Security notes:
docs/2FA-PRODUCTION-SECURITY.md - Email setup:
docs/EMAIL_SETUP.md - OAuth setup:
docs/OAUTH_SETUP.md - Architecture overview:
docs/ARCHITECTURE.md - SEO & social metadata:
docs/SEO.md - Public demo notes:
docs/DEMO.md