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.
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
git clone https://github.com/YOUR_USERNAME/gariwala-frontend.git
cd gariwala-frontend
npm install
Create 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
β οΈ Important: Never commit .env file to Git!
npm run dev
Visit http://localhost:5173 in your browser.
npm run build
</>firebaseConfig values to .envlocalhost (for development){
"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"
}
}
npm run builddist folder to deploy zonenpm run builddistVITE_* variablesCreate 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
.btn-primary {
background: linear-gradient(135deg, #007bff 0%, #00c6ff 100%);
}
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.
| 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
git clone https://github.com/Taoshif1/PH-A10-Server.git
cd PH-A10-Server
npm install
Create .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
β οΈ NEVER commit .env file to GitHub!
npm start
Server will run on: http://localhost:3000
You should see:
π GARIWALA Server running on port 3000
β
MongoDB Connected Successfully!
Cluster0gariwala_admin0.0.0.0/0 (automatically filled)β οΈ Note: For production, whitelist specific IPs only.
mongodb+srv://gariwala_admin:<password>@cluster0.xxxxx.mongodb.net/?retryWrites=true&w=majority
<password> with your actual password.env:
DB_USER=gariwala_admin
DB_PASS=your_actual_password
Database 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 /cars
Query Parameters:
search - Search by car name (case-insensitive)category - Filter: Sedan, SUV, Luxury, Electric, Hatchback, allsort - Sort: price-low, price-high, ratingExamples:
GET /cars
GET /cars?search=tesla
GET /cars?category=Luxury
GET /cars?category=SUV&sort=price-low
GET /cars/featured
Returns 6 newest cars for homepage display.
Success Response (200):
{
"success": true,
"count": 6,
"cars": [...]
}
GET /cars/:id
Parameters:
id - MongoDB ObjectId of the carExample:
GET /cars/69134b560448341e1c0a985d
Success 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/:email
Returns all cars listed by a specific provider.
Example:
GET /cars/user/elite@example.com
Success Response (200):
{
"success": true,
"count": 3,
"cars": [...]
}
POST /cars
Auto-Added Fields:
status: βavailableβrating: 4.5createdAt: Current timestampPUT /cars/:id
Protected Fields (cannot be updated):
providerEmailproviderNamecreatedAt_idDELETE /cars/:id
Example:
DELETE /cars/69134b560448341e1c0a985d
GET /bookings/user/:email
Example:
GET /bookings/user/john@example.com
POST /bookings
Automatic Actions:
Success Response (201):
{
"success": true,
"message": "Booking confirmed!",
"bookingId": "691abc123..."
}
Error Response (400) - Already Booked:
DELETE /bookings/:id
Example:
DELETE /bookings/691abc123...
Automatic Actions:
https://gariwala-server.vercel.appvercel.json{
"version": 2,
"builds": [
{
"src": "index.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "index.js",
"methods": ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"]
}
]
}
npm install -g vercel
vercel login
vercel --prod
DB_USER = your MongoDB usernameDB_PASS = your MongoDB passwordPORT = 3000vercel --prod
Your 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:
.env credentials are correct0.0.0.0/0 in MongoDB AtlasSolution:
Add your frontend URL to CORS origins in index.js:
origin: ["http://localhost:5173", "https://your-app.netlify.app"]
Solutions:
vercel.json existsindex.js is the entry pointpackage.jsonCheck:
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
}
_id and email# Start development server with nodemon
npm start
# Run tests (not implemented yet)
npm test
# Manual start (no auto-reload)
node index.js
Made with β€οΈ in Bangladesh π§π©
Live API: GARIWALA SERVER