A modern, full-stack car dealership management system built with Next.js 15, featuring advanced inventory management, customer reservations, and comprehensive admin tools.
Production: https://car-dealer-lake-eight.vercel.app/
Modern landing page with featured vehicles and search functionality
Comprehensive admin panel for inventory and customer management
AI detech specs of the whip by just upload 1 picture
- Hierarchical Car Taxonomy: Make β Model β Model Variant structure for precise categorization
- Real-time Search & Filtering: Filter by make, model, price, year, mileage, fuel type, transmission, body type, and more
- Dynamic Vehicle Listings: Live status updates (LIVE, DRAFT, SOLD)
- URL-based State Management: Shareable filter links with
nuqsintegration - View Counter: Track vehicle popularity with automated view counting
- Slug-based URLs: SEO-friendly URLs auto-generated from vehicle details
- AWS S3 Integration: Scalable cloud storage with presigned URLs
- Drag & Drop Upload: Intuitive multi-image uploader using
@dnd-kit - Image Sorting: Reorder images with drag-and-drop interface
- Thumbhash Placeholders: Ultra-fast loading with blur-up effect
- Main Image Selection: Designate primary vehicle photo
- Automatic Optimization: Next.js Image component with lazy loading
- Multi-Step Form: Welcome β Date Selection β Customer Details
- Calendar Integration: Interactive date picker with
date-fns - Lead Tracking: Capture customer interest with status lifecycle
- Email Notifications: Automated alerts via Resend
- Terms & Conditions: Built-in acceptance workflow
- Booking Confirmation: Success page with reservation details
- Lead Status Pipeline: SUBSCRIBER β INTERESTED β CONTACTED β PURCHASED β COLD
- Lifecycle Tracking: Full history of status changes with timestamps
- Customer Profiles: Detailed contact information and booking preferences
- Vehicle Association: Link customers to specific vehicle interests
- Search & Filter: Find customers by name, email, status, or vehicle
- Bulk Actions: Efficient customer management workflows
- NextAuth v5: Latest authentication library with database sessions
- Custom 2FA Implementation: OTP-based two-factor authentication
- Challenge System: Secure OTP generation and validation with
@/lib/otp - Session Management: 30-day sessions with automatic expiration
- Credential Provider: Email/password authentication with bcrypt hashing
- Protected Routes: Middleware-based route protection for admin area
- Automatic Redirects: Smart routing based on authentication state
- Rate Limiting: Upstash Redis-based request throttling (5 login attempts per 10 minutes)
- CSRF Protection: Built-in NextAuth CSRF tokens
- Content Security Policy: Strict CSP headers via middleware
- SQL Injection Prevention: Prisma ORM parameterized queries
- Input Sanitization: HTML sanitization for user-generated content
- Environment Variable Validation: Type-safe env vars with
@t3-oss/env-nextjs - Secure Headers: Custom security headers via Next.js middleware
- AI Description Generator: Automatically generate compelling vehicle descriptions
- Streamable Responses: Real-time AI output streaming
- Content Enhancement: Improve existing descriptions with AI suggestions
- Custom Prompts: Tailored prompts for automotive content
- Token Management: Efficient API usage with streaming
- PostgreSQL: Production-ready relational database
- Prisma ORM: Type-safe database client with migrations
- Connection Pooling: Neon database with optimized pooling
- Soft Deletes: Cascade deletes for related entities
- Indexes: Optimized queries with strategic indexing
- Migrations: Version-controlled schema changes
- Seeding: CSV-based hierarchical data seeding from
taxonomy.csv
- AWS S3: Scalable object storage for vehicle images
- Presigned URLs: Secure, temporary upload links
- Imgix CDN: Optional image transformation and delivery
- Multi-region Support: Configurable AWS regions
- MIME Type Validation: Secure file type checking
- Size Limits: Configurable upload constraints
- Resend Email API: Transactional email service
- React Email Templates: Beautifully designed email components
- OTP Delivery: Secure code delivery for 2FA
- Booking Confirmations: Automated reservation emails
- Admin Notifications: Alert system for new leads
- Full-text Search: Search across vehicle titles and descriptions
- Multi-criteria Filtering: Combine multiple filters simultaneously
- Sorting Options: Sort by price, year, views, date added
- Pagination: Server-side pagination with configurable page sizes
- Page View Tracking: Analytics on vehicle popularity
- URL State Persistence: Shareable search results
- Framework: Next.js 15 (App Router with Turbopack)
- Language: TypeScript 5
- Styling: Tailwind CSS 4.0
- UI Components: Radix UI primitives
- Forms: React Hook Form 7 + Zod validation
- State Management:
- URL state with
nuqs - Form state with React Hook Form
- No global state library (React Context only)
- URL state with
- Animation: Framer Motion
- Icons: Lucide React + React Simple Icons
- Rich Text: TinyMCE Editor
- Drag & Drop: @dnd-kit
- Image Gallery: Swiper + fslightbox-react
- Date Handling: date-fns
- Runtime: Node.js (Edge & Node.js runtimes)
- Database: PostgreSQL (Neon)
- ORM: Prisma 6 with extensions
@prisma/extension-acceleratefor query caching- Connection pooling optimized for serverless
- Authentication: NextAuth v5 (Auth.js)
- Database sessions
- Custom JWT encoding
- Credentials provider with bcrypt
- File Storage: AWS S3
@aws-sdk/client-s3v3- Presigned URLs for secure uploads
- Email: Resend API
- React Email for templates
- Transactional emails
- Rate Limiting: Upstash Redis
@upstash/ratelimitwith sliding window- API protection
- AI: OpenAI SDK with streaming
- Package Manager: npm
- TypeScript: Strict mode enabled
- Linting: ESLint with Next.js config
- Code Formatting: Prettier
- Database Tools:
- Prisma Studio (GUI)
- Prisma Migrate (migrations)
- ts-node for seeding
- Build Tool: Turbopack (Next.js dev server)
- Deployment: Vercel
{
"@ai-sdk/openai": "^1.1.13",
"@auth/prisma-adapter": "^2.7.4",
"@dnd-kit/core": "^6.3.1",
"@hookform/resolvers": "^3.10.0",
"@prisma/client": "^6.3.1",
"@radix-ui/react-*": "Latest",
"@upstash/ratelimit": "^2.0.5",
"next": "^15.4.0-canary.83",
"next-auth": "^5.0.0-beta.25",
"nuqs": "^2.3.1",
"react": "^19.0.0",
"tailwindcss": "^4.0.0",
"zod": "^3.25.56"
}Before running this project, ensure you have:
- Node.js 18.17 or later
- npm or yarn package manager
- PostgreSQL database (we recommend Neon for serverless Postgres)
- AWS Account with S3 bucket configured
- Resend Account for transactional emails
- Upstash Account for Redis rate limiting
- TinyMCE API Key (free tier available)
- OpenAI API Key (optional, for AI features)
git clone https://github.com/your-username/car-dealer.git
cd car-dealernpm installCreate a .env.local file in the root directory:
# Database (Neon PostgreSQL with connection pooling)
DATABASE_URL="postgresql://username:password@host.region.aws.neon.tech/dbname?sslmode=require"
# NextAuth Configuration
NEXTAUTH_SECRET="your-super-secret-key-here" # Generate with: openssl rand -base64 32
NEXTAUTH_URL="http://localhost:3000" # Change to your production URL in Vercel
# AWS S3 Configuration
AWS_S3_BUCKET_ACCESS_KEY="your-aws-access-key"
AWS_S3_BUCKET_SECRET_KEY="your-aws-secret-key"
NEXT_PUBLIC_S3_BUCKET_REGION="us-east-1"
NEXT_PUBLIC_S3_BUCKET_NAME="your-bucket-name"
NEXT_PUBLIC_S3_BUCKET_URL="https://your-bucket-name.s3.region.amazonaws.com"
# Email Service (Resend)
RESEND_API_KEY="re_your-resend-api-key"
SENDER_EMAIL="onboarding@resend.dev" # Or your verified domain
# TinyMCE Rich Text Editor
NEXT_PUBLIC_TINYMCE_API_KEY="your-tinymce-api-key"
# Redis Rate Limiting (Upstash)
UPSTASH_REDIS_REST_URL="https://your-redis-instance.upstash.io"
UPSTASH_REDIS_REST_TOKEN="your-upstash-token"
# AI Integration (Optional - for description generation)
OPENAI_API_KEY="sk-proj-your-openai-api-key"
# App Configuration
NEXT_PUBLIC_APP_URL="http://localhost:3000" # Your app URL
X_AUTH_TOKEN="secret" # Custom auth token for API protection
# Optional: Imgix CDN (if using Imgix for image optimization)
NEXT_PUBLIC_IMGIX_URL="https://your-source.imgix.net"Important for Production (Vercel):
- Set
NEXTAUTH_URLto your production domain (e.g.,https://your-app.vercel.app) - Set
NEXT_PUBLIC_APP_URLto your production domain - Use a strong
NEXTAUTH_SECRET(generate withopenssl rand -base64 32) - Ensure Upstash Redis database is active (free tier databases delete after 14 days of inactivity)
# Generate Prisma client
npx prisma generate
# Run database migrations (creates all tables)
npx prisma migrate dev
# Seed the database with sample data
# This will create:
# - Admin user (admin@example.com / admin123)
# - Car makes, models, and variants from taxonomy.csv
# - Sample vehicle listings
# - Sample customers
npx prisma db seedDatabase Schema Overview:
users&sessions- Authentication tablesclassifieds- Vehicle listingsmakes,models,model_variants- Hierarchical car taxonomyimages- Vehicle images with thumbhash datacustomers&customer_lifecycle- Lead managementpage_views- Analytics tracking
npm run devOpen http://localhost:3000 to view the application.
The application uses a comprehensive database schema with the following main entities:
car-dealer/
βββ prisma/ # Database schema and migrations
β βββ schema.prisma # Main Prisma schema with all models
β βββ migrations/ # Version-controlled schema changes
β βββ seed/ # Database seeding scripts
β βββ seed.ts # Main seed orchestrator
β βββ tax.seed.ts # Make/Model/Variant seeding from CSV
β βββ admin.seed.ts # Admin user creation
β βββ class.seed.ts # Sample vehicle listings
β βββ customer.seed.ts # Sample customer data
β βββ imageSeed.ts # Sample images with thumbhash
βββ src/
β βββ app/ # Next.js App Router
β β βββ (presentation)/ # Public-facing pages (route group)
β β β βββ page.tsx # Homepage
β β β βββ auth/ # Sign-in, challenge pages
β β β βββ inventory/ # Vehicle browsing & details
β β β βββ favourites/ # User favourites
β β βββ admin/ # Admin dashboard (protected)
β β β βββ dashboard/ # Analytics & overview
β β β βββ cars/ # Inventory management
β β β βββ customers/ # Lead management
β β β βββ settings/ # Admin settings
β β βββ api/ # API routes
β β β βββ auth/ # NextAuth endpoints
β β β βββ images/ # S3 upload handlers
β β β βββ taxonomy/ # Make/model data endpoints
β β β βββ favourites/ # Favourites management
β β βββ _actions/ # Server Actions (mutations)
β β β βββ car.ts # Vehicle CRUD operations
β β β βββ customer.ts # Customer management
β β β βββ challenge.ts # OTP verification
β β β βββ sign-in.ts # Authentication
β β β βββ subscribe.ts # Newsletter subscription
β β β βββ ai.tsx # AI description generation
β β βββ schemas/ # Zod validation schemas
β β βββ car.schema.ts # Vehicle validation
β β βββ customer.schema.ts # Customer validation
β β βββ auth.schema.ts # Auth validation
β β βββ ... # Other schemas
β βββ components/ # React components
β β βββ ui/ # Base Radix UI components
β β βββ admin/ # Admin-specific components
β β βββ car/ # Vehicle-related components
β β β βββ car-form.tsx # Vehicle edit form
β β β βββ car-form-fields.tsx # Form field components
β β β βββ car-carousel.tsx # Image carousel
β β β βββ drag-and-drop.tsx # Image uploader
β β β βββ rich-text-editor.tsx # TinyMCE wrapper
β β β βββ TaxonomySelect.tsx # Make/model dropdowns
β β βββ auth/ # Authentication components
β β βββ shared/ # Reusable components
β β βββ homepage/ # Landing page sections
β β βββ inventory/ # Inventory browsing UI
β β βββ reserve/ # Reservation flow
β βββ lib/ # Utility functions and clients
β β βββ prisma.ts # Prisma client singleton
β β βββ s3.ts # AWS S3 client & upload functions
β β βββ resend.ts # Email client configuration
β β βββ otp.ts # OTP generation & validation
β β βββ rate-limiter.ts # Upstash Redis rate limiting
β β βββ thumbhash-server.ts # Server-side thumbhash generation
β β βββ thumbhash-client.tsx # Client-side thumbhash rendering
β β βββ uploader.ts # File upload utilities
β β βββ utils.ts # General utilities (cn, formatters)
β β βββ ai-utils.ts # OpenAI integration helpers
β βββ config/ # Configuration files
β β βββ routes.ts # Centralized route definitions
β β βββ types.ts # Shared TypeScript types
β β βββ constants.ts # App-wide constants
β β βββ endpoints.ts # API endpoint definitions
β βββ middleware.ts # Route protection & security headers
βββ emails/ # React Email templates
β βββ challenge.tsx # OTP email template
βββ public/ # Static assets
βββ auth.config.ts # NextAuth configuration
βββ auth.ts # Auth.js wrapper
βββ next.config.ts # Next.js configuration
βββ tailwind.config.ts # Tailwind CSS configuration
βββ tsconfig.json # TypeScript configuration
βββ taxonomy.csv # Car make/model seed data
βββ .env.local # Environment variables (gitignored)
# Development
npm run dev # Start development server with Turbopack (fast HMR)
npm run build # Build for production (optimized)
npm run start # Start production server
npm run lint # Run ESLint for code quality
# Database Operations
npx prisma studio # Open Prisma Studio (visual database browser)
npx prisma generate # Regenerate Prisma Client after schema changes
npx prisma migrate dev # Create and apply new migration
npx prisma migrate deploy # Apply migrations in production
npx prisma db push # Push schema changes without creating migration (dev only)
npx prisma db seed # Seed database with initial data
npx prisma migrate reset # Reset database and re-run all migrations + seed
# Useful Development Commands
npx prisma format # Format schema.prisma file
npx prisma validate # Validate Prisma schema
npx prisma db pull # Pull schema from existing database (introspection)
# Deployment
npm run build && npm run start # Build and start production server locally
vercel # Deploy to Vercel (install: npm i -g vercel)Adding a new feature:
npm run dev # Start dev server
# Make changes...
npx prisma migrate dev # If schema changed
npm run build # Test production build
git add . && git commit # Commit changes
git push # Auto-deploy to VercelDatabase schema changes:
# Edit prisma/schema.prisma
npx prisma migrate dev --name add_new_field
npx prisma generate
# Update TypeScript types in config/types.ts if neededThe application provides comprehensive API endpoints:
POST /api/auth/signin- Sign in with credentialsPOST /api/auth/signout- Sign out and destroy sessionPOST /api/auth/session- Get current sessionGET /api/auth/csrf- Get CSRF token
GET /api/cars- List vehicles with filteringGET /api/cars/[id]- Get single vehicle detailsPOST /api/cars- Create new vehicle (admin)PUT /api/cars/[id]- Update vehicle (admin)DELETE /api/cars/[id]- Delete vehicle (admin)
POST /api/images/upload- Upload image to S3POST /api/images/presigned-url- Get presigned S3 URLDELETE /api/images/[key]- Delete image from S3
GET /api/taxonomy/makes- Get all car makesGET /api/taxonomy/models?makeId=[id]- Get models for makeGET /api/taxonomy/variants?modelId=[id]- Get variants for model
GET /api/favourites- Get user's favourites (cookie-based)POST /api/favourites- Add to favouritesDELETE /api/favourites/[id]- Remove from favourites
Located in src/app/_actions/:
createCarAction- Create new vehicle listingupdateCarAction- Update existing vehicledeleteCarAction- Delete vehiclesignInAction- Authenticate user with rate limitingchallengeAction- Verify OTP codecreateCustomerAction- Create new customer leadupdateCustomerStatusAction- Update lead statusgenerateDescriptionAction- AI-powered description generation
Contributions are welcome! Please follow these guidelines:
-
Fork the Repository
git clone https://github.com/vvduth/car-dealer.git cd car-dealer -
Create a Feature Branch
git checkout -b feature/your-feature-name
-
Make Your Changes
- Follow existing code patterns
- Use TypeScript for type safety
- Update Prisma schema if needed
- Add Zod schemas for new forms
- Follow component structure conventions
-
Test Your Changes
npm run dev # Test locally npm run build # Ensure production build works npm run lint # Check for linting errors
-
Commit Your Changes
git add . git commit -m "feat: add new feature"
Commit Message Conventions:
feat:New featurefix:Bug fixdocs:Documentation changesstyle:Code style changes (formatting)refactor:Code refactoringtest:Test additions/changeschore:Build process or tooling changes
-
Push to Your Fork
git push origin feature/your-feature-name
-
Submit a Pull Request
- Describe your changes clearly
- Reference any related issues
- Include screenshots for UI changes
- TypeScript: Use strict type checking
- Components: Functional components with TypeScript
- Server Actions: Always use
"use server"directive - Client Components: Mark with
"use client"when needed - Styling: Use Tailwind CSS utility classes
- Imports: Use
@/alias for cleaner imports - Error Handling: Return
{ success: boolean, message: string } - Validation: Zod schemas for all user inputs
- π Bug fixes and improvements
- β¨ New features (vehicle comparisons, saved searches, etc.)
- π Documentation improvements
- π¨ UI/UX enhancements
- βΏ Accessibility improvements
- π Internationalization (i18n)
- π§ͺ Test coverage
- β‘ Performance optimizations
This project is licensed under the MIT License. See the LICENSE file for details.
This project is licensed under the MIT License. See the LICENSE file for details.
This project was built with amazing open-source technologies:
- Next.js - The React framework for production by Vercel
- Vercel - Deployment and hosting platform with edge network
- Prisma - Next-generation ORM for type-safe database access
- NextAuth.js - Complete authentication solution for Next.js
- Radix UI - Unstyled, accessible component primitives
- Tailwind CSS - Utility-first CSS framework
- shadcn/ui - Re-usable components built with Radix and Tailwind
- Upstash - Serverless Redis for rate limiting and caching
- Neon - Serverless PostgreSQL with branching
- AWS S3 - Scalable object storage
- Resend - Modern email API for developers
- OpenAI - AI models for content generation
- TinyMCE - Rich text editor
Special thanks to the open-source community for making these tools freely available.
Built with β€οΈ by vvduth using Next.js 15 and modern web technologies
Live Demo: https://car-dealer-lake-eight.vercel.app/
