This project is a Java EE-based application designed to streamline and facilitate carpooling and ride-sharing services. The application enables passengers and drivers to connect, allowing drivers to post available rides and passengers to book them. This approach aims to make travel more economical, environmentally friendly, and efficient by encouraging shared rides.
- ✨Features
- 🛠️Technology Stack
- ⚙️Project Setup
- 🔧CI/CD Pipeline
- 🐳Docker Deployment
- 🌐API Endpoints
- 🧪Testing
- 🔍Usage
- 🤝Contributing
- License
- Contact
- User Registration and Authentication: Allows users to sign up, log in, and manage their profiles.
- Ride Posting and Management: Drivers can create, update, and manage ride offers, including details such as route, time, date, and available seats.
- Search and Filter: Passengers can search for available rides based on various filters (e.g., route, time).
- Booking and Notifications: Passengers can book seats in a ride, and both parties receive notifications for confirmations, cancellations, and updates.
- Ride History and Feedback: Users can view past rides, leave reviews, and provide feedback.
- Backend: Java EE, JPA, Hibernate, RESTful APIs
- Frontend: JSP, HTML, CSS, JavaScript
- Database: MySQL
- Frameworks: Spring (optional), Hibernate
- Build Tool: Maven
- Server: Apache Tomcat
- Testing: JUnit 4, Mockito, JaCoCo (Code Coverage)
- Code Quality: SonarQube, Checkstyle
- Security: OWASP Dependency Check
- CI/CD: Jenkins CI Pipeline
Ensure you have the following installed:
- Java Development Kit (JDK) 8+
- Apache Maven for dependency management
- Apache Tomcat server for deployment
- MySQL Database for data storage
- Clone the Repository
git clone https://github.com/yourusername/carpooling-app.git cd carpooling-app - Configure Database
Create a MySQL database.
Update the application.properties file with your database settings:
spring.datasource.url=jdbc:mysql://localhost:3306/carpooling_db
spring.datasource.username=your_db_username
spring.datasource.password=your_db_password- Build and Deploy Build the project using Maven:
mvn clean install-
Deploy and Run the Application
-
Deploy the generated
.warfile to your Apache Tomcat server. -
Start the Apache Tomcat server.
-
Access the application via http://localhost:8080/carpooling-app.
This project includes a Jenkins CI pipeline that automates:
- Checkout: Source code retrieval
- Build: Maven compilation
- Unit Tests: JUnit test execution with JaCoCo coverage
- Code Quality: SonarQube analysis and Checkstyle checks
- Security Scan: OWASP dependency check
- Package: WAR file creation
- Publish Artifacts: Prepare artifacts for separate CD pipeline
- Configure Jenkins with required plugins (see
jenkins-config.md) - Configure SonarQube server connection with ID
sonar_integration - Create pipeline job pointing to
Jenkinsfile
# Windows
build.bat
# Or manual steps
mvn clean test package- WAR File:
target/demo.war- Ready for deployment - Test Reports: JUnit and JaCoCo coverage reports
- Quality Reports: SonarQube and Checkstyle analysis
- Security Report: OWASP dependency check results
- Build Metadata: JSON file with build information for CD pipeline
| Endpoint | Method | Description |
|---|---|---|
/api/users/register |
POST | Register a new user |
/api/users/login |
POST | User login |
/api/rides |
GET | Retrieve available rides |
/api/rides |
POST | Create a new ride |
/api/rides/{id} |
GET | Retrieve ride details by ID |
/api/rides/{id}/book |
POST | Book a ride |
/api/rides/{id}/cancel |
POST | Cancel a booked ride |
# Run all tests
mvn test
# Run with coverage
mvn clean test jacoco:report
# View coverage report
open target/site/jacoco/index.html- Unit Tests:
src/test/java/models/- Model validation tests - Integration Tests: Database and service layer tests
- Coverage Reports: JaCoCo generates detailed coverage metrics
- Test Database: H2 in-memory database for testing
# Run Checkstyle
mvn checkstyle:check
# SonarQube analysis (requires SonarQube server)
mvn sonar:sonar -Dsonar.host.url=http://localhost:9000
# OWASP Dependency Check
mvn org.owasp:dependency-check-maven:check- User Registration: Register as a passenger or driver to access the platform.
- Create or Search for Rides:
- Drivers can create ride offers.
- Passengers can search for available rides by applying filters (e.g., location, time).
- Book a Ride: Select an available ride, submit a booking request, and await confirmation.
- Leave Feedback: After the ride is completed, provide feedback to help improve service quality.
Contributions are welcome! Follow these steps to contribute:
- Fork the repository.
- Create a new branch:
git checkout -b feature/YourFeature
1.users Table
CREATE TABLE users (
user_id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(100) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
phone_number VARCHAR(15),
role ENUM('driver', 'passenger', 'admin') DEFAULT 'passenger',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);2.rides Table
CREATE TABLE rides (
id INT AUTO_INCREMENT PRIMARY KEY,
driver_id INT NOT NULL,
date DATE NOT NULL,
depart VARCHAR(100) NOT NULL,
destination VARCHAR(100) NOT NULL,
fare DECIMAL(10, 2) NOT NULL,
number_of_places INT NOT NULL,
status ENUM('In Progress', 'Completed', 'Cancelled') DEFAULT 'In Progress',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (driver_id) REFERENCES users(user_id) ON DELETE CASCADE
);2.ride_requests Table
CREATE TABLE ride_requests (
request_id INT AUTO_INCREMENT PRIMARY KEY,
ride_id INT NOT NULL,
passenger_id INT NOT NULL,
status ENUM('Pending', 'Accepted', 'Rejected') DEFAULT 'Pending',
requested_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (ride_id) REFERENCES rides(id) ON DELETE CASCADE,
FOREIGN KEY (passenger_id) REFERENCES users(user_id) ON DELETE CASCADE
);