A full-stack ride-hailing application built using the MERN stack. This project mimics a ride-sharing service similar to Uber and is divided into two main parts:
- Frontend: A React application powered by Vite and styled with Tailwind CSS. It handles user/captain interactions, live tracking (via Google Maps), and real-time notifications (via Socket.IO).
- Backend: An Express server using MongoDB (via Mongoose) for data persistence, Socket.IO for real-time communication, and REST APIs for user, captain, ride, and map functionalities.
- frontend/
- Contains the React application with pages (e.g., UserLogin, UserSignUp, Home, Riding, CaptainLogin, etc.), context providers (User, Captain, Socket.IO), components, and configuration files (vite.config.js, tailwind.config.js, etc.).
- Backend/
- Contains the Express server, models, controllers, services, and routes for handling users, captains, rides, maps, and authentication.
- README Files:
- This file documents the full project.
- The Backend folder also contains a README.md with detailed API endpoint documentation.
- Node.js (v14 or later)
- A MongoDB instance (local or cloud)
- A Google Maps API key
- Open a terminal and navigate to the
frontendfolder:cd frontend - Install dependencies:
npm install - Create a
.envfile insidefrontend/with the following keys:VITE_BASE_URL=http://localhost:4000 VITE_GOOGLE_MAPS_API=YOUR_GOOGLE_MAPS_API_KEY - Start the development server:
npm run dev
- Open a terminal and navigate to the
Backendfolder:cd Backend - Install dependencies:
npm install - Create a
.envfile insideBackend/with the following keys:DB_CONNECT=YOUR_MONGODB_CONNECTION_STRING JWT_SECRET=YOUR_SECRET_KEY GOOGLE_MAP_API=YOUR_GOOGLE_MAPS_API_KEY PORT=4000 - Start the server:
(Optionally, use nodemon for auto-reloading)
node server.js
Extensive API documentation is available in the Backend README (located at Backend/README.md). It covers:
- User registration, login, profile, and logout endpoints.
- Captain registration, login, profile, and logout endpoints.
- Ride creation, fare calculation, confirmation, start, and end endpoints.
- Map endpoints for coordinates, distance/time calculations, and auto-complete suggestions.
- User Authentication: Secure user and captain registration, login, and session management.
- Ride Management: Users can create ride requests and captains can accept, start, and finish rides with OTP confirmation.
- Real-time Communication: Uses Socket.IO to update ride statuses and notify nearby captains about new ride requests.
- Maps Integration: Google Maps API integration for live tracking, route calculations, and auto-complete suggestions.
- Responsive Design: The frontend is built with responsive layouts using Tailwind CSS.
VITE_BASE_URL=http://localhost:4000
VITE_GOOGLE_MAPS_API=YOUR_GOOGLE_MAPS_API_KEY
DB_CONNECT=YOUR_MONGODB_CONNECTION_STRING
JWT_SECRET=YOUR_SECRET_KEY
GOOGLE_MAP_API=YOUR_GOOGLE_MAPS_API_KEY
PORT=4000
- Currently, tests are not configured. Use tools like Postman to test the API endpoints.
- Both frontend and backend are designed to be easily deployed on cloud platforms. Adjust environment variables accordingly for production.
- Consult inline comments within the source code for more details.
- The Backend README further describes each API endpoint with example requests and responses.
- For troubleshooting, check server logs and ensure your environmental variables are correctly set.
This project is licensed under the MIT License.