Skip to content

Application for managing carpooling or ride-sharing services. Projet JEE

Notifications You must be signed in to change notification settings

YASSIRAMRAOUI/Management-Carpooling-Services

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚗Application for Managing Carpooling or Ride-Sharing Services

📖Project Overview

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.

📋Table of Contents

✨Features

  • 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.

🛠️Technology Stack

  • 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

⚙️Project Setup

📋Prerequisites

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

🚀1- Installation Steps

  1. Clone the Repository
    git clone https://github.com/yourusername/carpooling-app.git
    cd carpooling-app
  2. 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
  1. Build and Deploy Build the project using Maven:
mvn clean install
  1. Deploy and Run the Application

  2. Deploy the generated .war file to your Apache Tomcat server.

  3. Start the Apache Tomcat server.

  4. Access the application via http://localhost:8080/carpooling-app.

🔧CI Pipeline

This project includes a Jenkins CI pipeline that automates:

Pipeline Stages:

  1. Checkout: Source code retrieval
  2. Build: Maven compilation
  3. Unit Tests: JUnit test execution with JaCoCo coverage
  4. Code Quality: SonarQube analysis and Checkstyle checks
  5. Security Scan: OWASP dependency check
  6. Package: WAR file creation
  7. Publish Artifacts: Prepare artifacts for separate CD pipeline

Setup Instructions:

  1. Configure Jenkins with required plugins (see jenkins-config.md)
  2. Configure SonarQube server connection with ID sonar_integration
  3. Create pipeline job pointing to Jenkinsfile

Quick Local Build:

# Windows
build.bat

# Or manual steps
mvn clean test package

CI Pipeline Outputs:

  • 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

🌐API Endpoints

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

🧪Testing

Running Tests:

# Run all tests
mvn test

# Run with coverage
mvn clean test jacoco:report

# View coverage report
open target/site/jacoco/index.html

Test Structure:

  • 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

Code Quality:

# 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

🔍Usage

  1. User Registration: Register as a passenger or driver to access the platform.
  2. Create or Search for Rides:
    • Drivers can create ride offers.
    • Passengers can search for available rides by applying filters (e.g., location, time).
  3. Book a Ride: Select an available ride, submit a booking request, and await confirmation.
  4. Leave Feedback: After the ride is completed, provide feedback to help improve service quality.

🤝Contributing

Contributions are welcome! Follow these steps to contribute:

  1. Fork the repository.
  2. Create a new branch:
    git checkout -b feature/YourFeature
    

SQL queries to create the users, rides, and ride_requests tables

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
);

About

Application for managing carpooling or ride-sharing services. Projet JEE

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages