Skip to content

Gokuldatthu/TicketSwap-python_core_project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Ticket Swap Platform

A simple tool used to let the student know which clgs one can take admission based on EAMCET Ranks

Ticket Swap Platform (Instant)

''' A lightweight user-to-user ticket resale marketplace built with Streamlit (frontend) and Supabase (database). Users can sign up, add tickets for sale, view marketplace listings, buy tickets, and view their purchased tickets. The app stores ticket records, updates wallets on purchase, and supports simple affiliate bonuses.

This README explains the project structure, how to set up the Supabase database (including the tickets table you requested), and how to run the app locally. '''

Repository structure

/
├─ frontend/
│  └─ app.py             # Streamlit UI
├─ src/
│  ├─ logic.py           # Business logic (Supabase queries)
│  └─ db.py              # Helper/CLI DB utilities and samples
├─ requirements.txt      # Python dependencies
├─ readme.md             # Project documentation (this file)
└─ .env                  # (not checked in) environment variables

Features

  • User management: sign up, login
  • Movies: add and view movies (poster URL supported)
  • Marketplace: add tickets for sale (seller sets quoted price)
  • Buy flow: users can buy tickets (wallet updates) and record purchased tickets
  • My Tickets: users can view tickets they've bought (stored in tickets table)
  • Simple affiliate bonus support when adding tickets to the marketplace

Prerequisites

  • Python 3.8+
  • A Supabase account (Postgres + REST API)
  • Git (recommended)

Installation

  1. Clone the repo:
git clone <repository-url>
cd instant
  1. Install Python dependencies:
pip install -r requirements.txt
  1. Create a .env file in the project root and add your Supabase credentials:
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your-service-role-or-anon-key

Security note: keep service role keys secret and never commit .env to source control.

Database (Supabase) setup

Create the database tables used by the app. Below are example SQL statements for the core tables. Adjust column types and constraints to match your Supabase/Postgres setup.

  1. Users (example)
create table users (
   id serial primary key,
   name text,
   mail text,
   phone text,
   pwd text,
   interests text,
   wallet integer default 0
);
  1. Movies
create table movies (
   id serial primary key,
   name text,
   genre text,
   release_date date,
   url text  -- poster url
);
  1. Marketplace (mart)
create table mart (
   id serial primary key,
   uid integer references users(id) on delete cascade,
   movie_name text,
   no_of_tickets integer,
   official_price integer,
   quoted_price integer,
   affiliate boolean default false,
   refund boolean default false,
   showtime timestamp
);
  1. Tickets (purchased tickets) — per your requested schema
CREATE TABLE tickets (
   id SERIAL PRIMARY KEY,
   uid INTEGER NOT NULL,
   name TEXT NOT NULL,
   no_of_tickets INTEGER NOT NULL CHECK (no_of_tickets > 0),
   showtime TIMESTAMP NOT NULL,
   FOREIGN KEY (uid) REFERENCES users(id) ON DELETE CASCADE
);

Notes:

  • Run these SQL statements in the Supabase SQL editor or your Postgres client.
  • The application will attempt inserts into these tables; if a table is missing, insert operations will quietly fail (the app continues), so make sure you create them before testing purchases.

Environment variables

  • SUPABASE_URL — your Supabase project URL
  • SUPABASE_KEY — the anon or service key used to access Supabase

Place them in a .env file at the project root.

Run the app

  1. Start the Streamlit frontend (from the project root):
streamlit run "frontend/app.py" --server.port 8502

Open the Local URL displayed (e.g., http://localhost:8502).

  1. (Optional) CLI helpers

The src/db.py file contains helper functions and example flows for directly interacting with Supabase (add user, add movie, etc.). It is not a web API.

How to use the app (quick walkthrough)

  1. Sign up from the sidebar (or use an existing account).
  2. Log in using the sidebar login (name + password) — note: current implementation uses plaintext passwords stored in Supabase; consider upgrading to hashed passwords for production.
  3. Home: shows movie poster cards (suggestions if logged in, otherwise all movies).
  4. Add Movie: add a movie and include a url for poster images.
  5. Add Tickets: logged-in sellers can add tickets to the marketplace (quote must be less than official price).
  6. View Mart: browse tickets offered by others.
  7. Buy Ticket: when buying you are prompted for movie name, ticket count, and show date/time — the app updates wallets and records purchased tickets in the tickets table.
  8. My Tickets: view tickets you purchased.

Development notes & TODO

  • Password security: store hashed passwords (bcrypt) instead of plaintext.
  • Add proper authentication tokens instead of name-based login.
  • Improve image handling: thumbnail generation or signed URLs for private storage.
  • Pagination & search on movie listing pages.
  • Unit tests for business logic in src/logic.py.

Troubleshooting

  • Deprecation warnings from Streamlit: update calls like use_column_widthuse_container_width (already updated in this repo).
  • If images do not show: ensure movies.url contains public image URLs or use Supabase signed URLs.
  • If purchases do not record in tickets: verify tickets table exists and your Supabase key has insert privileges.
  • If you get Supabase connection errors: check SUPABASE_URL and SUPABASE_KEY in .env and that environment variables are loaded.

SQL migration file (optional)

If you want, I can add a small SQL migration file (e.g., migrations/create_tables.sql) to the repo containing the table statements above.

Contact / Support

If you need help setting up Supabase or wiring secure auth, open an issue or contact:

gokuldatthubandi@gmail.com


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages