A clean, well-maintained ride-sharing platform built with Spring Boot and MongoDB that connects users who need rides with available drivers. This refactored version features improved code quality, comprehensive documentation, and type-safe ride status management.
- Create ride requests with pickup and drop locations
- View all your ride history
- Mark rides as completed
- View all pending ride requests
- Accept available rides
- Complete rides after drop-off
- JWT-based authentication
- Role-based access control (USER/DRIVER)
- Secure password encryption using BCrypt
- Backend: Spring Boot
- Database: MongoDB
- Security: Spring Security with JWT
- Build Tool: Maven/Gradle
This codebase has been refactored for improved quality:
- ✅ New Package Structure:
com.rideshare.app(cleaner, more generic) - ✅ Type-Safe Enums:
RideStatusenum replaces string-based status values - ✅ Comprehensive Documentation: JavaDoc comments on all classes and methods
- ✅ Cleaner Code: Extracted validation logic into private helper methods
- ✅ Better Naming: Clear, descriptive variable and method names
- ✅ Consistent Formatting: Professional code style throughout
- ✅ 100% Backward Compatible: All APIs remain unchanged
See REFACTORING_SUMMARY.md and REFACTORING_CHECKLIST.md for detailed changes.
POST /api/auth/register- Register new user/driverPOST /api/auth/login- Login and get JWT token
POST /api/v1/rides- Create a new ride requestGET /api/v1/user/rides- Get all your ridesPUT /api/v1/rides/{rideId}/complete- Complete a ride
GET /api/v1/driver/rides/requests- View pending ride requestsPUT /api/v1/driver/rides/{rideId}/accept- Accept a ride
- Java 17 or higher
- MongoDB installed and running
- Maven or Gradle
Create an application.properties file in src/main/resources/:
# MongoDB Configuration
spring.data.mongodb.uri=mongodb://localhost:27017/rideshare
spring.data.mongodb.database=rideshare
# JWT Configuration
jwt.secret=your-secret-key-here
jwt.expiration-ms=86400000# Using Maven
mvn spring-boot:run
# Using Gradle
gradle bootRunThe application will start on http://localhost:8080
curl -X POST http://localhost:8080/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"username": "john",
"password": "password123",
"role": "USER"
}'curl -X POST http://localhost:8080/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"username": "john",
"password": "password123"
}'curl -X POST http://localhost:8080/api/v1/rides \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{
"pickupLocation": "123 Main St",
"dropLocation": "456 Park Ave"
}'rideshare-app/
├── config/ # Security and JWT configuration
├── controller/ # REST API endpoints
├── dto/ # Data transfer objects
├── model/ # Entity models (includes RideStatus enum)
├── repository/ # MongoDB repositories
├── service/ # Business logic
└── util/ # Utility classes
The application uses a type-safe RideStatus enum with the following states:
- REQUESTED - User created a ride request, waiting for driver acceptance
- ACCEPTED - Driver has accepted the ride and is en route
- COMPLETED - Ride has been successfully completed
This refactored version includes:
- Comprehensive JavaDoc: Every class and public method is documented
- Private Helper Methods: Complex logic broken into focused methods
- Meaningful Names: Self-documenting code with clear variable names
- Consistent Formatting: Professional code style and indentation
- Better Exception Handling: Contextual error messages for debugging
- Type Safety: Enum-based status management instead of magic strings
For details, see REFACTORING_SUMMARY.md.
This project is open source and available for educational and commercial purposes.