This application is developed in Spring Boot and provides APIs for train booking. It utilizes MySQL as the database for storing data. The application receives requests from the frontend and responds with JSON data.
-
Endpoint:
/
- Method: GET
- Description: Retrieves the booking started date.
- Response: JSON containing the booking started date (
startDate
).
-
Endpoint:
/adminLogin
- Method: POST
- Description: Authenticates the admin user.
- Request Body:
username
(string): Admin username.password
(string): Admin password.
-
Endpoint:
/addTrain
- Method: POST
- Description: Adds a new train.
- Request Body:
trainNo
(int): Train number.trainName
(string): Train name.startStation
(Station): Starting station.stopStation
(Station): Destination station.numberOfSeats
(int): Total number of seats.fare
(int): Fare for the train.
-
Endpoint:
/addStation
- Method: POST
- Description: Adds a new station.
- Request Body:
stationCode
(int): Station code.stationName
(string): Station name.
-
Endpoint:
/showTrain
- Method: GET
- Description: Retrieves all trains.
- Response: JSON array containing all train details (
trainList
).
-
Endpoint:
/userRegister
- Method: POST
- Description: Registers a new user.
- Request Body:
userFullName
(string): Full name of the user.userName
(string): User's username.password
(string): User's password.
-
Endpoint:
/userLogin
- Method: POST
- Description: Authenticates the user.
- Request Body:
username
(string): User's username.password
(string): User's password.
-
Endpoint:
/book/showTrain
- Method: POST
- Description: Retrieves available trains based on start and stop stations and date.
- Request Body:
startStation
(string): Start station name.stopStation
(string): Stop station name.date
(Date): Date of travel.
- Response: JSON array containing available train details (
trainList
).
-
Endpoint:
/book/ticketBooking
- Method: POST
- Description: Books a ticket for a user.
- Request Body:
userId
(int): User ID.logId
(long): Login ID.noOfPassengers
(int): Number of passengers.
- Response: JSON containing the booking details (
bookingDetails
).
-
Endpoint:
/user/showMyTickets
- Method: POST
- Description: Retrieves tickets booked by a user.
- Request Body:
userId
(int): User ID.
- Response: JSON array containing the booked ticket details (
ticketList
).
To run this application locally, follow these steps:
- Clone the repository:
git clone https://github.com/shoaib749/IRCTC-Backened.git
- Navigate to
the project directory:
cd train-booking-api
- Build the project:
./mvnw clean package
- Run the application:
./mvnw spring-boot:run
The application will start running on http://localhost:8080
.
Remember to configure the MySQL database connection details in the application.properties
file.
The following dependencies are used in this Spring Boot application:
- Spring Web
- Spring Data JPA
- MySQL Driver
These dependencies are managed through Maven. The required dependencies will be automatically downloaded when building the project.