Skip to content

A full-stack MERN Car Rental App with user login, car browsing, bookings, and an admin dashboard. Images are handled via ImageKit, making it a clean, secure, and production-ready project.

Notifications You must be signed in to change notification settings

PratikDevelops/CarRental-fullstack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Car Rental Booking System (MERN Stack)

A fully functional, production‑ready Car Rental Booking Website built using the MERN Stack (MongoDB, Express.js, React.js, Node.js) with ImageKit integration for media storage.


πŸš€ Features

πŸ‘€ User Features

  • User Registration & Login (JWT‑based authentication)
  • Browse cars with filters
  • Select pickup location & date
  • View car details
  • Make a booking
  • View "My Bookings" page

πŸ› οΈ Admin Features

  • Secure Admin Login
  • Add new cars
  • Manage all bookings
  • Manage car inventory including images

πŸ–ΌοΈ Image Handling

  • Image upload handled via ImageKit
  • Auto optimization, fast delivery

🌐 Fully Deployed Application

  • Frontend deployed (e.g., on Vercel or Netlify)
  • Backend deployed (e.g., on Render or Railway)
  • Connected to MongoDB Atlas

πŸ—οΈ Tech Stack

Frontend

  • React.js
  • React Router
  • Axios
  • Context API
  • CSS / Tailwind (optional)

Backend

  • Node.js
  • Express.js
  • MongoDB & Mongoose
  • JWT Authentication
  • ImageKit SDK

Deployment

  • Frontend β†’ Vercel / Netlify
  • Backend β†’ Render / Railway / VPS
  • Database β†’ MongoDB Atlas
  • Media β†’ ImageKit

πŸ“ Folder Structure

car-rental-app/
β”‚
β”œβ”€β”€ client/             # React Frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ context/
β”‚   β”‚   β”œβ”€β”€ assets/
β”‚   β”‚   β”œβ”€β”€ App.js
β”‚   β”‚   β”œβ”€β”€ index.js
β”‚   └── package.json
β”‚
β”œβ”€β”€ server/             # Node Backend
β”‚   β”œβ”€β”€ controllers/
β”‚   β”œβ”€β”€ routes/
β”‚   β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ middleware/
β”‚   β”œβ”€β”€ .env
β”‚   β”œβ”€β”€ index.js
β”‚   └── package.json
β”‚
└── README.md

βš™οΈ Installation & Setup

πŸ”§ Prerequisites

Make sure you have:

  • Node.js installed
  • MongoDB Atlas account
  • ImageKit account

πŸ–₯️ Local Setup

1. Clone the Repository

https://github.com/pratikdevelops/car-rental-mern.git
cd car-rental-mern

2. Install Frontend Dependencies

cd client
npm install

3. Install Backend Dependencies

cd ../server
npm install

πŸ”‘ Environment Variables

Create a .env file in the server folder and add:

MONGO_URI=your_mongo_atlas_url
JWT_SECRET=your_jwt_secret
IMAGEKIT_PUBLIC_KEY=
IMAGEKIT_PRIVATE_KEY=
IMAGEKIT_URL_ENDPOINT=

▢️ Run the App

Start Backend

cd server
npm start

Start Frontend

cd client
npm run dev

Your project will be live at:


πŸ“¦ Build for Production

Frontend Build

cd client
npm run build

This generates a production-ready build inside /dist.


☁️ Deployment Steps

Frontend (Vercel / Netlify)

  1. Connect GitHub repo
  2. Select the client folder
  3. Build Command β†’ npm run build
  4. Output Directory β†’ dist

Backend (Render / Railway)

  1. Create new web service
  2. Use server folder
  3. Add environment variables
  4. Deploy

ImageKit Setup

  • Create a new ImageKit project
  • Copy API Keys to .env
  • Use .upload() method to upload car images

πŸ”— API Endpoints

Auth Routes

Method Endpoint Description
POST /api/auth/register Register user
POST /api/auth/login Login user

Car Routes

Method Endpoint Description
GET /api/cars List all cars
GET /api/cars/:id Get car details
POST /api/cars Add car (Admin)

Booking Routes

Method Endpoint Description
POST /api/bookings Create booking
GET /api/bookings/me Get user bookings


πŸ›‘οΈ Authentication Flow

  • User logs in β†’ Backend generates JWT
  • Frontend stores token in localStorage
  • Token added in every protected request header
  • Admin routes are protected using middleware

✨ Bonus Features You Can Add

  • Payment gateway (Razorpay / Stripe)
  • Advanced car filters (price, brand, fuel type)
  • Reviews & ratings
  • Coupon/discount system
  • Admin analytics dashboard
  • OTP login

πŸ“„ License

This project is open source and free to use.


πŸ’¬ Feedback & Support

Feel free to fork the project, raise issues, or suggest improvements!

About

A full-stack MERN Car Rental App with user login, car browsing, bookings, and an admin dashboard. Images are handled via ImageKit, making it a clean, secure, and production-ready project.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages