Skip to content

About

Production-ready admin dashboard built with Next.js 15, TypeScript & Tailwind CSS - frontend for the Product Catalog REST API

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

3 Commits

Folders and files

Repository files navigation

πŸ–₯️ Product Catalog - Admin Panel

A production-grade admin dashboard built with Next.js 15, TypeScript & Tailwind CSS


Next.js React TypeScript Tailwind CSS TanStack Query License: ISC


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.


πŸ“‹ Table of Contents


πŸ” Overview

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

✨ Features

πŸ“Š Dashboard

  • Live metrics - Dealers, Products, Enquiries, Internal Users
  • Real-time count cards with navigation shortcuts
  • Dark mode support across all components
  • Responsive grid layout

πŸ‘₯ User Management

  • Dealer management - full CRUD + bulk delete
  • Internal user management - full CRUD
  • Paginated data tables with search & sort
  • Bulk selection and bulk status updates

πŸ“¦ Product Management

  • Product listing with advanced filters (make, category, status)
  • Create / edit product forms with validation
  • Bulk delete and bulk status update
  • Reference code and keyword search

πŸ“© Enquiry Management

  • View all enquiries with filters
  • Update status, priority, and remarks
  • Bulk delete enquiries
  • Enquiry detail view

πŸ” Auth & Security

  • Cookie-based JWT authentication
  • Middleware route protection (Next.js edge)
  • Silent token refresh via Axios interceptor
  • Redirect to original page after login
  • Change password flow

🎨 UI & UX

  • Light / Dark theme toggle with context
  • Collapsible sidebar with hover expand
  • Toast notifications (Sonner)
  • SweetAlert2 for delete confirmations
  • Fully responsive mobile layout

πŸ› οΈ Tech Stack

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

πŸ“ Project Structure

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

πŸš€ Getting Started

Prerequisites

Installation

# 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 dev

Open http://localhost:3000 in your browser.


πŸ”§ Environment Variables

Create a .env.local file at the root:

# Backend API base URL
NEXT_PUBLIC_API_URL=http://localhost:5000

The app proxies all /api/* requests to the backend via Next.js rewrites, keeping credentials secure and avoiding CORS issues.


πŸ“„ Pages & Routes

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


πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    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       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ” Authentication Flow

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

🧩 Component System

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

πŸ”Œ API Integration

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

πŸ”— Related Project

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.


πŸ“¦ Scripts

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

πŸ“„ License

Distributed under the ISC License.


Built with ❀️ using Next.js & TypeScript

⬆ Back to top

About

Production-ready admin dashboard built with Next.js 15, TypeScript & Tailwind CSS - frontend for the Product Catalog REST API

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages