Skip to content

About

A Python-based Ticket Management System using OOP concepts, CRUD operations, exception handling, inheritance, and file handling.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Ticket-Management-System-Python

A Python-based Ticket Management System using OOP concepts, CRUD operations, exception handling, inheritance, and file handling.

The Ticket Management System is a Python-based console application designed to manage customer support tickets. The project demonstrates Object-Oriented Programming (OOP) concepts, CRUD operations, exception handling, inheritance, and file handling.

Features

  • Create Tickets
  • View All Tickets
  • Search Tickets
  • Close Tickets
  • Reopen Tickets
  • Update Ticket Issues
  • Delete Tickets
  • Count Open Tickets
  • Count Closed Tickets
  • VIP Ticket Support
  • Data Persistence using File Handling

OOP Concepts Used

  • Classes and Objects
  • Constructors
  • Encapsulation
  • Inheritance
  • Method Overriding
  • Super Keyword

Technologies Used

  • Python
  • File Handling
  • Exception Handling

How to Run

  1. Open the project in Spyder or any Python IDE.
  2. Run the Python file.
  3. Use the menu options to manage tickets.

Learning Outcomes

  • Implemented CRUD operations using OOP.
  • Practiced inheritance and encapsulation.
  • Implemented exception handling.
  • Stored and retrieved data using file handling.

Project Structure

File Purpose
ticket management system.py The original single-file version, with the bug fixes below applied in place. Still runs on its own
ticket_system.py Restructured version: core module with Ticket, VIPTicket, TicketManager, custom exceptions
main.py Console menu for the restructured version
test_ticket_system.py Unit tests for the restructured version (21 tests)
test_original_script.py Runs the original script with scripted input and checks each fix (9 tests)

Both versions are tested with the standard library only (30 tests in total).

Run the Improved Version

Requires Python 3.9 or newer. There are no external dependencies.

python main.py

Run the tests:

python -m unittest -v

Sample Session

----- Ticket Management System -----
1.  Create Ticket
2.  View All Tickets
...
11. Exit
Enter your choice: 1
Enter Ticket ID: 101
Enter Customer Name: Asha
Enter Issue: Login fails, error 500
1. Normal Ticket
2. VIP Ticket
Enter Ticket Type: 2
Enter Priority (High/Medium/Low): high
Ticket Created Successfully!

Tickets are saved to tickets.json after every change, for example:

{
  "type": "vip",
  "ticket_id": 101,
  "customer_name": "Asha",
  "issue": "Login fails, error 500",
  "status": "Open",
  "priority": "High"
}

What Changed From the First Version

Both the original script and the restructured version keep the same classes, menu and ideas, and fix these problems found in a code review:

  • Closed ticket count always showed 0 because it compared against "close" instead of "Closed".
  • Duplicate saves: creating a ticket wrote it to the file twice.
  • VIP priority was lost after a restart because only four fields were saved; the priority is now stored.
  • Commas in text (for example Login failed, error 500) broke the old comma separated file; data is now written with Python's csv module (original script) or as JSON (main.py).
  • Invalid ticket type no longer adds a wrong or undefined ticket.
  • Open ticket count printed once per ticket instead of once.
  • Duplicate ticket IDs are now rejected.
  • Status values are stored in one format (Open / Closed); main.py also rejects any other value.

Extra improvements in main.py only:

  • A corrupt data file is moved to tickets.json.bak instead of being overwritten.
  • Existing tickets.txt data from the first version is imported automatically (duplicate rows are skipped).
  • The original script reads old four-column tickets.txt files too, and skips duplicate rows.

Design Notes and Known Limitations

  • The menu logic lives in small functions and the data logic lives in TicketManager, so each part can be tested on its own.
  • Data is stored in a single JSON file, which is fine for a learning project but is not safe for several users at once.
  • Search is by ticket ID only.
  • Ideas for later: search by customer name, sorting and filtering, a SQLite or database backend, and a simple web or GUI front end.

About

A Python-based Ticket Management System using OOP concepts, CRUD operations, exception handling, inheritance, and file handling.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages