Skip to content

EasyTrip-Backend REST API for cab booking application built with Spring Boot, supporting customers, drivers, bookings and admin operations with email alerts.

Notifications You must be signed in to change notification settings

mohdsajid9600/easytrip-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

31 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

EasyTrip-APP

EasyTrip is a secure, role-based RESTful backend application built using Spring Boot for a cab booking system. It provides APIs to manage authentication, customers, drivers, cabs, and bookings with support for secure login, ownership-based access, and admin controls.

πŸ” About Project

EasyTrip is a secure and scalable backend RESTful web application developed using Spring Boot for managing a complete cab booking system. The application is designed around dedicated dashboards for Customer, Driver, and Admin, with strict authentication and role-based authorization applied across all APIs. Customers can manage their profiles and book cabs, drivers can handle trip execution and booking status updates, and administrators can monitor and control customers, drivers, cabs, and bookings efficiently. All user operations are protected through ownership-based access control, ensuring that each user can access only their own data and related bookings.

The project follows a clean layered architecture using Controller, Service, Repository, DTO, and Transformer layers to ensure maintainability, scalability, and readability. Centralized exception handling provides consistent and structured error responses. Swagger UI is integrated for interactive API documentation and testing. The system also implements essential security features such as password encryption (BCrypt), login/logout mechanisms, change password and forgot password flows, along with status-based entity management (ACTIVE, INACTIVE, CONFIRMATION, COMPLETED, CANCELLED, etc.), reflecting real-world cab booking workflows.

This project is suitable for demonstrating real-world backend development concepts such as:

βœ” βš™οΈ Technical Features

  • RESTful API design
  • DTO based architecture
  • Entity to DTO transformation
  • Spring Security integration
  • Role based authorization (Admin, Driver, Customer)
  • Ownership security (user can access only his own data)
  • Validation annotations
  • Service layer separation
  • Interface-based services
  • Global exception handling
  • Status-based filtering using Enums
  • Clean layered architecture (Controller, Service, Repository, Model)
  • Swagger UI for API documentation

πŸ“§ Email Notification System

The application sends email notifications to customers for:

  • Booking Confirmation

  • Booking Completion

  • Booking Cancellation

Email templates are generated dynamically based on booking status.

πŸ›‘οΈ Security Model (Role Security Rules)

Role Access
CUSTOMER Own profile, own bookings, cab search
DRIVER Own profile, assigned bookings, cab qureries
ADMIN Full system access

βœ” Ownership security is applied using logged-in user identity
βœ” No user can access another user's data
βœ” /me APIs are used instead of {id}

πŸ”’ Ownership Security

Every customer or driver API uses the logged-in user’s Principal email to fetch only that user’s own data.

This ensures:
βœ” Prevents ID tampering
βœ” Only owners see their own bookings
βœ” Admin has privileged access

  • All protected APIs require session authentication.

πŸš€ Features of EasyTrip-Backend Application

πŸ” App Users (Authentication & Security)

βœ” Signup with Role (Customer / Driver only)
βœ” Login User
βœ” Logout User
βœ” Change Password
βœ” BCrypt password encryption
βœ” Role based access (ADMIN / DRIVER / CUSTOMER)
βœ” Profile status check (ACTIVE / INACTIVE)
βœ” Ownership based security (user can access only own data)

πŸ‘€ Customer Dashboard

🧾 Customer Profile

βœ” Create customer profile
βœ” View own profile
βœ” Update profile
βœ” Deactivate (inactive) profile

πŸ“– Customer Booking Window

βœ” View all bookings
βœ” View active booking
βœ” View completed bookings
βœ” View cancelled bookings
βœ” Book cab
βœ” Update booking
βœ” Cancel booking

πŸš• Cab Availability

βœ” Check available cabs

πŸš— Driver Dashboard

πŸ‘€ Driver Profile

βœ” Create driver profile
βœ” View own profile
βœ” Update profile
βœ” Deactivate (inactive) profile

πŸ“– Driver Booking Window

