Skip to content

kmredosendo/queue-management-system

Repository files navigation

Queue Management System

A comprehensive, production-ready queueing system for multi-lane service environments. Built with Next.js 15, TypeScript, Tailwind CSS, shadcn/ui, and MySQL (Prisma ORM).


πŸš€ Features

User Roles

  • Admin: Full dashboard access, manage users and lanes
  • User (Cashier/Staff): Queue operations for assigned lanes (Next, Call, Buzz, Serve)
  • Display: Real-time display of all active lanes and queue status
  • Reservation: Customer-facing interface to get queue numbers and wait times

Core Functions

  • Admin Dashboard: Manage lanes, users, assignments, and view live stats
  • Queue Operations: Advance, call, buzz, and serve queue numbers (per lane, per day, with daily reset)
  • Reservation System: Customers select a lane, get a queue number, and see estimated wait
  • Display System: Shows all active lanes, current/next numbers, and queue status in real time
  • Role-based Authentication: Custom, secure, no third-party providers
  • Daily Reset: Queue numbers and stats are always based on today’s operations only
  • Responsive UI: Built with shadcn/ui and Tailwind CSS for a modern, accessible experience
  • Physical Ticket Printing: Print queue tickets for customers (if printer is connected)
  • Real-Time Updates: All interfaces update automatically for live queue status

Tech Stack

  • Frontend: Next.js 15 (App Router), TypeScript, Tailwind CSS, shadcn/ui
  • Backend: Next.js API routes, Prisma ORM
  • Database: MySQL
  • Authentication: Custom JWT-based

πŸ› οΈ Getting Started

Prerequisites

  • Node.js 18+
  • MySQL

Installation

git clone <repo-url>
cd queue
npm install

Environment Setup

Copy .env.example to .env and update DB credentials and secrets.

Database Setup

npm run db:generate
npm run db:push
npm run db:seed

Development

npm run dev

Production Build

npm run build
npm run build:production

πŸ§‘β€πŸ’» Demo Users (Default Seed)

  • Admin: admin / admin123
  • Cashier 1: c1 / 123
  • Cashier 2: c2 / 123

🏒 Demo Lanes (Default Seed)

  • Regular Lane: General queue for all customers
  • PWD Lane: Priority for PWDs and Senior Citizens

πŸ—‚οΈ Project Structure

src/
  app/
    admin/         # Admin dashboard
    user/          # Cashier interface
    display/       # Display screens
    reservation/   # Customer reservation
    api/           # API routes
  components/
    ui/            # shadcn/ui components
  lib/             # Auth, Prisma, utils
prisma/            # Prisma schema & migrations
public/            # Static assets
scripts/           # Seed and utility scripts

πŸ”— Key API Endpoints

  • POST /api/auth/login β€” Login
  • POST /api/auth/logout β€” Logout
  • GET /api/lanes β€” List all lanes (today's stats)
  • GET /api/queue/reservation β€” Lane status for reservation (today only)
  • POST /api/queue/reservation β€” Get a new queue number
  • POST /api/queue/operations β€” Queue actions (Next, Call, Buzz, Serve)
  • GET /api/users/assigned-lanes β€” Lanes assigned to current user (today only)

πŸ“ Development Scripts

  • npm run dev β€” Start dev server
  • npm run build β€” Build for production
  • npm run build:production β€” Create deployable package
  • npm run db:generate β€” Generate Prisma client
  • npm run db:push β€” Push schema to DB
  • npm run db:seed β€” Seed DB with demo data

πŸ—οΈ Database Entities

  • User: System users (admin, cashier, etc.)
  • Lane: Service lanes (regular, PWD, etc.)
  • LaneUser: Assignment of users to lanes
  • QueueItem: Queue entries (per lane, per day)

πŸ“¦ Production Deployment (Linux/Ubuntu + PM2)

Server Requirements

  • Node.js 18+, MySQL, PM2, Apache with mod_proxy
  • Prisma binary targets set for Linux in prisma/schema.prisma:
    binaryTargets = ["native", "debian-openssl-3.0.x"]

Steps

  1. Clone/copy the project to the server (e.g. /var/www/node/queue)
  2. npm install
  3. Set up .env (see Environment Variables below)
  4. npx prisma generate && npx prisma migrate deploy
  5. npm run build
  6. Configure PM2 in ecosystem.config.js (port, cwd, log paths)
  7. pm2 start ecosystem.config.js && pm2 save

Apache Reverse Proxy

Add to your virtual host config:

ProxyPass "/queue" "http://localhost:3007/queue"
ProxyPassReverse "/queue" "http://localhost:3007/queue"

Environment Variables

DATABASE_URL="mysql://user:password@localhost:3306/queue"
JWT_SECRET="your-secret"
NEXTAUTH_URL="https://yourdomain.com/queue"
NEXT_PUBLIC_BASE_PATH=/queue

Base Path

The app is deployed under /queue. This is configured in next.config.ts:

basePath: '/queue'

All client-side API calls use getApiUrl() from src/lib/api.ts to prepend the base path automatically.


πŸ–¨οΈ Ticket Printing

Printing is handled client-side β€” the browser on the reservation PC calls a local print server directly, so tickets print silently with no dialog regardless of where the app is hosted.

Architecture

Browser (reservation PC) β†’ http://localhost:12345/print β†’ print-server.js β†’ EPSON printer

Setup

  1. Copy scripts/print-server.js to the Windows PC connected to the printer
  2. Install Node.js on that PC
  3. Update PRINTER_NAME in the script to match the exact printer name shown in Devices and Printers
  4. Run: node print-server.js

Autostart (no terminal window)

Option A β€” Task Scheduler (recommended):

  • Open taskschd.msc
  • Create Basic Task β†’ Trigger: At startup β†’ Action: Start node with argument "C:\path\to\print-server.js"
  • In Properties: check Run whether user is logged on or not + Run with highest privileges

Option B β€” Startup folder (hidden window):

  • Press Win + R β†’ shell:startup
  • Create start-print-server.vbs:
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Run "node ""C:\path\to\print-server.js""", 0, False

Browser Compatibility

  • Chrome / Edge: Fully supported (allows http://localhost from HTTPS pages)
  • Firefox: Blocked by default (mixed content policy)

πŸ“¦ Windows Deployment (original)

  1. Run npm run build:production (see production/ folder)
  2. Copy production/ to your server
  3. Run deploy.bat as Administrator

πŸ“„ License

MIT


❀️ Support This Project

If you find this project useful, consider supporting me:

Your support keeps this project alive and maintained!


For questions or support, open an issue in this repository.

About

A comprehensive queueing system built with Next.js, TypeScript, Tailwind CSS, shadcn/ui, and MySQL. The system provides efficient queue management for better customer service across multiple service lanes.

Topics

Resources

Stars

Watchers

Forks

Contributors