Admin System Quick Start Guide
Last Updated: November 20, 2025 Status: ā Ready to Use
š Getting Started
1. Create Admin User
The user must have role: "ADMIN" in the database.
Option A: Use Admin Panel (if available)
1. Navigate to admin settings
2. Create new user with ADMIN role
Option B: Direct Database Update
UPDATE users SET role = 'ADMIN' WHERE email = 'admin@example.com';
2. Login as Admin
1. Navigate to /signin
2. Enter email and password
3. Login
4. Should see "Admin" menu in navigation (after "Blogs")
3. Access Admin Dashboard
Click "Admin" in navigation to see submenu:
- Products ā
/admin/products - Categories ā
/admin/categories - Images ā
/admin/images - Dashboard ā
/admin
š Common Tasks
Add a New Product
- Go to Admin ā Products
- Click "+ Add Product" button
- Fill in product details:
- Title (required)
- Description (optional)
- Price (required)
- Discounted Price (optional)
- Stock (optional)
- SKU (optional, e.g., SKU-000001)
- Category (required)
- Click "Create Product"
- You'll be redirected to edit page
- Upload images:
- Drag & drop or click to select
- Choose "Preview" (800x800px) or "Thumbnail" (200x200px)
- Upload completes automatically
- Images appear below in a gallery
- Click "Delete" to remove unwanted images
Edit Existing Product
- Go to Admin ā Products
- Click "Edit" on the product
- Update details as needed
- Add or remove images
- Click "Update Product"
Delete Product
- Go to Admin ā Products
- Find the product
- Click "Delete" button
- Confirm deletion
- Product removed from system
Search Products
- Go to Admin ā Products
- Use search box: "Search by title or SKU..."
- Type to search (works in real-time)
- Click "Clear" to reset search
- Results show with pagination
Manage Categories
- Go to Admin ā Categories
- View existing categories in tree structure:
- Parent categories (blue)
- Child categories indented
Add Category:
- Click "+ Add Category"
- Fill in:
- Title (required)
- Slug (required, URL-friendly)
- Image URL (optional)
- Description (optional)
- Parent (optional, for subcategories)
- Click "Create Category"
Edit Category:
- Click "Edit" on category
- Update details
- Click "Update Category"
Delete Category:
- Click "Delete" on category
- Confirm (products stay in system)
View Image Audit
- Go to Admin ā Images
- See report of:
- Complete products (with images)
- Partial products (missing some images)
- Missing products (no images)
- Shows completion percentage
- Shows how many files in directory
š¼ļø Image Management
Image Naming Convention
All images follow this pattern:
product-{id}-{type}-{index}.webp
product-5-bg-1.webp ā Product 5, Preview image 1
product-5-sm-1.webp ā Product 5, Thumbnail image 1
product-5-bg-2.webp ā Product 5, Preview image 2
Image Types
| Type | Size | Use | Name |
|---|---|---|---|
| Preview (bg) | 800x800px | Product detail page | product-X-bg-N.webp |
| Thumbnail (sm) | 200x200px | Product list/grid | product-X-sm-N.webp |
Image Upload
Supported Formats:
- JPG / JPEG
- PNG
- WebP
- GIF
Requirements:
- Max size: 10MB
- Automatically converted to WebP
- Automatically resized to correct dimensions
- Center-cropped if needed
Upload Process:
- Select image type (Preview or Thumbnail)
- Drag image onto dropzone OR click to select
- Progress bar shows upload status
- Image appears in gallery when complete
- Can upload multiple images per product
āļø Admin Menu Navigation
Menu Structure
Popular
āāā Link to home
Shop
āāā Link to shop
Contact
āāā Link to contact
Pages
āāā Shop pages
āāā Checkout
āāā Wishlist
āāā Account
āāā Other pages
Blogs
āāā Blog Grid
āāā Blog Details
āāā Archive
Admin ā (ONLY for ADMIN users)
āāā Products
ā āāā Add/edit/delete products
āāā Categories
ā āāā Create category hierarchy
āāā Images
ā āāā View audit report
āāā Dashboard
āāā Admin overview
š Security Features
Who Can Access?
| User Type | Can See Admin Menu? | Can Access /admin/* ? |
|---|---|---|
| Not Logged In | ā No | ā Redirects to /signin |
| Customer | ā No | ā Redirects to / |
| Admin | ā Yes | ā Full access |
What's Protected?
All admin routes are protected:
- ā
/admin/products - ā
/admin/products/new - ā
/admin/products/[id] - ā
/admin/categories - ā
All API endpoints under
/api/admin/*
Automatic Redirects
Non-logged-in user tries /admin/products
ā Redirected to /signin
Non-admin user tries /admin/products
ā Redirected to / (home page)
Admin user accesses /admin/products
ā Full access granted ā
š API Reference
Products API
List Products
GET /api/admin/products?page=1&limit=20&search=keyword
Create Product
POST /api/admin/products
{
"title": "Product Name",
"description": "Description",
"price": 99.99,
"discountedPrice": 79.99,
"stock": 10,
"sku": "SKU-000001",
"categoryId": 1
}
Update Product
PUT /api/admin/products/[id]
{
"title": "Updated Title",
...
}
Delete Product
DELETE /api/admin/products/[id]
Images API
Upload Image
POST /api/admin/products/images
FormData:
- file: File
- productId: number
- type: "THUMBNAIL" | "PREVIEW"
Delete Image
DELETE /api/admin/products/images?id=imageId
Image Audit Report
GET /api/admin/images/audit
Categories API
List Categories
GET /api/admin/categories
Create Category
POST /api/admin/categories
{
"title": "Category Name",
"slug": "category-name",
"description": "Description",
"parentId": null // Optional, for subcategories
}
Update Category
PUT /api/admin/categories/[id]
{
"title": "Updated Title",
...
}
Delete Category
DELETE /api/admin/categories/[id]
š Troubleshooting
Admin Menu Not Showing
Problem: "Admin" menu item doesn't appear after login
Solutions:
- Verify user role is "ADMIN" in database
- Logout and login again (refresh session)
- Check browser console for errors
- Verify NextAuth session includes role
Images Not Uploading
Problem: Image upload fails
Solutions:
- Check file is valid image format (JPG, PNG, WebP, GIF)
- Verify file size < 10MB
- Check directory
public/images/products/exists and is writable - Check server logs for Sharp errors
Can't Access Admin Pages
Problem: Redirected when trying to access /admin/products
Solutions:
- Verify you're logged in
- Verify your user has
role = "ADMIN" - Clear browser cache and login again
- Check middleware.ts is loaded (no errors in logs)
Product Not Saving
Problem: Form submission fails
Solutions:
- Verify all required fields filled (Title, Price, Category)
- Check price is a valid number
- Check category is selected
- Look for error message in red box
- Check browser console for errors
š” Tips & Best Practices
Product Management
- ā Always provide meaningful product titles
- ā Use descriptive SKU codes for inventory tracking
- ā Add both preview and thumbnail images
- ā Write detailed descriptions for better SEO
- ā Set realistic prices and discounts
- ā Keep stock numbers accurate
Image Management
- ā Use high-quality source images (original size)
- ā Consistency matters - use similar crops/angles
- ā Upload preview (big) image first, then thumbnail (small)
- ā WebP conversion happens automatically
- ā
Images are accessible via
/images/products/{filename}
Category Management
- ā Use clear, descriptive category names
- ā Keep hierarchy shallow (1-2 levels max)
- ā Use consistent slug format (lowercase, hyphens)
- ā Parent categories group related products
- ā Delete empty categories to keep clean
Search & Navigation
- ā Users can search by product title
- ā Users can search by SKU
- ā Category filtering works automatically
- ā Product counts update in real-time
š Support Resources
Documentation Files:
docs/plans/PLAN_12_ADMIN_PRODUCT_IMAGE_MANAGEMENT.mddocs/plans/PLAN_12_SUPPLEMENT_ADMIN_NAVIGATION.mddocs/implementation/PLAN_12_IMPLEMENTATION_SUMMARY.mddocs/implementation/ADMIN_NAVIGATION_IMPLEMENTATION.md
Code References:
- Product components:
src/components/features/admin/ProductForm/* - Category components:
src/components/features/admin/CategoryList/* - Image widget:
src/components/features/admin/ProductForm/ImageUploadWidget/* - API routes:
src/app/api/admin/* - Utilities:
src/lib/image-processing.ts,src/lib/file-naming.ts,src/lib/validators.ts
ā Verification Checklist
After setup, verify:
- Admin user created with role = "ADMIN"
- Can login successfully
- "Admin" menu appears in navigation
- Can click "Admin" and see submenu
- Can access /admin/products
- Can access /admin/categories
- Can create a test product
- Can upload images to product
- Can edit existing products
- Can delete products
- Non-admin users can't see Admin menu
- Non-admin users redirected from /admin routes
š You're Ready!
The admin system is fully functional. Start managing your products and categories!
Quick Access:
- Products: Click Admin ā Products
- Categories: Click Admin ā Categories
- Images: Click Admin ā Images
- Dashboard: Click Admin ā Dashboard
Last Updated: November 20, 2025 Version: 1.0 Status: Production Ready