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.
This commit is contained in:
2025-09-19 19:02:15 +02:00
parent cb326f7190
commit 2c5461b0e0
12 changed files with 574 additions and 236 deletions

View File

@@ -47,9 +47,12 @@ This repository contains a minimal demo of a queue system for high-concurrency t
Files added in this demo:
- `app/api/socketio/route.js` — Next.js App Router API route that initializes the Socket.IO server, in-memory queue logic and JWT issuance (demo only).
- `.env.example` — example environment variables for the queue system.
- `app/page.tsx` — client UI (Next.js) that connects via Socket.IO and displays queue position, estimated wait, and purchase button.
- `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:
@@ -58,20 +61,35 @@ Important notes and limitations:
Running locally
1. Copy `.env.example` to `.env` and adjust values (especially `JWT_SECRET`).
2. Install dependencies (already included in package.json):
1. **Setup MySQL Database:**
```sql
-- Execute the schema in database/schema.sql
mysql -u root -p < database/schema.sql
```
```powershell
pnpm install
```
2. **Environment Configuration:**
Copy `.env.example` to `.env` and configure your settings:
```bash
cp .env.example .env
```
Update the MySQL connection details and JWT secret.
3. Start the Next.js dev server:
3. **Install Dependencies:**
```powershell
pnpm install
```
```powershell
pnpm dev
```
4. **Start the Application:**
```powershell
pnpm dev
```
4. Open `http://localhost:3000` - the page will automatically initialize the Socket.IO server via API call to `/api/socketio`, then connect to it on port 4000.
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