A modern, full-featured car rental platform built with Next.js, TypeScript, Prisma, and Tailwind CSS. This platform provides a complete solution for managing car rentals, bookings, users, and analytics.
- π Advanced Search & Filters: Full-text search with autocomplete, price range, MPG, year, and more
- π± Responsive Design: Beautiful, mobile-first UI built with Tailwind CSS and shadcn/ui
- β Favorites: Save your favorite cars for quick access
- π Reviews & Ratings: Rate and review cars you've rented
- π Booking System: Easy booking with date selection and availability checking
- π Detailed Car Pages: Comprehensive car details with image galleries and specifications
- ποΈ Admin Dashboard: Comprehensive management interface
- π Car Management: Full CRUD operations for car inventory
- π Booking Management: View and manage all bookings with status updates
- π₯ User Management: Manage users, roles, and permissions
- π Analytics & Reports: Revenue charts, booking trends, and export functionality
- π Review Moderation: Moderate user reviews and ratings
- β‘ Next.js 15: Latest App Router with Server Components
- ποΈ PostgreSQL: Robust database with Prisma ORM
- π Better Auth: Secure authentication and authorization
- π Comprehensive Documentation: Searchable docs with examples
- π¨ Modern UI: Built with shadcn/ui components
- π SEO Optimized: Meta tags, sitemap, and structured data
- Node.js 18+ installed
- PostgreSQL database
- npm or yarn package manager
-
Clone the repository
git clone <repository-url> cd car-rental
-
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env
Update
.envwith your configuration:DATABASE_URL="postgresql://user:password@localhost:5432/carrental" NEXT_PUBLIC_APP_URL="http://localhost:3000" NEXT_PUBLIC_BASE_URL="http://localhost:3000"
-
Set up the database
# Run migrations npx prisma migrate dev # Seed the database (optional) npx prisma db seed
-
Start the development server
npm run dev
-
Open your browser Navigate to http://localhost:3000
car-rental/
βββ app/ # Next.js App Router pages
β βββ api/ # API routes
β βββ dashboard/ # Admin dashboard
β βββ docs/ # Documentation pages
β βββ ...
βββ components/ # React components
β βββ cars/ # Car-related components
β βββ dashboard/ # Admin dashboard components
β βββ docs/ # Documentation components
β βββ ui/ # shadcn/ui components
βββ lib/ # Utility functions and configurations
βββ prisma/ # Prisma schema and migrations
βββ types/ # TypeScript type definitions
βββ public/ # Static assets
- Framework: Next.js 15 with App Router
- Styling: Tailwind CSS
- UI Components: shadcn/ui
- State Management: React hooks and URL state
- Forms: React Hook Form with Zod validation
- API: Next.js API Routes
- Database: PostgreSQL with Prisma ORM
- Authentication: Better Auth
- Validation: Zod schemas
- User: Authentication and user management
- Car: Car inventory with details
- Booking: Rental bookings with status tracking
- Favorite: User favorite cars
- Review: Car reviews and ratings
GET /api/cars
- Query parameters:
q,make,model,year,class,fuel_type,drive,transmission,min_price,max_price,min_year,max_year,min_mpg,max_mpg,available,sort_by,sort_order,limit,offset - Returns: List of cars with pagination
Example:
GET /api/cars?q=toyota&min_price=50&max_price=200&sort_by=price&sort_order=ascGET /api/bookings
- Returns: User's bookings
POST /api/bookings
- Body:
{ carId, startDate, endDate } - Creates a new booking
GET /api/favorites
- Returns: User's favorite cars
POST /api/favorites
- Body:
{ carId } - Adds a car to favorites
DELETE /api/favorites/[id]
- Removes a car from favorites
GET /api/reviews?carId=[id]
- Returns: Reviews for a specific car
POST /api/reviews
- Body:
{ carId, rating, comment } - Creates a new review
For complete API documentation, visit /docs/api.
Comprehensive documentation is available at /docs:
- API Documentation: Complete API reference
- Components: React component documentation
- Getting Started: Setup and installation guide
- Admin Guide: Administrator features
Use Cmd/Ctrl + K to search documentation.
npm run dev: Start development servernpm run build: Build for productionnpm run start: Start production servernpm run lint: Run ESLintnpm run db:seed: Seed the database
# Create a new migration
npx prisma migrate dev --name migration_name
# Reset database (WARNING: deletes all data)
npx prisma migrate reset
# Open Prisma Studio
npx prisma studio- Use TypeScript for all code
- Follow the existing code style
- Use functional components with hooks
- Prefer named exports
- Use descriptive variable and function names
To create an admin user:
- Sign up for a regular account
- Update the user role in the database:
UPDATE "user" SET role = 'admin' WHERE email = 'your-email@example.com';
- Log in and access
/dashboard
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Write clear commit messages
- Add tests for new features
- Update documentation as needed
- Follow the existing code style
- Ensure all checks pass
| Variable | Description | Required |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string | Yes |
NEXT_PUBLIC_APP_URL |
Application URL | Yes |
NEXT_PUBLIC_BASE_URL |
Base URL for API calls | Yes |
This project is licensed under the MIT License.
For support, please open an issue on GitHub or refer to the documentation.