Skip to content

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš† Train Ticket Management System

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.


πŸ“Œ Overview

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.


✨ Key Features

πŸ“Š Dashboard

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

🎫 Ticket Issuing

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.


πŸ›οΈ Dynamic Bed Availability

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.


πŸ”’ Reservation Validation

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.


🎟️ Ticket Details

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.


πŸ”Ž Ticket Search

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

πŸ—‘οΈ Ticket Management

Existing tickets can be selected and deleted after confirmation.

When a ticket is deleted, its previously reserved bed becomes available again.


πŸ“ˆ Sales Reports

The reporting module provides two main report types.

Sales by Train

Displays:

  • Train
  • Route
  • Number of sold tickets
  • Total revenue

Sales by Route

Displays:

  • Origin
  • Destination
  • Number of sold tickets
  • Total revenue

πŸ—„οΈ Database

The application uses SQLite as its local relational database.

The database is automatically created when the application starts.

Main Tables

trains

Stores train information such as:

  • Train ID
  • Train name
  • Origin
  • Destination
  • Price

wagons

Stores wagon information associated with each train.

rooms

Stores room information and bed capacity.

tickets

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.


πŸ—οΈ Application Architecture

The current application is intentionally implemented in a single Python file and organized around two main classes.

Database

Responsible for:

  • Database initialization
  • Table creation
  • Seed data
  • Train queries
  • Wagon queries
  • Room queries
  • Bed availability
  • Ticket creation
  • Ticket deletion
  • Ticket retrieval
  • Sales reporting

TrainTicketApp

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.


πŸ› οΈ Technologies

  • Python
  • Tkinter
  • SQLite
  • Object-Oriented Programming (OOP)
  • SQL
  • Relational Database Design

Python Standard Libraries Used

  • sqlite3
  • tkinter
  • datetime

πŸ“ Project Structure

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.


πŸš€ Getting Started

Prerequisites

Make sure Python 3 is installed on your system.

You can verify your Python installation with:

python --version

Clone the Repository

git clone https://github.com/Trane-N-lab/train-ticket-system.git

Navigate to the Project

cd train-ticket-system

Run the Application

python train_ticket_system.py

The application will automatically create the SQLite database when it starts.


πŸ’‘ Technical Highlights

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

🎯 Project Purpose

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.


πŸ‘©β€πŸ’» Author

Fateme NabiGhanbari

GitHub: @Trane-N-lab


πŸ“„ License

This project is currently provided as a personal educational and portfolio project.

About

A desktop train ticket management system built with Python, Tkinter, and SQLite, featuring ticket booking, seat availability management, ticket search, cancellation, dashboard statistics, and sales reports.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages