A full-stack ride-sharing application built with the MERN stack, featuring real-time driver-passenger matching, live location tracking, and integrated payment processing.
uber.mp4
- π User Authentication - Secure signup/login with JWT
- π Location Search - Google Maps autocomplete for pickup and destination
- π° Fare Estimation - Real-time fare calculation for different vehicle types
- π Vehicle Selection - Choose from cars, bikes, or autos
- π³ Payment Integration - Razorpay payment gateway integration
- π Real-time Notifications - Live updates on ride status
- π― Ride Tracking - Track your driver in real-time
- π Driver Authentication - Separate authentication flow for drivers
- π± Driver Dashboard - View and manage ride requests
- π Ride Notifications - Instant notifications for nearby ride requests
- β Accept/Reject Rides - Full control over ride acceptance
- π Vehicle Management - Register and manage vehicle details
- π Ride History - Track completed rides
- β‘ Real-time Communication - Socket.io for instant updates
- πΊοΈ Google Maps Integration - Location services and distance calculation
- π State Management - React Context API
- πΎ Caching - Redis for session and location data
- π¨ Responsive Design - Mobile-first Tailwind CSS design
- π Secure Authentication - Bcrypt password hashing + JWT tokens
The application consists of three main services:
uber-clone/
βββ frontend/ # React + Vite frontend
βββ backend/ # Express.js + MongoDB backend
βββ web socket server/ # Socket.io real-time server
Frontend
- React 19
- Vite
- TailwindCSS
- Socket.io Client
- React Router DOM
- GSAP (animations)
- Axios
- React Razorpay
Backend
- Node.js + Express 5
- TypeScript
- MongoDB + Mongoose
- Redis
- JWT Authentication
- Bcrypt
- Google Maps API
- Razorpay API
WebSocket Server
- Socket.io
- Redis
- Express
- TypeScript
- Node.js (v18+)
- MongoDB
- Redis
- Google Maps API Key
- Razorpay API Keys
- Clone the repository
git clone https://github.com/yourusername/uber-clone.git
cd uber-clone- Backend Setup
cd backend
npm install
# Create .env file
cat > .env << EOL
PORT=3000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
JWT_EXPIRY=1d
GOOGLE_MAPS_API_KEY=your_google_maps_api_key
GOOGLE_MAPS_URL=https://maps.googleapis.com/maps/api
RAZORPAY_API_KEY=your_razorpay_key
RAZORPAY_SECRET_KEY=your_razorpay_secret
EOL
npm run dev- WebSocket Server Setup
cd "web socket server"
npm install
npm run dev- Frontend Setup
cd frontend
npm install
# Create .env file
cat > .env << EOL
VITE_RAZORPAY_API_KEY=your_razorpay_key
EOL
npm run devStart all services:
- MongoDB (default port: 27017)
- Redis (default port: 6379)
- Backend server (port: 3000)
- WebSocket server (port: 3001)
- Frontend (port: 5173)
backend/src/
βββ config/ # Configuration files (DB, Redis, Razorpay)
βββ controllers/ # Route controllers
βββ dtos/ # Data transfer objects
βββ middleware/ # Auth middleware
βββ models/ # Mongoose schemas
βββ repositories/ # Database operations
βββ routes/ # API routes
βββ services/ # Business logic
βββ utils/ # Helper functions
frontend/src/
βββ components/ # Reusable React components
βββ context/ # Context providers
βββ pages/ # Page components
βββ utils/ # Helper functions
web socket server/src/
βββ config/ # Socket.io configuration
βββ controllers/ # WebSocket event handlers
βββ routes/ # HTTP routes for notifications
βββ services/ # Redis operations
βββ utils/ # Helper utilities
- User requests ride β Backend creates booking
- Backend finds nearby drivers β Uses Redis geospatial queries
- WebSocket server notifies drivers β Socket.io emit to driver sockets
- Driver accepts ride β Backend updates booking status
- User notified β Socket.io emit to user socket
- Payment processed β Razorpay integration
- Ride completed β Status updated in MongoDB
- JWT tokens stored in localStorage
- Protected routes with auth middleware
- Separate auth flows for users and drivers
- Password hashing with bcrypt (10 rounds)
- Google Maps Geocoding API for address β coordinates
- Distance Matrix API for fare calculation
- Places Autocomplete API for search suggestions
- Redis GEOADD/GEORADIUS for driver proximity
PORT=3000
MONGO_URI=mongodb://localhost:27017/uber
JWT_SECRET=your_secret_key
JWT_EXPIRY=1d
GOOGLE_MAPS_API_KEY=your_google_maps_key
GOOGLE_MAPS_URL=https://maps.googleapis.com/maps/api
RAZORPAY_API_KEY=your_razorpay_key
RAZORPAY_SECRET_KEY=your_razorpay_secretVITE_RAZORPAY_API_KEY=your_razorpay_keyPOST /api/v1/user/signup- Register new userPOST /api/v1/user/signin- User loginGET /api/v1/user/me- Get user profilePOST /api/v1/user/create- Create new ride bookingGET /api/v1/user/:id- Get user by ID
POST /api/v1/driver/signup- Register new driverPOST /api/v1/driver/signin- Driver loginGET /api/v1/driver/me- Get driver profilePOST /api/v1/driver/location- Update driver locationPOST /api/v1/driver/confirm- Confirm ride acceptanceGET /api/v1/driver/details/:id- Get booking details
GET /api/v1/map/suggestions?input={query}- Get location suggestionsGET /api/v1/map/get-fare?pickup={}&destination={}- Calculate fare
POST /api/v1/payment/order- Create Razorpay order
- Live GPS tracking on map
- Ride history and receipts
- Driver ratings and reviews
- Multi-language support
- Push notifications
- Advanced analytics dashboard
- In-app chat between driver and passenger
- Scheduled rides
- Promo codes and referral system
- Driver earnings dashboard
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the ISC License.
Your Name
- GitHub: @yourusername
- Google Maps Platform for location services
- Razorpay for payment processing
- Socket.io for real-time communication
- MongoDB for database
- Redis for caching and geospatial queries
For any queries or suggestions, feel free to reach out!
Happy Coding! π