Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Tinh Sombot Ticketing System

A desktop ticketing application built with CustomTkinter that enables users to browse events, purchase tickets, manage their profile, and display QR codes for purchased tickets. Admin users can create events, validate tickets via QR codes or reference numbers, and issue promo codes. The system integrates a MySQL backend with environment-based credentials and supports profile picture management and promo-based discounts.

🚀 Features

User

  • Secure signup & login (basic validation)
  • Browse events (filter by category)
  • Purchase tickets with promo code discounts
  • Auto-generated unique ticket reference + QR code image
  • View active tickets & show individual QR code
  • View expired (used) tickets
  • Profile management: change password, change username, upload profile picture

Admin

  • Add new events (ticket inventory, category, pricing, image)
  • Validate tickets (status update to Expired)
  • Scan QR codes from clipboard (image decode)
  • Create promo codes with discount percent + voucher quantity
  • Change username/password & profile picture (same as user)

Backend / System

  • MySQL schema auto-creation on first run
  • Tables: promo_code, ticket_data, user_data, userTicket_Bought
  • Environment-based DB credentials (.env file)
  • QR code generation using qrcode package
  • Simple random alphanumeric ticket number generation
  • Separation of concerns between UI and DB layer (backend_db.py)

🛠 Tech Stack

  • Python 3.x
  • CustomTkinter
  • Pillow (PIL)
  • PyMySQL
  • qrcode
  • pyzbar (QR decode for admin ticket validation)
  • tkcalendar (date picker)
  • python-dotenv (environment configuration)

📂 Project Structure

Tinh-Ticket/
├─ admin_homePage.py        # Admin UI (add tickets, validate, promo codes)
├─ home_page.py             # User UI (feed, tickets, profile)
├─ login.py                 # Login screen
├─ signup.py                # Signup screen
├─ backend_db.py            # Database logic & QR generator
├─ main.py                  # Application entry point
├─ requirements.txt         # Python dependencies
├─ .env                     # Environment variables (DB credentials)
├─ images/                  # UI assets & generated QR codes
│  ├─ QRCode/               # Generated ticket QR images
│  └─ ...                   
└─ profile_pics/
   └─ profile_picture/      # Uploaded profile pictures

⚙️ Setup & Installation

  1. Clone the repository:
git clone [https://github.com/YOUR_USERNAME/YOUR_REPO.git](https://github.com/thisisnotleng/Tinh-Ticket.git)
cd Tinh-Ticket
  1. Create and activate a virtual environment (recommended):
python -m venv venv
venv\Scripts\activate  # Windows
  1. Install dependencies:
pip install -r requirements.txt
  1. Create and configure the .env file (already present):
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=your_database
DB_PORT=3306
  1. Ensure the MySQL server is running and the user has permissions to create databases and tables.
  2. Run the application:
python main.py

✅ First Run Behavior

  • Automatically creates the database (if missing) and required tables
  • Inserts a default admin account:
    • Username: admin
    • Email: admin
    • Password: admin
    • User Type: admin

🔐 Environment Variables

Variable Required Description Default
DB_HOST Yes MySQL server host —
DB_USER Yes MySQL username —
DB_PASSWORD Yes MySQL password —
DB_NAME Yes Target database name —
DB_PORT No MySQL port 3306

🎟 Ticket Lifecycle

  1. Admin creates event (ticket inventory recorded)
  2. User books ticket → QR code generated under images/QRCode/
  3. Admin validates ticket (via reference number or QR decode) → status set to Expired
  4. User can view Active vs Expired tickets in profile

💾 Database Schema (Simplified)

  • user_data(user_id, username, email, password, user_type, profile_picture, user_stamp)
  • ticket_data(ticket_id, event_name, event_date, event_location, event_category, ticket_price, amount_left, image_path)
  • userTicket_Bought(ticket_id, event_name, event_date, event_location, event_category, ticket_price, ticket_ref_number, ticket_owner, image_path, ticket_status, qr_path)
  • promo_code(id, publisher_name, promo_number, disc_amount, voucher_amount)

🧩 Promo Code Flow

  • Admin creates promo code: discount fraction (e.g. 0.15) and voucher count
  • User enters code at purchase → price recalculated
  • (Future improvement) Decrement voucher count & expire when zero

🖼 Screenshots (Add later)

images/
  login_ui.png
  signup_ui.png
  ticket_logo.png

You can embed screenshots using standard markdown once hosted:

![Login Screen](images/login_ui.png)

🚧 Roadmap / Ideas

  • Hash passwords (e.g. bcrypt) instead of plain text
  • Enforce stronger input validation & error handling
  • Improve DB schema normalization (remove multi-column composite PKs)
  • Add voucher usage decrement logic for promo codes
  • Add pagination / search for events
  • Add export (CSV) for admin reports
  • Dockerize app + MySQL for easier onboarding
  • Unit tests & CI workflow

🛡 Security Notes

  • Current password storage is plain text (NOT secure) → Hashing recommended
  • Validate image uploads (limit size & type)
  • Sanitize user input for robustness (though parameterized queries help)

📜 License

MIT

🙌 Acknowledgements

  • CustomTkinter for modern Tkinter styling
  • Pillow for image handling
  • pyzbar for QR decoding
  • qrcode for QR generation

Feel free to suggest improvements or open an issue if something breaks. Enjoy building and managing events with Tinh Sombot!

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages