CHAPTER 1
INTRODUCTION
As cities grow, public transportation systems, especially buses, are finding it hard to
keep up with the increasing demand. Traditional bus management methods often lead to
problems like overcrowding, delays, and inefficient use of buses. These issues can frustrate
both passengers and operators.
To solve these problems, crowdsourcing offers a smart solution. Crowdsourcing means
collecting real-time information from passengers, such as where they are, their travel patterns,
and their experiences. This data helps improve bus schedules, routes, and capacity by
matching resources with the actual demand at any given time.
By using crowdsourced data, bus management systems can be more flexible and
responsive, ensuring buses run when and where they are needed most. This system also
allows passengers to report problems directly, helping operators fix issues quickly. Overall,
crowdsourcing can make bus systems more efficient, reduce waiting times, and provide better
service for everyone.
CHAPTER-2
SYSTEM ANALYSIS
2.1.1Demerits:
1.Data Reliability:
Crowdsourced data depends on passengers sharing accurate information. If
the data is incorrect or incomplete, it can lead to poor decisions in managing the bus system.
2.Privacy Concerns:
Collecting personal data from passengers, such as their location or travel
patterns, can raise privacy issues. People may be concerned about how their information is
used and stored.
3.Technology Dependence:
The system relies on mobile apps or other technology, which may not be
accessible to all passengers, especially older adults or those without smartphones
2.1.2 Merits:
1. Real-Time Data Collection:
Crowdsourcing allows for real-time input from passengers, providing accurate and
timely information about bus locations, traffic conditions, delays, and passenger counts.
This can lead to more dynamic decision-making, with immediate responses to
changing conditions.
2. Cost-Effectiveness:
By relying on users to provide data (such as route feedback, bus occupancy, or
delays), bus management on resources and manpower that would otherwise be needed for
manual data collection and monitoring.
3. Improved Service Efficiency:
Crowdsourced data can help identify patterns in bus usage, pinpoint inefficiencies, and
optimize routes and schedules.
This may result in improved service, shorter wait times, and better coverage of
underserved areas.
Crowdsourcing helps detect operational problems (e.g., crowded buses or bus
breakdowns) and provides faster solutions.
4. Enhanced Passenger Experience:
Passengers can report issues such as unsafe driving, cleanliness, or overcrowding in
real-time, which improves service quality and customer satisfaction.
Crowdsourced apps or platforms often include features like live bus tracking,
notifications of delays, or availability of seats, which enhance the commuter experience.
5. Increased Engagement and Accountability:
Crowdsourcing can encourage community involvement, as passengers become active
participants in improving the service. This fosters a sense of ownership and responsibility.
Transparency can increase, as passengers can access real-time data and see the actions
taken based on their input.
6. Data Diversity:
Crowdsourcing taps into a diverse range of perspectives, providing insights from
various demographic groups, locations, and times, offering a more comprehensive
understanding of bus system performance.
CHAPTER 3
HARDWARE AND SOFTWARE REQUIREMENTS
HARDWARE REQUIREMENTS:
1) Computer/Laptop
2) Mobile phone
3) Stable Internet connection
SOFTWARE REQUIREMENTS:
1) Python IDLE
CHAPTER 4
PROJECT DESCRIPTION
4.1Modules:
CHAPTER-5
RESULT DISCUSSION
5.1. SOURCE CODE
4.1.1.User/Passenger Module:
App = Flask(__name__)
# Database connection function
def get_db():
Conn = sqlite3.connect(‘bus_system.db’)
Return conn
# Route for user registration
@app.route(‘/register’, methods=[‘GET’, ‘POST’])
def register():
if request.method == ‘POST’:
Username = request.form[‘username’]
Password = request.form[‘password’]
Hashed_password = generate_password_hash(password, method=’sha256’)
Conn = get_db()
Cur = conn.cursor()
Cur.execute(“INSERT INTO users (username, password) VALUES (?, ?)”, (username,
hashed_password))
Conn.commit()
Conn.close()
Return redirect(url_for(‘login’))
Return render_template(‘register.html’)
# Route for user login
@app.route(‘/login’, methods=[‘GET’, ‘POST’])
def login():
If request.method == ‘POST’:
Username = request.form[‘username’]
Password = request.form[‘password’]
Conn = get_db()
Cur = conn.cursor()
Cur.execute(“SELECT * FROM users WHERE username = ?”, (username,))
User = cur.fetchone()
if user and check_password_hash(user[1], password):
return redirect(url_for(‘dashboard’))
else:
Return “Invalid login credentials”
Return render_template(‘login.html’)
# Dashboard (after successful login)
@app.route(‘/dashboard’)
Def dashboard():
Return “Welcome to your dashboard!”
If __name__ == ‘__main__’:
App.run(debug=True)
4.1.2.Admin Module:
# Route for adding a new bus route
@app.route(‘/add_route’, methods=[‘GET’, ‘POST’])
Def add_route():
If request.method == ‘POST’:
Route_name = request.form[‘route_name’]
Start_point = request.form[‘start_point’]
End_point = request.form[‘end_point’]
Schedule = request.form[‘schedule’]
Conn = get_db()
Cur = conn.cursor()
Cur.execute(“INSERT INTO routes (route_name, start_point, end_point, schedule)
VALUES (?, ?, ?, ?)”,
(route_name, start_point, end_point, schedule))
Conn.commit()
Conn.close()
Return redirect(url_for(‘admin_dashboard’))
Return render_template(‘add_route.html’)
# Admin dashboard
@app.route(‘/admin_dashboard’)
Def admin_dashboard():
Conn = get_db()
Cur = conn.cursor()
Cur.execute(“SELECT * FROM routes”)
Routes = cur.fetchall()
Conn.close()
Return render_template(‘admin_dashboard.html’, routes=routes)
4.1.3.Ticketing and Payment Module:
# Route for booking a ticket
@app.route(‘/book_ticket’, methods=[‘GET’, ‘POST’])
Def book_ticket():
If request.method == ‘POST’:
Route_id = request.form[‘route_id’]
Passenger_name = request.form[‘passenger_name’]
Seat_number = request.form[‘seat_number’]
Fare = request.form[‘fare’]
Conn = get_db()
Cur = conn.cursor()
Cur.execute(“INSERT INTO bookings (route_id, passenger_name, seat_number, fare)
VALUES (?, ?, ?, ?)”,
(route_id, passenger_name, seat_number, fare))
Conn.commit()
Conn.close()
Return redirect(url_for(‘payment’, fare=fare))
Return render_template(‘book_ticket.html’)
# Payment route
@app.route(‘/payment’)
Def payment():
Fare = request.args.get(‘fare’)
Return f”Proceed with the payment of {fare}”
class bus:
Def __init__(self, bus_id, capacity):
Self.bus_id = bus_id
Self.capacity = capacity
Self.booked_seats = 0
Def book_seat(self):
If self.booked_seats self.booked_seats += 1
Print(f”Seat booked successfully on Bus {self.bus_id}.”)
Else:
Print(f”Bus {self.bus_id} is fully booked.”)
Def get_available_seats(self):
Return self.capacity – self.booked_seats
Class Route:
Def __init__(self, route_id, start_point, end_point):
Self.route_id = route_id
Self.start_point = start_point
Self.end_point = end_point
Def display_route(self):
Print(f”Route {self.route_id}: {self.start_point} to {self.end_point}”)
Class Schedule:
Def __init__(self, bus, route, departure_time):
Self.bus = bus
Self.route = route
Self.departure_time = departure_time
Def display_schedule(self):
Print(f”Bus {self.bus.bus_id} is scheduled on Route {self.route.route_id} from
{self.route.start_point} to {self.route.end_point} at {self.departure_time}.”)
Class BusManagementSystem:
Def __init__(self):
Self.buses = []
Self.routes = []
Self.schedules = []
Def add_bus(self, bus_id, capacity):
Bus = Bus(bus_id, capacity)
Self.buses.append(bus)
Print(f”Bus {bus_id} with capacity {capacity} added.”)
Def add_route(self, route_id, start_point, end_point):
Route = Route(route_id, start_point, end_point)
Self.routes.append(route)
Print(f”Route {route_id} from {start_point} to {end_point} added.”)
Def create_schedule(self, bus_id, route_id, departure_time):
Bus = next((b for b in self.buses if b.bus_id == bus_id), None)
Route = next((r for r in self.routes if r.route_id == route_id), None)
If bus and route:
Schedule = Schedule(bus, route, departure_time)
Self.schedules.append(schedule)
Print(f”Schedule created for Bus {bus_id} on Route {route_id}.”)
Else:
Print(“Bus or route not found.”)
Def book_ticket(self, bus_id):
Bus = next((b for b in self.buses if b.bus_id == bus_id), None)
If bus:
Bus.book_seat()
Else:
Print(f”Bus {bus_id} not found.”)
Def display_buses(self):
Print(“Buses:”)
For bus in self.buses:
Print(f”Bus {bus.bus_id} – Capacity: {bus.capacity}, Available Seats:
{bus.get_available_seats()}”)
Def display_routes(self):
Print(“Routes:”)
For route in self.routes:
Route.display_route()
Def display_schedules(self):
Print(“Schedules:”)
For schedule in self.schedules:
Schedule.display_schedule()
If __name__ == “__main__”:
System = BusManagementSystem()
System.add_bus(“B101”, 40)
System.add_bus(“B102”, 30)
System.add_route(“R1”, “City A”, “City B”)
System.add_route(“R2”, “City B”, “City C”)
System.create_schedule(“B101”, “R1”, “2024-12-10 08:00”)
System.create_schedule(“B102”, “R2”, “2024-12-10 09:00”)
System.display_
System.display_routes()
System.display_schedules()
System.book_ticket(“B101”)
System.book_ticket(“B101”)
System.book_ticket(“B102”)
System.display_buses()
5.2.SCREENSHOT
CHAPTER 7
BIBLIOGRAPHY
Computer Science with Python by Sumita Arora