InfoGain Bus Ticket Reservation System
This project is a backend implementation of a bus ticket reservation system using a microservice architecture with Spring Boot. The system allows users to search for buses, view schedules, select seats, and make reservations. It includes user authentication and a mechanism to temporarily block seats to prevent race conditions during booking.
- User Service: Manages user authentication and profiles.
- Bus Service: Handles bus information, routes, and schedules.
- Booking Service: Manages seat reservations and availability.
- Payment Service: Simulates payment processing.
- Spring Boot for microservice creation.
- Spring Data JPA for database interaction.
- Spring Security for user authentication.
- Eureka for service discovery.
- MySQL for the database.
- Java 11 or higher
- Maven
- Docker (optional for containerization)
-
Clone the repository:
git clone https://github.com/your-repo/bus-ticket-reservation-system.git cd bus-ticket-reservation-system
-
Build the project:
mvn clean install
-
Run the microservices:
cd user-service mvn spring-boot:run cd ../bus-service mvn spring-boot:run cd ../reservation-service mvn spring-boot:run cd ../payment-service (optional) mvn spring-boot:run
-
Alternatively, you can use Docker to run the services (if Dockerfile is provided):
docker-compose up
To Register [User Mode]
To Login [User Mode]
-
Register User:
POST /users/register
{ "username": "john_doe", "password": "password123", "email": "john.doe@example.com" }
-
Login User:
POST /users/login
{ "username": "john_doe", "password": "password123" }
- Search Buses:
GET /buses/search?route={route}&departureTime={departureTime}
-
Block Seat:
POST /reservations/block
{ "busId": 1, "seatNumber": "A1", "userId": 1 }
-
Reserve Seat:
POST /reservations/reserve
{ "busId": 1, "seatNumber": "A1", "userId": 1 }
- Process Payment:
POST /payments/process
{ "reservationId": 1, "amount": 50.0 }
Field | Type |
---|---|
id | Long |
username | String |
password | String |
String |
Field | Type |
---|---|
id | Long |
route | String |
departureTime | String |
arrivalTime | String |
Field | Type |
---|---|
id | Long |
busId | Long |
userId | Long |
seatNumber | String |
paid | boolean |
blocked | boolean |
blockedUntil | LocalDateTime |
Global exception handling is implemented to manage various errors, including user not found, reservation conflicts, and generic errors.
- Fork the repository.
- Create your feature branch (
git checkout -b feature/your-feature
). - Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature/your-feature
). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or suggestions, please contact us at akashnkumar1@gmail.com.