A desktop-based train ticket management system developed with Python, Tkinter, SQLite, and Object-Oriented Programming (OOP).
The application provides a graphical interface for managing train ticket sales, passenger reservations, wagon and room selection, bed availability, ticket records, and sales reports.
The Train Ticket Management System is a complete desktop application designed to simulate the core workflow of a train ticket sales system.
The application provides tools for:
- Managing train information
- Selecting trains and routes
- Selecting wagon and room types
- Checking bed availability
- Issuing train tickets
- Preventing duplicate reservations
- Searching ticket records
- Viewing detailed ticket information
- Deleting tickets
- Monitoring sales statistics
- Generating train-based sales reports
- Generating route-based sales reports
- Tracking total capacity and revenue
The application uses SQLite as a local relational database, so no external database server is required.
The dashboard provides an overview of the current system status, including:
- Total issued tickets
- Total sales revenue
- Available trains
- Total bed capacity
- Recent ticket records
- Quick access to system functions
The ticket issuing module allows the operator to enter and select:
- Passenger name
- Train
- Origin
- Destination
- Wagon
- Room
- Travel day
- Departure time
- Bed number
The ticket price is automatically retrieved from the selected train.
The system manages bed availability for each room.
For each room, the application identifies:
- Available beds
- Reserved beds
- Currently selected beds
A reserved bed cannot be selected again for the same train schedule.
Multiple validation mechanisms are implemented to reduce invalid and conflicting reservations.
The system validates:
- Passenger name
- Room selection
- Bed number
- Bed availability
- Existing reservations
- Duplicate passenger reservations
The database also enforces a unique reservation constraint based on the train, room, bed, travel day, and departure time.
After successfully issuing a ticket, the application displays detailed ticket information, including:
- Ticket ID
- Passenger name
- Train
- Route
- Wagon
- Room
- Bed number
- Travel day
- Departure time
- Ticket price
Previously issued tickets can also be opened from the ticket management section.
The ticket management section provides dynamic search functionality.
Tickets can be searched using information such as:
- Ticket ID
- Passenger name
- Train name
- Origin
- Destination
- Wagon
- Room
Existing tickets can be selected and deleted after confirmation.
When a ticket is deleted, its previously reserved bed becomes available again.
The reporting module provides two main report types.
Displays:
- Train
- Route
- Number of sold tickets
- Total revenue
Displays:
- Origin
- Destination
- Number of sold tickets
- Total revenue
The application uses SQLite as its local relational database.
The database is automatically created when the application starts.
Stores train information such as:
- Train ID
- Train name
- Origin
- Destination
- Price
Stores wagon information associated with each train.
Stores room information and bed capacity.
Stores issued ticket records, including:
- Passenger
- Train
- Wagon
- Room
- Bed
- Travel day
- Departure time
- Price
- Creation time
SQLite foreign-key constraints are enabled to maintain relational integrity.
The current application is intentionally implemented in a single Python file and organized around two main classes.
Responsible for:
- Database initialization
- Table creation
- Seed data
- Train queries
- Wagon queries
- Room queries
- Bed availability
- Ticket creation
- Ticket deletion
- Ticket retrieval
- Sales reporting
Responsible for:
- GUI configuration
- Dashboard
- Ticket issuing
- Ticket management
- Search
- Ticket details
- Sales reports
This separation keeps the database operations and graphical user interface responsibilities logically organized within the application.
- Python
- Tkinter
- SQLite
- Object-Oriented Programming (OOP)
- SQL
- Relational Database Design
sqlite3tkinterdatetime
train-ticket-system/
β
βββ train_ticket_system.py
βββ README.md
βββ .gitignore
The SQLite database file is generated automatically when the application runs and is intentionally excluded from version control.
Make sure Python 3 is installed on your system.
You can verify your Python installation with:
python --versiongit clone https://github.com/Trane-N-lab/train-ticket-system.gitcd train-ticket-systempython train_ticket_system.pyThe application will automatically create the SQLite database when it starts.
This project demonstrates practical implementation of:
- Object-oriented application design
- GUI development with Tkinter
- Relational database design
- SQLite database integration
- CRUD operations
- Foreign-key relationships
- Data validation
- Reservation conflict prevention
- Dynamic availability management
- Search and filtering
- Sales and revenue reporting
- Event-driven GUI programming
- Exception handling
This project was developed as a practical software engineering project to apply programming, object-oriented design, database management, GUI development, and problem-solving concepts in a complete desktop application.
Fateme NabiGhanbari
GitHub: @Trane-N-lab
This project is currently provided as a personal educational and portfolio project.