A modern, full-stack MERN car rental platform that connects users with premium vehicle providers across Bangladesh. Built with React 19, featuring stunning animations and seamless user experience.
- Frontend: GARIWALA - Premium Car Rentals
- Email/Password registration with validation (uppercase, lowercase, 6+ characters)
- Google OAuth integration for quick sign-up
- Persistent login sessions (stays logged in on refresh)
- Protected private routes with automatic redirection
- Browse all available vehicles with real-time status
- Add new car listings with detailed information
- Update existing car details with inline editing
- Delete cars with confirmation dialogs
- View comprehensive car details before booking
- One-click booking with confirmation
- Real-time availability checking
- Prevents double-booking automatically
- View all personal bookings in one place
- Cancel bookings with status updates
- Search cars by name in real-time
- Filter by category (Sedan, SUV, Luxury, Electric, Hatchback)
- Filter by availability status
- Dynamic results with instant updates
- Framer Motion: Smooth page transitions and hover effects
- React Typewriter: Dynamic hero banner text animation
- React Tooltip: Informative hover cards with pricing details
- Lottie React: Success animations on booking confirmation
- SweetAlert2: Beautiful confirmation and alert dialogs
- Responsive design (mobile, tablet, desktop)
- Professional gradient color schemes
- Mobile-first design approach
- Optimized for all screen sizes
- Touch-friendly interactions
- Fast loading times
- React 19.1.1 - Latest React with improved performance
- React Router v7 - Client-side routing
- Vite 7.1.7 - Lightning-fast build tool
- Tailwind CSS v4 - Utility-first CSS framework
- DaisyUI 5.4.7 - Beautiful UI components
- Firebase Authentication - Secure user management
- Email/Password authentication
- Google OAuth provider
- Axios 1.13.2 - Promise-based HTTP client
- React Context API - Global state management
- Framer Motion - Professional animations
- React Simple Typewriter - Typing effects
- React Tooltip - Hover information cards
- Lottie React - JSON-based animations
- React Hot Toast - Toast notifications
- SweetAlert2 - Beautiful alert dialogs
- React Icons - Icon library
- Swiper - Touch slider carousel
gariwala-frontend/
├── public/
│ ├── _redirects # Netlify routing config
│ └── logo.png
├── src/
│ ├── assets/
│ │ └── logo.png
│ ├── components/
│ │ ├── Navbar.jsx # Navigation with auth dropdown
│ │ ├── Footer.jsx # Footer with links & social media
│ │ ├── CarCard.jsx # Reusable car card with animations
│ │ └── LoadingSpinner.jsx # Loading state component
│ │ └── ThemeToggle.jsx # Theme Toggle
│ ├── pages/
│ │ ├── Home.jsx # Landing page with hero & featured cars
│ │ ├── Login.jsx # Login with email/Google
│ │ ├── Register.jsx # Registration with validation
│ │ ├── BrowseCars.jsx # All cars with filters
│ │ ├── CarDetails.jsx # Detailed car view with booking
│ │ ├── AddCar.jsx # Add new car form
│ │ ├── MyListings.jsx # User's car listings (CRUD)
│ │ ├── MyBookings.jsx # User's booking history
│ │ └── ErrorPage.jsx # Custom 404 page
│ │ └── BookCar.jsx # Car Booking Page
│ │ └── ContactUs.jsx # Custom Contact Us Page
│ │ └── Dashboard.jsx # Custom Dashboard Page
│ ├── routes/
│ │ ├── router.jsx # Route configuration
│ │ └── PrivateRoute.jsx # Protected route wrapper
│ ├── context/
│ │ └── AuthContext.jsx # Authentication context
│ ├── firebase/
│ │ └── firebase.config.js # Firebase initialization
│ ├── App.jsx # Main app component
│ ├── main.jsx # Entry point
│ └── index.css # Global styles with custom gradients
├── .env # Environment variables (not in repo)
├── .gitignore
├── package.json
├── tailwind.config.js
├── vite.config.js
└── README.md
- Node.js (v18 or higher)
- npm or yarn
- Firebase account
- Git
git clone https://github.com/YOUR_USERNAME/gariwala-frontend.git
cd gariwala-frontendnpm installCreate a .env file in the root directory:
# Firebase Configuration
VITE_apiKey=your_firebase_api_key
VITE_authDomain=your_project.firebaseapp.com
VITE_projectId=your_project_id
VITE_storageBucket=your_project.appspot.com
VITE_messagingSenderId=123456789
VITE_appId=1:123456:web:abc123
# API Base URL
VITE_API_BASE_URL=https://gariwala-server.vercel.app.env file to Git!
npm run devVisit http://localhost:5173 in your browser.
npm run build- Go to Firebase Console
- Click "Add project"
- Enter project name: "gariwala"
- Disable Google Analytics (optional)
- Click "Create project"
- In Firebase Console, click "Authentication"
- Click "Get started"
- Enable Email/Password sign-in method
- Enable Google sign-in method
- Add your email as authorized domain
- Go to Project Settings (⚙️ icon)
- Scroll to "Your apps"
- Click web icon
</> - Register app: "gariwala-web"
- Copy
firebaseConfigvalues to.env
- Go to Authentication → Settings
- Scroll to "Authorized domains"
- Add:
localhost(for development)- Your Netlify domain (after deployment)
{
"dependencies": {
"react": "^19.1.1",
"react-dom": "^19.1.1",
"react-router-dom": "^7.9.5",
"firebase": "^12.5.0",
"axios": "^1.13.2",
"framer-motion": "^11.x.x",
"react-simple-typewriter": "^5.x.x",
"react-tooltip": "^5.x.x",
"lottie-react": "^2.x.x",
"sweetalert2": "^11.x.x",
"react-hot-toast": "^2.6.0",
"react-icons": "^5.5.0",
"swiper": "^12.0.3",
"tailwindcss": "^4.1.17",
"daisyui": "^5.4.7"
}
}- Run
npm run build - Go to Netlify
- Drag
distfolder to deploy zone
- Push code to GitHub
- Go to Netlify → "Add new site"
- Import from Git → Select repository
- Build settings:
- Build command:
npm run build - Publish directory:
dist
- Build command:
- Add environment variables:
- Go to Site settings → Environment variables
- Add all
VITE_*variables
- Click "Deploy site"
Create public/_redirects:
/* /index.html 200
This prevents 404 errors on page refresh.
Add your Netlify domain to Firebase authorized domains:
https://your-app.netlify.app
- ✅ Hero carousel with 3 slides
- ✅ Typewriter effect in hero text
- ✅ Search bar with real-time filtering
- ✅ 6 featured cars from database
- ✅ "Why Choose Us" section (4 benefits)
- ✅ Customer testimonials (3 reviews)
- ✅ Top-rated cars section
- ✅ All available cars display
- ✅ Search by car name
- ✅ Filter by category
- ✅ Status badges (Available/Booked)
- ✅ Animated card grid
- ✅ Hover tooltips with details
- ✅ Full car information
- ✅ Provider details
- ✅ Booking button with confirmation
- ✅ Lottie success animation
- ✅ Status checking
- ✅ Login requirement
- ✅ Complete car form
- ✅ Auto-filled provider info
- ✅ Category dropdown
- ✅ Form validation
- ✅ Image URL input
- ✅ Success notification
- ✅ User's car list
- ✅ Update functionality
- ✅ Delete with confirmation
- ✅ Status display
- ✅ Modal edit form
- ✅ User's booking history
- ✅ Car details display
- ✅ Booking date
- ✅ Cancel booking option
- ✅ Empty state
.btn-primary {
background: linear-gradient(135deg, #007bff 0%, #00c6ff 100%);
}- Page entrance: Fade + slide
- Card hover: Lift + scale
- Button tap: Scale down
- Typewriter: Dynamic text
- Tooltips: Hover information
- ✅ Environment variables for sensitive data
- ✅ Firebase authentication
- ✅ Private route protection
- ✅ Input validation
- ✅ XSS prevention
- ✅ Secure API calls
- ⚡ Lighthouse Score: 90+
- 📱 Mobile-first responsive
- 🎨 Optimized images from Unsplash
- 🚀 Fast page loads with Vite
- 💾 Efficient state management
- Firebase for authentication
- Unsplash for high-quality car images
- DaisyUI for beautiful components
- Framer Motion for smooth animations
- MongoDB Atlas for database hosting
RESTful API backend for GARIWALA car rental platform. Built with Node.js, Express.js & MongoDB Atlas, providing secure endpoints for car management, user bookings & real-time availability tracking.
- API Base: https://gariwala-server.vercel.app
- Frontend: https://gariwala.netlify.app
- Client Repo: GitHub - Frontend
- Server Repo: GitHub - Backend
- Get all cars with advanced filtering (search, category, sort)
- Get 6 featured/newest cars for homepage
- Get single car details by ID
- Get user-specific car listings by email
- Add new car with automatic status & rating
- Update car details (except provider info)
- Delete car with validation
- Create bookings with automatic car status update
- Prevent double bookings (checks availability)
- Get user bookings sorted by date
- Cancel bookings with car status rollback
- Store complete booking details (car info + user info)
- CORS enabled for frontend domains
- Environment variable protection
- MongoDB ObjectId validation
- Error handling on all routes
- Input sanitization
- Duplicate booking prevention
- MongoDB connection reuse (serverless optimization)
- Efficient database queries
- Fast response times (< 200ms)
- Proper indexing on collections
- Sorted results for optimal UX
| Technology | Version | Purpose |
|---|---|---|
| Node.js | 20.x | Runtime environment |
| Express.js | 5.1.0 | Web framework |
| MongoDB | 7.0.0 | NoSQL database |
| Mongoose | 8.19.3 | MongoDB ODM (optional) |
| CORS | 2.8.5 | Cross-origin requests |
| dotenv | 17.2.3 | Environment variables |
| bcryptjs | 3.0.3 | Password hashing (future auth) |
| jsonwebtoken | 9.0.2 | JWT tokens (future auth) |
| firebase-admin | 13.6.0 | Admin SDK (optional) |
| nodemon | 3.1.10 | Development auto-reload |
gariwala-server/
├── index.js # Main server file with all routes
├── vercel.json # Vercel serverless configuration
├── package.json # Dependencies and scripts
├── .env # Environment variables (not in repo)
├── .gitignore # Git ignore file
└── README.md # This file
- Node.js v18+ installed
- MongoDB Atlas account
- Git installed
- Text editor (VS Code recommended)
git clone https://github.com/Taoshif1/PH-A10-Server.git
cd PH-A10-Servernpm installCreate .env file in root directory:
# MongoDB Atlas Connection
DB_USER=your_mongodb_username
DB_PASS=your_mongodb_password
# Server Configuration
PORT=3000
# Optional: Future Authentication
JWT_SECRET=your_super_secret_jwt_key_here.env file to GitHub!
npm startServer will run on: http://localhost:3000
You should see:
🚀 GARIWALA Server running on port 3000
✅ MongoDB Connected Successfully!
- Go to MongoDB Atlas
- Sign in or create free account
- Click "Build a Database"
- Choose M0 Free tier
- Select region closest to you (Singapore for Bangladesh)
- Name cluster:
Cluster0 - Click "Create"
- Go to Database Access (left sidebar)
- Click "Add New Database User"
- Choose Password authentication
- Set username:
gariwala_admin - Click "Autogenerate Secure Password" (save it!)
- Database User Privileges: "Atlas admin"
- Click "Add User"
- Go to Network Access (left sidebar)
- Click "Add IP Address"
- Click "Allow Access from Anywhere"
- IP Address:
0.0.0.0/0(automatically filled) - Click "Confirm"
- Go to Database (left sidebar)
- Click "Connect" on your cluster
- Choose "Connect your application"
- Driver: Node.js, Version: 5.5 or later
- Copy connection string:
mongodb+srv://gariwala_admin:<password>@cluster0.xxxxx.mongodb.net/?retryWrites=true&w=majority
- Replace
<password>with your actual password - Add to
.env:
DB_USER=gariwala_admin
DB_PASS=your_actual_passwordDatabase Name: gariwalaDB
Collections:
cars- Car listingsbookings- User bookings
{
_id: ObjectId("69134b560448341e1c0a985d"),
name: "Tesla Model 3", // Car name
description: "Luxury electric sedan...", // Detailed description
category: "Electric", // Sedan|SUV|Luxury|Electric|Hatchback
price: 120, // Per day price (number)
location: "Dhaka", // City/location
image: "https://images.unsplash.com/...", // Car image URL
providerName: "Elite Motors", // Owner/provider name
providerEmail: "elite@example.com", // Provider email
status: "available", // available|booked
rating: 4.9, // 1-5 rating (auto: 4.5)
createdAt: ISODate("2025-01-10T00:00:00Z") // Auto-generated
}{
_id: ObjectId("691abc123..."),
carId: "69134b560448341e1c0a985d", // Reference to car
carName: "Tesla Model 3", // Stored for quick access
carImage: "https://...", // Car image
rentPrice: 120, // Stored price
userName: "John Doe", // User's name
userEmail: "john@example.com", // User's email
userPhoto: "https://...", // User's profile photo
status: "confirmed", // confirmed|cancelled
createdAt: ISODate("2025-01-13T10:30:00Z") // Booking timestamp
}GET /Response:
{
"message": "🚗 GARIWALA Server is Running!",
"status": "active",
"endpoints": {
"allCars": "GET /cars",
"featuredCars": "GET /cars/featured",
"singleCar": "GET /cars/:id",
"userCars": "GET /cars/user/:email",
"addCar": "POST /cars",
"updateCar": "PUT /cars/:id",
"deleteCar": "DELETE /cars/:id",
"userBookings": "GET /bookings/user/:email",
"createBooking": "POST /bookings",
"cancelBooking": "DELETE /bookings/:id"
}
}GET /carsQuery Parameters:
search- Search by car name (case-insensitive)category- Filter: Sedan, SUV, Luxury, Electric, Hatchback, allsort- Sort: price-low, price-high, rating
Examples:
GET /cars
GET /cars?search=tesla
GET /cars?category=Luxury
GET /cars?category=SUV&sort=price-lowGET /cars/featuredReturns 6 newest cars for homepage display.
Success Response (200):
{
"success": true,
"count": 6,
"cars": [...]
}GET /cars/:idParameters:
id- MongoDB ObjectId of the car
Example:
GET /cars/69134b560448341e1c0a985dSuccess Response (200):
{
"success": true,
"car": {
"_id": "69134b560448341e1c0a985d",
"name": "Tesla Model 3",
"description": "Luxury electric sedan...",
"category": "Electric",
"price": 120,
"location": "Dhaka",
"image": "https://...",
"providerName": "Elite Motors",
"providerEmail": "elite@example.com",
"status": "available",
"rating": 4.9,
"createdAt": "2025-01-10T00:00:00.000Z"
}
}Error Response (404):
{
"success": false,
"message": "Car not found"
}GET /cars/user/:emailReturns all cars listed by a specific provider.
Example:
GET /cars/user/elite@example.comSuccess Response (200):
{
"success": true,
"count": 3,
"cars": [...]
}POST /carsAuto-Added Fields:
status: "available"rating: 4.5createdAt: Current timestamp
PUT /cars/:idProtected Fields (cannot be updated):
providerEmailproviderNamecreatedAt_id
DELETE /cars/:idExample:
DELETE /cars/69134b560448341e1c0a985dGET /bookings/user/:emailExample:
GET /bookings/user/john@example.comPOST /bookingsAutomatic Actions:
- ✅ Validates car exists
- ✅ Checks car is available (not already booked)
- ✅ Creates booking record
- ✅ Updates car status to "booked"
- ✅ Stores car details in booking
Success Response (201):
{
"success": true,
"message": "Booking confirmed!",
"bookingId": "691abc123..."
}Error Response (400) - Already Booked:
DELETE /bookings/:idExample:
DELETE /bookings/691abc123...Automatic Actions:
- ✅ Finds booking
- ✅ Deletes booking record
- ✅ Updates car status back to "available"
- Import collection or create manually
- Set base URL:
https://gariwala-server.vercel.app - Test all endpoints
- Save responses
- Install Thunder Client extension
- Create new request
- Set URL and method
- Test API endpoints
{
"version": 2,
"builds": [
{
"src": "index.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "index.js",
"methods": ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"]
}
]
}npm install -g vercelvercel loginvercel --prod- Go to Vercel Dashboard
- Select project
- Settings → Environment Variables
- Add:
DB_USER= your MongoDB usernameDB_PASS= your MongoDB passwordPORT= 3000
vercel --prodYour API is now live! 🎉
The server allows requests from:
origin: [
"http://localhost:5173", // Local development
"https://gariwala.netlify.app" // Production frontend
]To add more origins:
app.use(cors({
origin: [
"http://localhost:5173",
"https://gariwala.netlify.app",
"https://your-new-domain.com" // Add new domain here
],
credentials: true
}));Solution:
- Check
.envcredentials are correct - Verify IP whitelist:
0.0.0.0/0in MongoDB Atlas - Check MongoDB user has proper permissions
- Ensure connection string format is correct
Solution:
Add your frontend URL to CORS origins in index.js:
origin: ["http://localhost:5173", "https://your-app.netlify.app"]Solutions:
- Ensure
vercel.jsonexists - Check
index.jsis the entry point - Verify all dependencies in
package.json - Check build logs for specific errors
Check:
- MongoDB connection is active
- Environment variables are set in Vercel
- Check Vercel function logs
- Verify request body format
All errors return consistent structure:
{
"success": false,
"message": "Human-readable error message",
"error": "Technical error details (optional)"
}| Code | Meaning |
|---|---|
| 200 | Success |
| 201 | Created |
| 400 | Bad Request (invalid data) |
| 404 | Not Found |
| 500 | Internal Server Error |
{
"express": "^5.1.0", // Web framework
"mongodb": "^7.0.0", // Database driver
"mongoose": "^8.19.3", // ODM (optional)
"cors": "^2.8.5", // Cross-origin requests
"dotenv": "^17.2.3", // Environment variables
"bcryptjs": "^3.0.3", // Password hashing (future)
"jsonwebtoken": "^9.0.2", // JWT auth (future)
"firebase-admin": "^13.6.0", // Admin SDK (optional)
"nodemon": "^3.1.10" // Dev auto-reload
}- ✅ MongoDB connection reuse (serverless)
- ✅ Efficient database queries
- ✅ Proper indexing on
_idandemail - ✅ Response time: < 200ms average
- ✅ Sorted results for better UX
- ✅ Limited featured cars query
- Environment variables for secrets
- CORS restriction to specific domains
- MongoDB ObjectId validation
- Input sanitization
- Error handling on all routes
- Duplicate booking prevention
- JWT authentication for API routes
- User roles (admin, provider, customer)
- Car image upload to cloud storage
- Payment integration (Stripe/PayPal/BKash/Nagad)
- Booking date range selection
- Reviews and ratings system
- Real-time notifications
- Advanced analytics dashboard
# Start development server with nodemon
npm start
# Run tests (not implemented yet)
npm test
# Manual start (no auto-reload)
node index.js- MongoDB Atlas for free database hosting
- Vercel for serverless deployment
- Express.js community
- Node.js ecosystem
- Total Endpoints: 10
- Collections: 2 (cars, bookings)
- Response Time: < 200ms
- Uptime: 99.9%
- Database: MongoDB Atlas (M0 Free)
Made with ❤️ in Bangladesh 🇧🇩
Live API: GARIWALA SERVER