βœ” View all assigned bookings
βœ” View active booking
βœ” View completed bookings
βœ” View cancelled bookings
βœ” Complete booking (trip end)

πŸš• Driver Cab Queries

βœ” Register cab
βœ” Update cab details
βœ” Get own cab details

πŸ›‘οΈ Admin Dashboard

πŸ‘₯ Customer Management

βœ” View all customers
βœ” View active customers
βœ” View inactive customers
βœ” Find customer by ID
βœ” Search customers by gender & age
βœ” Search customers by age greater than
βœ” Activate customer profile
βœ” Inactivate customer profile

πŸš— Driver Management

βœ” View all drivers
βœ” View active drivers
βœ” View inactive drivers
βœ” Find driver by ID
βœ” Activate driver profile
βœ” Inactivate driver profile

πŸš• Cab Management

βœ” View all listed cabs
βœ” View active cabs
βœ” View inactive cabs
βœ” View available cabs
βœ” View unavailable cabs
βœ” Find cab by ID

πŸ“– Booking Management

βœ” View all bookings
βœ” Find booking by ID
βœ” Get bookings by customer
βœ” Get bookings by driver
βœ” View active bookings
βœ” View completed bookings
βœ” View cancelled bookings

πŸ›  Tech Stack

  • Java
  • Spring Boot
  • Spring Security
  • Spring MVC
  • Spring Data JPA
  • Hibernate ORM
  • MySQL Database / H2 (optional)
  • JavaMailSender (email)
  • RESTful APIs
  • Maven
  • Lombok
  • Postman / Swagger (for testing)

πŸ“‚ Project Structure

easetrip
β”‚
β”œβ”€β”€ .idea
β”œβ”€β”€ .mvn
β”‚
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ main
β”‚   β”‚   β”œβ”€β”€ java
β”‚   β”‚   β”‚   └── com.sajidtech.easytrip
β”‚   β”‚   β”‚       β”œβ”€β”€ config
β”‚   β”‚   β”‚       β”œβ”€β”€ controller
β”‚   β”‚   β”‚       β”œβ”€β”€ dto
β”‚   β”‚   β”‚       β”œβ”€β”€ emails
β”‚   β”‚   β”‚       β”œβ”€β”€ enums
β”‚   β”‚   β”‚       β”œβ”€β”€ exception
β”‚   β”‚   β”‚       β”œβ”€β”€ model
β”‚   β”‚   β”‚       β”œβ”€β”€ repository
β”‚   β”‚   β”‚       β”œβ”€β”€ security
β”‚   β”‚   β”‚       β”œβ”€β”€ service
β”‚   β”‚   β”‚       β”œβ”€β”€ transformer
β”‚   β”‚   β”‚       └── EasytripApplication.java
β”‚   β”‚   β”‚
β”‚   β”‚   └── resources
β”‚   β”‚       β”œβ”€β”€ static
β”‚   β”‚       β”œβ”€β”€ templates
β”‚   β”‚       └── application.properties
β”‚   β”‚
β”‚   └── test
β”‚
β”œβ”€β”€ target
β”‚
β”œβ”€β”€ .gitattributes
β”œβ”€β”€ .gitignore
β”œβ”€β”€ HELP.md
β”œβ”€β”€ mvnw
β”œβ”€β”€ mvnw.cmd
└── pom.xml

πŸ—„ Database Configuration

Configure database in application.properties:

spring.datasource.url=jdbc:mysql://localhost:3306/easytrip_db
spring.datasource.username=root
spring.datasource.password=your_password

spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true

spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=your_email@gmail.com
spring.mail.password=your_app_password
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true

βš™ How to Run the Project

1️. Clone repository git clone https://github.com/mohdsajid9600/easetrip-app.git

2️. Open project in IntelliJ / Eclipse

3. Configure database in application.properties

4. Run the application

5. Go to project directory cd easetrip-app

6. Build project mvn clean install

7. Run application mvn spring-boot:run

Application will run on:

http://localhost:8080

πŸ§ͺ API Testing

