This file provides guidance to WARP (warp.dev) when working with code in this repository.
ColorTech Panel Beaters is a Next.js 15 automotive panel beating and spray painting service application with a PostgreSQL database using Prisma ORM, Cloudinary for media management, and NextAuth for authentication. The project features a comprehensive admin portal for content management.
Framework Stack:
- Frontend: Next.js 15 (App Router) with TypeScript
- Database: PostgreSQL with Prisma ORM
- Authentication: NextAuth v4 with Prisma adapter
- Media Storage: Vercel Blob for image/video uploads
- Styling: Tailwind CSS with Radix UI components
- State Management: React Query (@tanstack/react-query)
Database Models (Prisma Schema):
- User management with roles (admin/staff)
- Service management with categories and bookings
- Gallery items with multiple image types (before/after, single, video)
- Blog posts with rich content and media
- Reviews, testimonials, and FAQ management
- Form submissions and homepage sections
Key Directory Structure:
src/app/- Next.js App Router pages and layoutssrc/components/- Reusable React componentssrc/lib/- Utilities, database connections, and shared logicsrc/services/- API service layers and business logicprisma/- Database schema and migrationspublic/- Static assets including uploaded media
# Generate Prisma client (run after schema changes)
npx prisma generate
# Run database migrations
npm run db:migrate
# Reset database (development only)
npm run db:reset
# Seed database with initial data
npm run db:seed
# Open Prisma Studio (database GUI)
npm run db:studio
# Check database connection and contents
node check-db.js# Start development server
npm run dev
# Build for production
npm run build
# Start production server
npm start# Run tests
npm test
# Run linting
npm run lint
# Run database migrations (for CI/CD)
npm run migrate# Setup Docker environment
npm run docker:setup
# Build and start containers
npm run docker:up
# Stop containers
npm run docker:downAll database operations go through the DatabaseService class in src/lib/database.ts. This provides:
- Centralized database access with Prisma
- Consistent error handling
- Type-safe database operations
- Connection pooling management
API routes follow REST conventions:
src/app/api/content/[resource]/route.ts- Content management APIssrc/app/api/upload/route.ts- Media upload via Cloudinary- Each route handles GET, POST, PUT, DELETE as needed
- Pages: Located in
src/app/[route]/page.tsx - Layouts: Shared layouts in
src/app/[route]/layout.tsx - Components: Reusable components in
src/components/ - Admin Interface: Complete admin portal at
src/app/admin/
Images and videos are stored in Vercel Blob with these endpoints:
- Upload:
/api/uploadand/api/content/media - Retrieval: Direct Vercel Blob URLs stored in database
- Gallery management integrated with database records
- Files stored with unique filenames in
colortech/folder
Required environment variables:
DATABASE_URL- PostgreSQL connection stringNEXTAUTH_URL- NextAuth callback URLNEXTAUTH_SECRET- NextAuth encryption secretBLOB_READ_WRITE_TOKEN- Vercel Blob access token
If gallery management or other database operations fail:
- Verify
DATABASE_URLenvironment variable is set correctly - Run
npx prisma generateto regenerate Prisma client - Check database connection with
node check-db.js - Ensure database migrations are up to date with
npm run db:migrate
Gallery upload issues are typically related to:
- Vercel Blob token not properly configured (get from https://vercel.com/dashboard/stores)
- Database user permissions (ensure createdBy/updatedBy fields have valid user IDs)
- Missing required fields in gallery item creation
- File size limits (Vercel Blob has size restrictions based on plan)
- Run
npx prisma generatebefore building if database schema changed - Ensure all environment variables are available in build environment
- Check TypeScript errors with proper type definitions
- Database Schema Changes: Update
prisma/schema.prisma, runnpx prisma generate, thennpm run db:migrate - New Features: Create components in appropriate directories, add API routes if needed, update types
- Media Updates: Use existing upload endpoints, store URLs in database via DatabaseService methods
- Content Management: All content operations go through the admin interface at
/admin
- Jest configuration in
jest.config.js - Test files in
src/tests/ - Database mocking configured for testing environment
- Run tests with
npm test
- GitHub Actions workflows configured for CI/CD
- Docker support available with multi-stage builds
- Prisma client generation happens automatically via postinstall script
- Environment variables must be configured in production environment
Required Environment Variables on Vercel:
DATABASE_URL- PostgreSQL connection stringNEXTAUTH_URL- Full production URL (e.g., https://colortech.co.zw)NEXTAUTH_SECRET- NextAuth encryption secretBLOB_READ_WRITE_TOKEN- Vercel Blob access tokenNODE_ENV=production
Next.js Configuration:
The next.config.ts file includes image optimization settings for Vercel Blob.
Ensure the hostname in remotePatterns matches your actual Vercel Blob subdomain.
Build Commands:
- Build:
npm run build - Start:
npm start