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.
- 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
- Classes and Objects
- Constructors
- Encapsulation
- Inheritance
- Method Overriding
- Super Keyword
- Python
- File Handling
- Exception Handling
- Open the project in Spyder or any Python IDE.
- Run the Python file.
- Use the menu options to manage tickets.
- Implemented CRUD operations using OOP.
- Practiced inheritance and encapsulation.
- Implemented exception handling.
- Stored and retrieved data using file handling.
| 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).
Requires Python 3.9 or newer. There are no external dependencies.
python main.pyRun the tests:
python -m unittest -v----- 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"
}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'scsvmodule (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.pyalso rejects any other value.
Extra improvements in main.py only:
- A corrupt data file is moved to
tickets.json.bakinstead of being overwritten. - Existing
tickets.txtdata from the first version is imported automatically (duplicate rows are skipped). - The original script reads old four-column
tickets.txtfiles too, and skips duplicate rows.
- 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.