A fully-featured, type-safe admin dashboard that connects to the Product Catalog REST API - built with the latest Next.js App Router, server-side route protection, and a clean component architecture.
- Overview
- Features
- Tech Stack
- Project Structure
- Getting Started
- Environment Variables
- Pages & Routes
- Architecture
- Authentication Flow
- Component System
- API Integration
- Related Project
This is the frontend admin panel for the Product Catalog platform. It provides a full management interface for admins to handle dealers, products, enquiries, internal users, and platform metrics - all in a responsive, dark-mode-ready dashboard.
Built with the Next.js 15 App Router and React 19, it uses the latest patterns including route groups, middleware-based auth guards, and server/client component separation.
Key design decisions:
- β Type-safe throughout - every API response, form, and component is fully typed with TypeScript
- β Smart data fetching - TanStack Query handles caching, pagination, and background refetching
- β Token refresh handled automatically - Axios interceptors silently refresh expired tokens
- β Route protection at the edge - Next.js middleware guards all protected routes before render
- β Form validation with schema - React Hook Form + Zod for runtime-safe form handling
|
π Dashboard
|
π₯ User Management
|
|
π¦ Product Management
|
π© Enquiry Management
|
|
π Auth & Security
|
π¨ UI & UX
|
| Category | Technology | Purpose |
|---|---|---|
| Framework | Next.js 15 (App Router) | Routing, SSR, middleware |
| Language | TypeScript 5 | Full type safety |
| UI Library | React 19 | Component rendering |
| Styling | Tailwind CSS v4 | Utility-first styling |
| Data Fetching | TanStack Query v5 | Server state, caching, pagination |
| Tables | TanStack Table v8 | Headless table logic |
| Forms | React Hook Form + Zod | Form state + schema validation |
| HTTP Client | Axios | API calls + interceptors |
| Charts | ApexCharts | Dashboard data visualizations |
| Calendar | FullCalendar | Event calendar UI |
| UI Components | MUI v7 | Material components |
| Icons | Lucide React, Heroicons, FontAwesome | Icon sets |
| Toasts | Sonner | Non-blocking notifications |
| Alerts | SweetAlert2 | Confirmation dialogs |
| File Upload | React Dropzone | Drag & drop file input |
| Date Handling | date-fns, Flatpickr | Date formatting & pickers |
src/
βββ app/
β βββ (Dashboard)/ # Route group - protected pages
β β βββ layout.tsx # Dashboard shell (sidebar + header)
β β βββ page.tsx # Home - dashboard metrics
β β βββ dealer/
β β β βββ page.tsx # Dealer listing table
β β β βββ form/[[...id]]/page.tsx # Create / edit dealer (optional ID)
β β βββ internal-user/
β β β βββ page.tsx
β β β βββ form/[[...id]]/page.tsx
β β βββ product/
β β β βββ page.tsx
β β β βββ form/[[...id]]/page.tsx
β β βββ enquiry/
β β β βββ page.tsx
β β β βββ form/[[...id]]/page.tsx
β β βββ change-password/page.tsx
β βββ login/
β β βββ layout.tsx
β β βββ page.tsx # Public login page
β βββ layout.tsx # Root layout (theme provider, query client)
β βββ globals.css
β βββ not-found.tsx # 404 page
β
βββ layout/
β βββ AppSidebar.tsx # Collapsible sidebar with nav items
β βββ AppHeader.tsx # Top bar with notifications & user menu
β βββ Backdrop.tsx # Mobile sidebar backdrop
β
βββ components/
β βββ auth/
β β βββ LoginForm.tsx # Login form with RHF + Zod
β β βββ SignUpForm.tsx
β βββ dashboard/
β β βββ DashboardMetrics.tsx # Live metric cards
β β βββ MonthlySalesChart.tsx # ApexCharts bar chart
β β βββ StatisticsChart.tsx # ApexCharts line chart
β β βββ CountryMap.tsx # jVectorMap world map
β β βββ DemographicCard.tsx
β β βββ MonthlyTarget.tsx
β β βββ RecentOrders.tsx
β βββ tables/
β β βββ DataTable.tsx # Reusable TanStack Table wrapper
β β βββ AdvanceTable.tsx
β β βββ BasicTableOne.tsx
β β βββ Pagination.tsx
β βββ form/
β β βββ input/ # InputField, TextArea, Checkbox, Radio, etc.
β β βββ form-elements/ # DropZone, FileInput, ToggleSwitch, etc.
β β βββ switch/, date-picker.tsx
β βββ ui/
β β βββ alert/, badge/, button/ # Primitive UI components
β β βββ dropdown/, modal/
β β βββ loader/Loader.tsx
β β βββ images/, video/
β βββ user/Form.tsx # Reusable user create/edit form
β βββ common/ # PageBreadCrumb, ThemeToggle, etc.
β
βββ hooks/ # TanStack Query custom hooks
β βββ useProducts.ts
β βββ useDeleteProduct.ts
β βββ useBulkDeleteProduct.ts
β βββ useEnquiry.ts
β βββ useDeleteEnquiry.ts
β βββ useBulkDeleteEnquiry.ts
β βββ useUser.ts
β βββ useDeleteUser.ts
β βββ useBulkDeleteUser.ts
β βββ useDashboardStats.ts
β βββ useAdminUser.ts
β βββ useModal.ts
β βββ useGoBack.ts
β
βββ services/ # Axios API call functions (typed)
β βββ productServices.ts
β βββ userServices.ts
β βββ enquiryServices.ts
β βββ dashboardServices.ts
β βββ makeCategoryServices.ts
β βββ fileUploadServices.ts
β βββ cityServices.ts
β βββ propertyServices.ts
β
βββ types/ # TypeScript interfaces
β βββ productTypes.ts
β βββ userTypes.ts
β βββ enquiryTypes.ts
β βββ dashboardTypes.ts
β βββ formTypes.ts
β βββ makeCategoryTypes.ts
β βββ paginationType.ts
β βββ fileTypes.ts
β
βββ validations/ # Zod schemas
β βββ productSchema.ts
β βββ userSchema.ts
β βββ citySchema.ts
β
βββ context/
β βββ SidebarContext.tsx # Sidebar expand/collapse state
β βββ ThemeContext.tsx # Light/dark theme state
β
βββ utils/
β βββ axiosInstance.ts # Axios + token refresh interceptor
β βββ ReactQueryProvider.tsx # TanStack Query client provider
β βββ utils.ts
β
βββ middleware.ts # Next.js edge middleware - route auth guard
- Node.js v18+
- npm v9+
- The Product Catalog REST API running locally or deployed
# 1. Clone the repository
git clone https://github.com/your-username/product-catalog-admin.git
cd product-catalog-admin
# 2. Install dependencies
npm install
# 3. Set up environment variables
cp .env.example .env.local
# Fill in your API URL (see section below)
# 4. Start the development server
npm run devOpen http://localhost:3000 in your browser.
Create a .env.local file at the root:
# Backend API base URL
NEXT_PUBLIC_API_URL=http://localhost:5000The app proxies all
/api/*requests to the backend via Next.js rewrites, keeping credentials secure and avoiding CORS issues.
| Route | Description | Auth |
|---|---|---|
/login |
Admin login page | π Public |
/ |
Dashboard - live metrics overview | π |
/dealer |
Dealer listing - paginated table with search | π |
/dealer/form |
Create new dealer | π |
/dealer/form/[id] |
Edit existing dealer | π |
/internal-user |
Internal user listing | π |
/internal-user/form |
Create internal user | π |
/internal-user/form/[id] |
Edit internal user | π |
/product |
Product listing - filters, search, bulk actions | π |
/product/form |
Create product | π |
/product/form/[id] |
Edit product | π |
/enquiry |
Enquiry listing with status filters | π |
/enquiry/form/[id] |
View & update enquiry | π |
/change-password |
Admin change password | π |
π = Protected by Next.js middleware - unauthenticated users are redirected to
/login
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Browser β
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Next.js App Router β β
β β β β
β β middleware.ts βββΊ checks admin_token cookie β β
β β β β β
β β βΌ β β
β β Route Group (Dashboard)/layout.tsx β β
β β βββ AppSidebar (SidebarContext) β β
β β βββ AppHeader (UserDropdown, Notifications) β β
β β βββ Page Component β β
β β β β β
β β βΌ β β
β β Custom Hook (TanStack Query) β β
β β e.g. useProducts() β β
β β β β β
β β βΌ β β
β β Service Function (Axios) β β
β β e.g. getAllProducts() β β
β β β β β
β βββββββββββΌβββββββββββββββββββββββββββββββββββββββββ β
β β β
ββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββ
β HTTP (proxied via Next.js /api/*)
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Node.js + Express REST API β
β github.com/6ixline/nodejs-express-rest-api β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
User visits protected route
β
βΌ
middleware.ts checks admin_token cookie
β
ββββββ΄βββββ
β β
Missing Present
β β
βΌ βΌ
Redirect Allow request
to /login to proceed
with ?redirect=original_path
β
βΌ
User logs in β API sets admin_token cookie (HttpOnly)
β
βΌ
Redirect back to original path
Silent Token Refresh - handled automatically in axiosInstance.ts:
API call returns 401
β
βΌ
Axios interceptor catches error
β
βΌ
POST /api/admin/auth/refresh-token
β
ββββββ΄βββββ
β β
Success Failure
β β
βΌ βΌ
Retry Redirect to /login
original (preserving current path)
request
Built on a layered component architecture:
| Layer | Location | Examples |
|---|---|---|
| Primitives | components/ui/ |
Button, Badge, Alert, Avatar, Modal, Loader |
| Form Inputs | components/form/input/ |
InputField, TextArea, Checkbox, SearchableSelect, FileInput |
| Data Display | components/tables/ |
DataTable (TanStack), Pagination |
| Dashboard Widgets | components/dashboard/ |
DashboardMetrics, MonthlySalesChart, CountryMap |
| Layout | layout/ |
AppSidebar, AppHeader, Backdrop |
All API communication follows a consistent 3-layer pattern:
Page / Component
β
βΌ
Custom Hook (TanStack Query) β caching, loading & error states
β
βΌ
Service Function (Axios) β typed HTTP calls
β
βΌ
axiosInstance β base URL, credentials, token refresh
This admin panel is the frontend for the Product Catalog REST API:
π§ nodejs-express-rest-api - Node.js + Express 5 + MySQL backend with multi-role JWT auth, bulk Excel import, and 40+ REST endpoints.
Together they form a complete, production-ready full-stack system.
| Command | Description |
|---|---|
npm run dev |
Start development server |
npm run build |
Build for production |
npm run start |
Start production server |
npm run lint |
Run ESLint |
Distributed under the ISC License.
Built with β€οΈ using Next.js & TypeScript