Skip to content

mdashad0/Car-Rental

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš— CarRental - Luxury Car Rental Platform:

A full-stack car rental web application built with React, Node.js, Express, and MongoDB. Users can browse, search, and book luxury cars, while car owners can list and manage their vehicles...

πŸ“Έ Screenshots of This Project:

Home Page:

Home Page

Available Cars:

Cars Page

Car Details & Booking:

Car Details

My Bookings

My Bookings

Owner Dashboard

Owner Dashboard

Add Car

Add Car

Manage Cars:

Manage Cars

✨ Features

For Customers

  • πŸ” Browse Cars - View all available luxury cars with detailed information
  • πŸ“… Search by Date & Location - Find cars available for specific dates and pickup locations
  • πŸš™ Car Details - View comprehensive car information including features, specifications, and pricing
  • πŸ“ Easy Booking - Simple booking process with date selection
  • πŸ“‹ My Bookings - Track all your car rentals and booking status

For Car Owners

  • πŸ“Š Dashboard - Overview of your car listings and bookings
  • βž• Add Cars - List your luxury cars for rent with images and details
  • πŸš— Manage Cars - Edit, toggle availability, or remove car listings
  • πŸ“‘ Manage Bookings - Approve, confirm, or cancel booking requests

General

  • πŸ” User Authentication - Secure login and registration system
  • 🎨 Responsive Design - Beautiful UI that works on all devices
  • ⚑ Smooth Animations - Enhanced UX with Framer Motion animations
  • πŸ”” Toast Notifications - Real-time feedback for user actions

πŸ› οΈ Tech Stack

Frontend

  • React 18 - UI library
  • React Router DOM - Client-side routing
  • Tailwind CSS - Utility-first styling
  • Framer Motion - Animations
  • Axios - HTTP client
  • React Hot Toast - Notifications
  • Vite - Build tool

Backend

  • Node.js - Runtime environment
  • Express.js - Web framework
  • MongoDB - Database
  • Mongoose - ODM
  • JWT - Authentication
  • ImageKit - Image storage and optimization
  • Multer - File uploads

πŸ“ Project Structure

Car Rental/
β”œβ”€β”€ client/                 # Frontend React application
β”‚   β”œβ”€β”€ public/            # Static assets
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ assets/        # Images and static data
β”‚   β”‚   β”œβ”€β”€ components/    # Reusable UI components
β”‚   β”‚   β”‚   └── owner/     # Owner-specific components
β”‚   β”‚   β”œβ”€β”€ context/       # React Context (AppContext)
β”‚   β”‚   └── pages/         # Page components
β”‚   β”‚       └── owner/     # Owner dashboard pages
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.js
β”‚
└── server/                 # Backend Node.js application
    β”œβ”€β”€ configs/           # Database and ImageKit config
    β”œβ”€β”€ controllers/       # Route handlers
    β”œβ”€β”€ middleware/        # Auth and file upload middleware
    β”œβ”€β”€ models/            # Mongoose schemas
    β”œβ”€β”€ routes/            # API routes
    β”œβ”€β”€ uploads/           # Temporary file uploads
    β”œβ”€β”€ package.json
    └── server.js          # Entry point

πŸš€ Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • MongoDB (local or Atlas)
  • ImageKit account (for image uploads)

Environment Variables

Client (client/.env)

VITE_BASE_URL=http://localhost:5000
VITE_CURRENCY=β‚Ή

Server (server/.env)

PORT=5000
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key

IMAGEKIT_PUBLIC_KEY=your_imagekit_public_key
IMAGEKIT_PRIVATE_KEY=your_imagekit_private_key
IMAGEKIT_URL_ENDPOINT=your_imagekit_url_endpoint

Installation

  1. Clone the repository

    git clone https://github.com/mdashad0/car-rental.git
    cd car-rental
  2. Install server dependencies

    cd server
    npm install
  3. Install client dependencies

    cd ../client
    npm install
  4. Set up environment variables

    • Create .env files in both client and server directories
    • Add the required environment variables as shown above
  5. Start the development servers

    In the server directory:

    npm run server

    In the client directory:

    npm run dev
  6. Open your browser

πŸ“‘ API Endpoints

User Routes (/api/user)

Method Endpoint Description
POST /register Register new user
POST /login User login
GET /data Get user data
GET /cars Get all available cars

Owner Routes (/api/owner)

Method Endpoint Description
POST /change-role Upgrade to owner role
POST /add-car Add new car listing
GET /cars Get owner's cars
POST /toggle-availability Toggle car availability
DELETE /delete-car Delete car listing
POST /update-image Update profile image

Booking Routes (/api/bookings)

Method Endpoint Description
POST /check-availability Check car availability
POST /create Create new booking
GET /user Get user's bookings
GET /owner Get owner's bookings
POST /change-status Update booking status

🎯 Key Features Explained

Authentication Flow

  • Users register/login with email and password
  • JWT tokens are stored in localStorage
  • Protected routes require valid tokens
  • Owners can upgrade their role to list cars

Booking System

  • Users select pickup and return dates
  • System checks car availability for the date range
  • Price is calculated based on daily rate Γ— number of days
  • Owners can confirm or cancel bookings

Image Management

  • Car images are uploaded via ImageKit
  • Optimized delivery with automatic transformations
  • Owner profile images supported

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘¨β€πŸ’» Author

MD ASHAD

πŸ™ Acknowledgments


⭐ Star this repository if you found it helpful!

About

A full-stack car rental web application built with React, Node.js, Express, and MongoDB. Users can browse, search, and book luxury cars, while car owners can list and manage their vehicles.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages