A backend ride-sharing service modeled using Object-Oriented Design and implemented as a RESTful API using Java Spring Boot. This service enables efficient ride booking, driver matching, and fare calculation.
Built with real-world interview standards:
✅ SOLID principles · ✅ Design Patterns · ✅ Layered Architecture · ✅ Swagger UI
- 🔧 Register drivers and riders
- 🚕 Book rides with location-based matching
- ✅ Complete rides and calculate fares
- 📜 View ride history
- 🔔 Real-time notifications using Observer pattern
- 🧠 Strategy pattern for fare calculation
- 🧪 Live testing via Swagger UI
| Layer | Tool / Tech |
|---|---|
| Language | Java 17 |
| Framework | Spring Boot 3.x |
| Docs | Swagger (SpringDoc) |
| Build Tool | Maven |
| Testing | JUnit 5, Mockito |
| API Testing | Postman / Swagger UI |
src/main/java/com/jayanth/rideshare/
├── controller/ # REST APIs and endpoint handling
│ ├── RideController.java
│ └── dto/ # Data Transfer Objects
├── service/ # Business logic implementation
│ ├── DriverService.java
│ ├── RideService.java
│ └── impl/ # Service implementations
├── model/ # Domain entities
│ ├── Driver.java
│ ├── Rider.java
│ ├── Ride.java
│ └── Location.java
├── strategy/ # Strategy pattern for fare calculation
│ ├── FareStrategy.java
│ └── SimpleFareStrategy.java
├── observer/ # Observer pattern for notifications
│ ├── NotificationService.java
│ └── ConsoleNotificationService.java
├── exception/ # Custom exceptions and handlers
└── RideshareApplication.java # Main application class
- Java JDK 17 or higher
- Maven 3.6+
- Git
git clone https://github.com/jayanth-j-j/rideshare.git
cd ridesharemvn clean install
mvn spring-boot:runApp will start on:
📍 http://localhost:8080
The application uses the following default configuration in application.properties:
server.port=8080
spring.application.name=rideshareAccess all live APIs with docs and test buttons:
🔗 http://localhost:8080/swagger-ui/index.html
POST /api/ride/registerDriver
{
"name": "Arjun",
"currentLocation": {
"latitude": 12.9611,
"longitude": 77.6387
}
}POST /api/ride/book?dropLat=12.925&dropLng=77.5938
{
"name": "Ravi",
"currentLocation": {
"latitude": 12.9716,
"longitude": 77.5946
}
}POST /api/ride/complete?rideId=<ride-id>
GET /api/ride/history
- ✅ SOLID principles (Single Responsibility, Interface Segregation, etc.)
- 🧠 Strategy Pattern for fare logic
- 📣 Observer Pattern for driver notifications
- 🧱 Layered Architecture: Controller → Service → Model
- 🧼 Clean Code with testable design
The project includes comprehensive unit and integration tests:
# Run all tests
mvn test
# Run specific test class
mvn test -Dtest=RideServiceTestTest coverage reports can be generated with:
mvn jacoco:report- 📍 Location distance-based driver filtering
- 🧾 Integration with payment and rating systems
- 🗃️ JPA + H2/Postgres persistence
- 🛡️ JWT Authentication & Role-based Access
- 📦 Dockerize & Deploy
Jayanth Jayadevan
Software Engineer @ Microsoft
🔗 LinkedIn
MIT License – feel free to fork and expand this for your own portfolio or interviews!