Fake logo
Fake logo
on
BACHELOR OF TECHNOLOGY
in
DEPARTMENT OF CSD
i
COMPUTER SCIENCE ENGINEERING(DATA SCIENCE)
Date:
CERTIFICATE
This is to certify that the project work entitled “Flask Based e-Transit Ticketing Portal”
work done by R. SRI DHANUSH(217Y1A67B6), S. DURGA PRASAD(217Y1A6779) and
S.VISHNU CHOWDARY(217Y1A67C8) students of Department of Computer Science
Engineering (Data Science) is a record of bonafide work carried out by the members during a
period from MAY, 2024 to JULY, 2024 under the supervision of Mr.V. INDIVARU TEJA. This
project is done as a fulfilment of obtaining Bachelor of Technology Degree to be awarded by
Jawaharlal Nehru Technological University Hyderabad, Hyderabad.
The matter embodied in this project report has not been submitted by us to any
other university for the award of any other degree.
This is to certify that the above statement made by the candidate(s) is correct to the best
of my knowledge.
External Examiner
Principal
ii
ACKNOWLEDGEMENTS
We would like to express our sincere gratitude to our guide Mr.V. Indivaru Teja,
Asst.Professor Dept of CSD, for his excellent guidance and invaluable support, which helped
us accomplish the B.Tech degree and prepared me to achieve more life goals in the future. His
total support of my dissertation and countless contributions to my technical and professional
development made for a truly enjoyable and fruitful experience. Special thanks are dedicated
for the discussions we had on almost every working day during my project period and for
reviewing my dissertation.
We wish to express deepest gratitude and thanks to Dr. R. Murali Prasad, Principal, and Dr.
P. Sridhar, Director for their constant support and encouragement in providing all the
facilities in the college to do the project work.
We would also like to thank all our faculties, administrative staff and management of
MLRITM, who helped me to completing the project.
On a more personal note, I thank my beloved parents and friends for their moral
support during the course of our project.
iii
TABLE OF CONTENTS
Page No.
Certificate ii
Acknowledgements iii
Table of Contents iv
List of Figures v
Abstract vi
Chapter 1: Introduction VII-IX
1.1 User Autentication vii
1.2 Enchancements vii
1.2.1 Backend Enchancements vii
1.2.2 Future Enchancements viii
1.3 Main Objective viii
1.4 The Need for a Bus Reservation System ix
Chapter 2: Literature Survey X-XIII
2.1 Algorithms Used x
2.2 Existing Systems xi-xii
2.2.1 Booking System xi
2.2.2 Limitations xii
2.3 Proposed System xiii
Chapter 3: Implementation Details XIV-XXIII
iv
Publications (if any) ------------
LIST OF FIGURES
v
ABSTRACT
The Bus Reservation System is an innovative web-based application designed to simplify and
enhance the process of booking and managing bus tickets. Developed using Flask, a
lightweight Python web framework, this project provides an efficient solution for both
passengers and bus operators. The system features a user-friendly interface built with HTML
and CSS, enabling seamless interaction and navigation.
Upon accessing the application, users are prompted to log in with their credentials. The login
mechanism ensures secure access and personalized service. Once authenticated, users can book
tickets by selecting a bus, entering passenger details, and confirming their reservation. The
system dynamically updates the availability of seats, ensuring real-time accuracy and
preventing overbooking. Passengers can also cancel their tickets if plans change, with the
system adjusting seat availability accordingly.
An essential feature of the Bus Reservation System is the ability to check the status of buses.
Users can obtain detailed information about bus routes, departure and arrival times, total seats,
available seats, and fare. This transparency aids passengers in making informed decisions and
enhances the overall travel experience.
The backend of the application leverages Python for logical operations and data management,
ensuring robust performance and scalability. The use of Flask facilitates rapid development and
easy maintenance. Future enhancements could include integrating a database to store user and
reservation data, implementing user registration, and adding advanced features like payment
processing and notification services.
Overall, the Bus Reservation System project exemplifies the practical application of web
development technologies to solve real-world problems, providing a reliable and user-centric
platform for managing bus reservations.
vi
CHAPTER 1
INTRODUCTION
The Bus Reservation System is a web-based application developed using Flask, a Python
micro-framework, to streamline and enhance the process of booking and managing bus
tickets. This project is designed to provide a seamless and user-friendly experience for
passengers and bus operators, making ticket reservations more efficient and accessible.
User Authentication
Upon accessing the application, users are required to log in using their credentials. This secure
login mechanism ensures that only authorized users can access the system, protecting sensitive
information and providing a personalized experience. Once logged in, users can book tickets
by selecting a bus, entering passenger details, and confirming their reservation. The system
dynamically updates the number of available seats in real time, preventing overbooking and
ensuring accurate seat allocation. Additionally, users can easily cancel their tickets if plans
change, with the system promptly updating seat availability. An essential feature of the Bus
Reservation System is the ability to check the status of buses. Users can view detailed
information about each bus, including its route, departure and arrival times, total seats,
available seats, and fare. This transparency helps passengers make informed travel decisions.
The backend logic of the application is managed using Python, ensuring robust performance
and scalability. Flask facilitates rapid development and easy maintenance. Future
enhancements could include integrating a database for storing user and reservation data,
implementing user registration, and adding advanced features like payment processing and
notification services.
Overall, the Bus Reservation System exemplifies the practical application of web development
technologies to solve real-world problems. By providing a reliable and user-centric platform
for managing bus reservations, this project enhances the travel experience for passengers and
simplifies operations for bus companies.
Main Objective
The primary objective of the Bus Reservation System project is to develop a web-based
application that simplifies and streamlines the process of booking and managing bus tickets.
This system aims to provide a secure, user-friendly platform that enables passengers to
effortlessly book and cancel tickets, check bus statuses, and obtain detailed information
vii
about bus routes, availability, and fares. By leveraging the Flask framework and Python, the
project
viii
seeks to enhance the efficiency, accuracy, and overall experience of bus travel for both
passengers and bus operators.
The Bus Reservation System addresses several key challenges and inefficiencies
associated with traditional bus ticket booking processes. The primary needs for this project
include:
Overall, the Bus Reservation System aims to modernize the bus ticket booking process,
making it more efficient, user-friendly, and reliable for both passengers and operators.
viv
CHAPTER 2
Literature Survey
The Bus Reservation System aims to streamline the process of booking and managing bus
tickets through a web-based application. This literature survey examines existing systems,
their limitations, and the algorithms and technologies used to develop the new system.
Flask is a micro web framework for Python that is lightweight and easy to use. It is chosen for
its simplicity and flexibility, allowing developers to build scalable web applications with
minimal overhead. Flask facilitates:
Routing: Maps URLs to functions, allowing for clean and readable URLs.
Template Rendering: Uses Jinja2 for rendering HTML templates dynamically.
Session Management: Manages user sessions securely.
Data Storage
For this project, data is stored in Python lists, but in a production environment, a
relational database like SQLite, MySQL, or PostgreSQL would be used:
User Authentication
The user authentication mechanism ensures that only authorized users can access the system:
The booking and cancellation algorithms are designed to update seat availability in real-time:
Booking Algorithm:
o Check bus availability.
o Verify seat availability.
ix
o Allocate seat and update the availability count.
o Store passenger details.
Cancellation Algorithm:
o Verify passenger and booking details.
o Update seat availability.
o Remove passenger details from the system.
Data Structures: Use Python lists and dictionaries to store and update seat
data efficiently.
Concurrency Handling: Ensure that concurrent booking and cancellation requests
are handled correctly to prevent race conditions.
Existing Systems
Manual Booking Systems
Early online systems provided a basic interface for booking tickets but had several limitations:
x
Limitations of Existing Systems
Scalability Issues
Many early systems are not designed to handle a large number of users simultaneously, leading
to performance bottlenecks.
Security Concerns
Basic security measures in older systems are insufficient to protect against modern threats,
leaving user data at risk.
Limited Features
Older systems often lack features such as integration with payment gateways, real-time
seat updates, and user-friendly interfaces.
Maintenance Challenges
Monolithic architecture in older systems makes them difficult to maintain and upgrade.
Proposed System
The Bus Reservation System leverages modern web development frameworks and
algorithms to provide a robust, secure, and user-friendly platform for managing bus
reservations. By addressing the limitations of existing systems, this project aims to
significantly improve the efficiency and convenience of booking and managing bus tickets.
Future enhancements will continue to evolve the system, ensuring it meets the growing
demands and expectations of users.
xi
Technologies Used:
Frontend Technologies
Backend Technologies
1. Python: The programming language used for the backend logic.
o Flask: A lightweight web framework for Python that is used to build the web
application.
o Jinja2: A templating engine for Python, which is used with Flask to dynamically
generate HTML content.
xii
CHAPTER 3
Implementation Details
The Bus Reservation System is built using Flask, a lightweight Python web framework ideal
for developing web applications. The first step involves setting up the Flask environment
and creating an instance of the Flask class, which acts as the central registry for the
application. This setup allows for seamless handling of web requests and responses.
User Authentication
User authentication is a critical feature ensuring that only authorized users can access the
system. The login functionality is implemented to verify user credentials against a predefined
list of users. Upon successful authentication, users are granted access to the system and
redirected to the dashboard. This secure mechanism involves handling user sessions to
maintain login states.
After logging in, users are directed to the dashboard, which offers various options such as
booking tickets, canceling reservations, checking bus statuses, and logging out. The
dashboard serves as the main interface for user interaction, allowing them to navigate through
different functionalities seamlessly.
Ticket Booking
The ticket booking process involves selecting a bus, entering passenger details, and
confirming the reservation. The system checks seat availability in real-time, allocates a seat,
updates the number of available seats, and stores the passenger's information. This dynamic
update ensures that the seat allocation is accurate and prevents overbooking.
Ticket Cancellation
Ticket cancellation allows users to revoke previously booked tickets. The system verifies
the passenger's details and updates the bus's seat availability accordingly. This functionality
ensures that canceled seats are made available for other passengers, maintaining an accurate
count of available seats.
Users can check the status of buses, including total and available seats, route information, and
fare. This feature provides real-time updates and detailed information, helping passengers make
xiii
informed travel decisions. The system retrieves and displays this data dynamically,
ensuring up-to-date information is always available.
Logout
The logout functionality is designed to clear user session data, effectively logging the user
out and redirecting them to the home page. This ensures that user sessions are managed
securely and that access is revoked once the user logs out.
The frontend of the application is created using HTML templates rendered by Flask. The home
page includes a login form, while the dashboard offers navigation options for booking,
canceling tickets, checking bus statuses, and logging out. Each functionality has a
corresponding form in its HTML template, allowing users to input necessary details and
interact with the system efficiently.
xiv
Code Implementation
app.py
from flask import Flask, render_template, request, redirect, url_for, session
class Bus:
def __init (self, bus_number, source, destination, total_seats,
fare): self.bus_number = bus_number
self.source = source
self.destination = destination
self.total_seats = total_seats
self.available_seats =
total_seats self.fare = fare
class Passenger:
def __init (self, name, age, seat_number, bus_number):
self.name = name
self.age = age
self.seat_number =
seat_number self.bus_number
= bus_number
class User:
def __init (self, username,
password): self.username =
username self.password = password
buses = [Bus(101, "City A", "City B", 50, 25.0), Bus(102, "City C", "City
D", 40, 20.0),
Bus(103, "City E", "City F", 30, 15.0)]
passengers = []
@app.route('/
') def
home():
return render_template('index.html')
@app.route('/login',
methods=['POST']) def login():
username =
request.form['username']
password =
request.form['password']
user = next((user for user in users if user.username ==
username and user.password == password), None)
xv
if user:
session['username'] = username
return
redirect(url_for('dashboard')) else:
return "Login failed. Please check your username and password."
xvi
@app.route('/
dashboard') def
dashboard():
if 'username' not in session:
return redirect(url_for('home'))
return render_template('dashboard.html', username=session['username'])
@app.route('/book_ticket',
methods=['POST']) def book_ticket():
bus_number = int(request.form['bus_number'])
bus = next((bus for bus in buses if bus.bus_number ==
bus_number), None) if bus and bus.available_seats > 0:
name = request.form['name']
age =
int(request.form['age'])
seat_number = bus.total_seats - bus.available_seats
+ 1 passenger = Passenger(name, age, seat_number,
bus_number) passengers.append(passenger)
bus.available_seats -= 1
return "Ticket booked
successfully!" elif not bus:
return f"Bus with Bus Number {bus_number} not
found." else:
return "Sorry, the bus is fully booked."
@app.route('/cancel_ticket',
methods=['POST']) def cancel_ticket():
name = request.form['name']
bus_number = int(request.form['bus_number'])
passenger = next((p for p in passengers if p.name == name and
p.bus_number == bus_number), None)
if passenger:
bus = next(bus for bus in buses if bus.bus_number ==
bus_number) bus.available_seats += 1
passengers.remove(passenger)
return "Ticket canceled
successfully!" else:
return f"Passenger with name {name} not found on bus {bus_number}."
@app.route('/bus_status',
methods=['POST']) def bus_status():
bus_number = int(request.form['bus_number'])
bus = next((bus for bus in buses if bus.bus_number ==
bus_number), None) if bus:
return render_template('bus_status.html',
bus=bus) else:
return f"Bus with Bus Number {bus_number} not found."
@app.route('/
logout') def
logout():
session.pop('username', None)
return
redirect(url_for('home'))
xvii
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bus Reservation System</title>
</head>
<body>
<h1>Bus Reservation System</h1>
<form action="/login" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<br>
<button type="submit">Login</button>
</form>
</body>
</html>
dashboard.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dashboard</title>
</head>
<body>
<h1>Welcome, {{ username }}!</h1>
<form action="/book_ticket" method="post">
<h2>Book a Ticket</h2>
<label for="bus_number">Bus Number:</label>
<input type="number" id="bus_number" name="bus_number" required>
<br>
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<br>
<label for="age">Age:</label>
<input type="number" id="age" name="age" required>
<br>
<button type="submit">Book Ticket</button>
</form>
<form action="/cancel_ticket" method="post">
<h2>Cancel a Ticket</h2>
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<br>
<label for="bus_number">Bus Number:</label>
xix
<input type="number" id="bus_number" name="bus_number" required>
<br>
<button type="submit">Cancel Ticket</button>
</form>
<form action="/bus_status" method="post">
<h2>Check Bus Status</h2>
<label for="bus_number">Bus Number:</label>
<input type="number" id="bus_number" name="bus_number" required>
<br>
<button type="submit">Check Status</button>
</form>
<form action="/logout" method="get">
<button type="submit">Logout</button>
</form>
</body>
</html>
bus_status.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bus Status</title>
</head>
<body>
<h1>Bus Status</h1>
<p>Bus Number: {{ bus.bus_number }}</p>
<p>Source: {{ bus.source }}</p>
<p>Destination: {{ bus.destination }}</p>
<p>Total Seats: {{ bus.total_seats }}</p>
<p>Available Seats: {{ bus.available_seats }}</p>
<p>Fare: {{ bus.fare }}</p>
<a href="/dashboard">Back to Dashboard</a>
</body>
</html>
xx
UML Diagrams:
2. User UseCase:
xxi
Sequence Diagram:
Activity Diagram:
xxii
Output:
xxii
Step 1:
xxv
Step 3:
Step 4:
To logout click on the logout button under the bus status web page.
The user returns to the Login page.
xxv
Conclusion
The Bus Reservation System project effectively demonstrates the implementation of a web-
based application using Flask to manage bus reservations. This project provides users with
essential features like logging in, booking tickets, canceling tickets, and checking bus statuses.
By leveraging Python and Flask, the project ensures a robust and user-friendly interface for
handling reservations. The structured approach and clear functionality make this system a
valuable tool for both passengers and bus operators, highlighting the practical application of
web development technologies in solving real-world problems efficiently.
References
Laweb,(2010): "Central Reservation System | Online Hotel Marketing Services, Hong Kong and
Philippines Hotel, Spa and Restaurant Software". Iaweb.net. 2010. Retrieved 2012-11-08.
Kevin O. C., (2012): Web-Based Bus Reservation and Ticketing System: College of Computer
Studies, Ateneo de Naga University, Naga City, Philippines February 26, 2012
Spool. J., Scanlon. T., Schroeder. W., Snyder. W., and DeAngelo. T. (1999): Website Usability.
San Franciso: Morgan Kaufmann Publishers, Inc.
University Press
xxv