devbeni 2c5461b0e0 Refactor socket handling and integrate database for event management
- Removed old socket handling code and replaced it with a new implementation in `app/api/socketio/route.js`.
- Added MySQL database integration for managing active sessions and queue entries.
- Implemented event retrieval and ticket purchasing APIs in `app/api/events/route.js` and `app/api/purchase/route.js`.
- Created database schema for events, tickets, active sessions, and orders in `database/schema.sql`.
- Updated front-end to handle event data fetching and ticket purchasing with improved UI components.
- Removed unused SVG files from the public directory.
2025-09-19 19:02:15 +02:00
2025-09-19 18:39:35 +02:00

This is a Next.js project bootstrapped with create-next-app.

Getting Started

First, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.

This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.

Queue / Ticketing demo (WebSocket + JWT)

This repository contains a minimal demo of a queue system for high-concurrency ticket sales. Key ideas:

  • When an event reaches a concurrency threshold (e.g. 100 users), the server enables a queue for that event.
  • Users connect via WebSocket (Socket.IO). When queueing is active they are placed in a FIFO queue.
  • The server grants access (issues a signed JWT) to up to CONCURRENT_ACTIVE users (default 50) at a time.
  • The JWT is valid for a short period (default 15 minutes). When it expires the server revokes access and grants the next users in queue.
  • The client uses the JWT to authenticate purchase API calls.

Files added in this demo:

  • app/api/socketio/route.js — Next.js App Router API route that initializes the Socket.IO server, queue logic and JWT issuance with MySQL persistence.
  • app/api/events/route.js — API for fetching event and ticket information from MySQL.
  • app/api/purchase/route.js — API for processing ticket purchases with JWT verification.
  • database/schema.sql — MySQL database schema with tables for events, tickets, queue, orders, and active sessions.
  • .env.example — example environment variables for the queue system and MySQL connection.
  • app/page.tsx — modern, responsive client UI that connects via Socket.IO and provides a full ticket purchasing experience.

Important notes and limitations:

  • The server implementation in server/index.js is an in-memory demo. For production use a shared, persistent store (Redis) for queue/locks and a robust MySQL schema if you need persistence.
  • Add authentication, rate-limiting, and persistent sessions before using in production.

Running locally

  1. Setup MySQL Database:

    -- Execute the schema in database/schema.sql
    mysql -u root -p < database/schema.sql
    
  2. Environment Configuration: Copy .env.example to .env and configure your settings:

    cp .env.example .env
    

    Update the MySQL connection details and JWT secret.

  3. Install Dependencies:

    pnpm install
    
  4. Start the Application:

    pnpm dev
    
  5. Access the Application: Open http://localhost:3000 - the page will automatically:

    • Initialize the Socket.IO server via /api/socketio
    • Connect to the queue system on port 4000
    • Load event and ticket data from MySQL
    • Provide a modern, responsive ticket purchasing interface

Next steps / improvements

  • Move queue state to Redis (ZSET) to support multiple server instances.
  • Persist issued tokens and sessions in DB to support revocation and auditing.
  • Add server-side validation of the JWT on purchase endpoints.
  • Add tests around queue promotion logic and token expiration.
Description
No description provided
Readme 254 KiB
Languages
TypeScript 53%
JavaScript 45.7%
CSS 1.3%