Use Postman or Swagger UI to test APIs.

πŸ” App Users (Auth APIs)

Method Endpoint Description
POST /auth/signup Signup user with role (CUSTOMER / DRIVER only)
POST /auth/login Login user
POST /auth/logout Logout current user
PUT /auth/change-password Change logged-in user password

πŸ‘€ Customer Dashboard

🧾 Customer Profile

Method Endpoint Description
POST /customer/create-profile Create customer profile
GET /customer/me Get logged-in customer profile
PUT /customer/me/update Update customer profile
DELETE /customer/me Deactivate customer profile

πŸ“– Customer Booking Windows

Method Endpoint Description
GET /booking/customer Get all bookings of logged-in customer
GET /booking/customer/active Get active booking
GET /booking/customer/completed Get completed bookings
GET /booking/customer/cancelled Get cancelled bookings
POST /booking/customer/booked Book a cab
PUT /booking/customer/update Update booking
PUT /booking/customer/cancel Cancel booking

πŸš• Cabs Availability

Method Endpoint Description
GET /cab/available Get all available cabs

πŸš— Driver Dashboard

πŸ‘€ Driver Profile

Method Endpoint Description
POST /driver/register Create driver profile
GET /driver/me Get logged-in driver profile
PUT /driver/me/update Update driver profile
DELETE /driver/me Deactivate driver profile

πŸ“– Driver Booking Windows

Method Endpoint Description
GET /booking/driver Get all bookings assigned to driver
GET /booking/driver/active Get active booking
GET /booking/driver/completed Get completed bookings
GET /booking/driver/cancelled Get cancelled bookings
PUT /booking/driver/complete Complete booking (trip finished)

πŸš• Driver Cab Queries

Method Endpoint Description
POST /cab/driver/register Register cab
PUT /cab/driver/update Update cab details
GET /cab/driver Get own cab details

πŸ›‘οΈ Admin Dashboard APIs

πŸ›‘οΈ Admin – Customer Fetch APIs

Method Endpoint Description
GET /admin/customers Get all customers
GET /admin/customers/active Get active customers
GET /admin/customers/inactive Get inactive customers
GET /admin/customer/search Search customer by id
GET /admin/customers/search Search customers by gender & age
GET /admin/customers/search/greater Search customers by age greater than
PUT /admin/customer/{id}/active Activate customer
PUT /admin/customer/{id}/inactive Inactivate customer

πŸ›‘οΈ Admin – Driver Fetch APIs

Method Endpoint Description
GET /admin/drivers Get all drivers
GET /admin/drivers/active Get active drivers
GET /admin/drivers/inactive Get inactive drivers
GET /admin/driver/search Search driver by id
PUT /admin/driver/{id}/active Activate driver
PUT /admin/driver/{id}/inactive Inactivate driver

πŸ›‘οΈ Admin – Cab Fetch APIs

Method Endpoint Description
GET /admin/cabs Get all cabs
GET /admin/cabs/active Get active cabs
GET /admin/cabs/inactive Get inactive cabs
GET /admin/cabs/available Get available cabs
GET /admin/cabs/unavailable Get unavailable cabs
GET /admin/cab/search Search cab by id

πŸ›‘οΈ Admin – Booking Fetch APIs

Method Endpoint Description
GET /admin/bookings Get all bookings
GET /admin/bookings/active Get active bookings
GET /admin/bookings/complete Get completed bookings
GET /admin/bookings/cancel Get cancelled bookings
GET /admin/bookings/driver Get bookings by driver
GET /admin/bookings/customer Get bookings by customer
GET /admin/booking/search Search booking by id

πŸ“ˆ Future Enhancements

βœ” JWT Authentication

βœ” Swagger Documentation

βœ” Ride Tracking

βœ” Rating System

βœ” Payment Gateway Integration

βœ” Frontend (React)

πŸ‘¨β€πŸ’» Developer

Er. Mohd Sajid

Java Backend Developer

πŸ“„ License

This project is developed for learning and practice purposes.