A Database-Driven GUI Ticket Reservation Platform with Dynamic Routing
- Project Overview
- Key Features
- Core Business Rules
- Database Architecture
- Setup Guide
- Usage Demo
- Algorithm Deep Dive
- Team Contributions
This system manages railway operations for 7 predefined routes with automated seat allocation, multi-route transit handling, and a 24-hour booking window.
Built with:
- Backend: Python + MySQL
- Frontend: Custom Tkinter GUI
- Security: SHA-256 + Salted Password Hashing
Feature | Description |
---|---|
Auto-Seat Assignment | Seats fill sequentially (Coach 1 → Coach 4) |
Dynamic Station Routing | DFS algorithm finds reachable stations within 24 hours |
Transit Management | Multi-route trips grouped under Together_ID (max 3 tickets) |
Cost Calculation | Fare = ((Travel Time + 5 mins) / 2) * 25 units |
User Authentication | Secure registration/login with password hashing |
- Train Structure
- 4 coaches/train × 25 seats/coach = 100 seats total.
- Trains operate on fixed routes (no route switching).
- Route Design
- 7 main routes: 5 × 12-hour routes (6 stations), 2 × 6-hour routes (3 stations).
- Adjacent stations are 2 hours apart.
- Timing
- Trains on the same track run 6/12 hours apart.
- All trips fit within a 24-hour window.
Table | Description |
---|---|
Ticket |
Stores seat, route, and booking group (Together_ID ) |
Station |
Contains station names and cities |
Track |
Edges between stations with departure times |
Train |
Train IDs and metadata |
Coach |
Tracks seat occupancy per train |
User |
Stores user credentials securely |
All tables satisfy 3NF (no transitive dependencies).
-
Clone Repository
git clone https://github.com/hamdiitarek/railway-booking-system.git cd railway-booking-system
-
Database Setup
-
Install MySQL Community Server.
-
Configure MySQL credentials in
env.txt
using the following format:localhost DB_Port Root_Username Database_Password Database_Name
-
-
Install Dependencies
pip install -r ./requirements.txt
-
Launch Application
python main.py
- New users are added to the
User
table with encrypted passwords.
def dfs_find_reachable(fStation, dept_time, total_time, target):
if total_time >= 24 or fStation in visited:
return
visited.add(fStation)
for neighbor in get_neighbors(fStation):
dfs_find_reachable(neighbor, ...)
- Purpose: Ensure trips fit within 24-hour window.
- Edge Handling: Skips backtracking to the origin station.
UPDATE Coach
SET Seats_taken = Seats_taken + 1
WHERE Train_ID = ? AND Coach_number = ?;
- Coaches fill sequentially; seat numbers auto-increment (1-25 per coach).