SmartQueue – Web-Based Appointment & Queue Management System
➡️ Customers can view and book available slots ➡️ Receive confirmations via Email or SMS ➡️ Admin can manage the calendar, assign tokens and monitor real-time queue status
🔥 AI is integrated to predict peak booking slots available based on previous data
🔥 QR Code System that will allow fast check-ins at the front desk improving efficiency.
AI-driven appointment and queue management system for clinics and small service businesses.
- Frontend: Next.js, React, TypeScript, Tailwind CSS
- Backend: Node.js, Express, TypeScript, Mongoose
- Database: MongoDB
- Authentication: JWT and bcrypt
- QR:
qrcodegeneration andhtml5-qrcodescanning - Email: SendGrid, optional in local development
| Service | URL |
|---|---|
| Frontend | http://localhost:3000 |
| Backend API | http://localhost:5000 |
| API health | http://localhost:5000/api/health |
| MongoDB | mongodb://localhost:27017/SmartQueue |
Backend:
cd backend
npm.cmd install
npm.cmd run seed
npm.cmd run migrate
npm.cmd run devSeed creates or updates:
| Account | Password | |
|---|---|---|
| Admin | admin@smartqueue.local |
admin123 |
| Demo customer | customer@smartqueue.local |
customer123 |
It also creates the four default consultation types: General, Emergency, Specialist, and Follow-up Consultation.
Frontend:
cd frontend
npm.cmd install
npm.cmd run devEnvironment files:
# backend/.env
PORT=5000
MONGO_URI=mongodb://localhost:27017/SmartQueue
JWT_SECRET=change-this-before-deployment
JWT_EXPIRES_IN=7d
CLIENT_URL=http://localhost:3000
ADMIN_EMAIL=admin@smartqueue.local
ADMIN_PASSWORD=admin123
SENDGRID_API_KEY=
SENDGRID_FROM_EMAIL=# frontend/.env.local
NEXT_PUBLIC_API_URL=http://localhost:5000/apiCustomer:
- Register with full name, email, phone number, and password.
- Log in to receive a JWT.
- Choose a consultation type and available slot.
- Book an appointment and receive an appointment ID, daily token, and QR code.
- View the booking and QR code in the dashboard.
- Check in using the QR code; only then does the token enter the live waiting queue.
Admin:
- Log in through
/admin/loginusing credentials configured inbackend/.env. - View dashboard totals, current token, next token, waiting customers, and completed consultations.
- Filter appointments by consultation type, status, date, or search term.
- Scan customer QR codes at check-in.
- Move waiting customers to serving and served states.
- Manage consultation types in the services screen.
| Collection | Purpose |
|---|---|
users |
Customer and admin accounts with hashed passwords and roles |
services |
Consultation types, duration, active/inactive status |
appointments |
Bookings, readable appointment code, slot, QR, lifecycle status |
queues |
Daily token and live queue state |
checkinlogs |
QR/manual check-in audit history |
notifications |
Confirmation and queue alert delivery records |
Internal Service records represent consultation types in the user interface.
Appointment lifecycle:
booked -> checked-in -> in-service -> completed
\-> cancelledQueue lifecycle:
booked -> waiting -> serving -> served
\-> cancelledAn appointment receives its token at booking, but enters the active queue only after check-in.
All responses use:
{
"success": true,
"message": "Readable result message",
"data": {}
}Customer API:
| Method | Endpoint | Purpose |
|---|---|---|
POST |
/api/customer/auth/register |
Register customer |
POST |
/api/customer/auth/login |
Login and receive JWT |
POST |
/api/customer/auth/logout |
Logout acknowledgement |
GET |
/api/customer/services |
List consultation types |
GET |
/api/customer/appointments/availability |
List available slots |
POST |
/api/customer/appointments |
Book appointment |
GET |
/api/customer/appointments |
View own bookings |
PATCH |
/api/customer/appointments/:id |
Reschedule a booked appointment |
PATCH |
/api/customer/appointments/:id/cancel |
Cancel a booking |
GET |
/api/customer/queue |
View own token states |
GET |
/api/customer/queue/status/:appointmentId |
View a token state |
POST |
/api/customer/qr/check-in |
Check in from QR |
Admin API:
| Method | Endpoint | Purpose |
|---|---|---|
POST |
/api/admin/auth/login |
Admin login |
POST |
/api/admin/auth/logout |
Logout acknowledgement |
GET |
/api/admin/dashboard |
Summary and live tokens |
GET |
/api/admin/appointments |
Filterable bookings |
PATCH |
/api/admin/appointments/:id/status |
Update consultation status |
PATCH |
/api/admin/appointments/:id/cancel |
Cancel appointment |
GET |
/api/admin/queue |
Active checked-in queue |
PATCH |
/api/admin/queue/:id |
Advance queue state |
POST |
/api/admin/qr/check-in |
Staff QR check-in |
GET |
/api/admin/check-in-logs |
Check-in audit log |
GET |
/api/admin/analytics |
Operational analytics |
GET/POST/PATCH/DELETE |
/api/admin/services |
Consultation type management |
backend/src/
config/ environment and MongoDB connection
controllers/ HTTP request/response handling
middleware/ auth, roles, validation, errors, rate limiting
models/ Mongoose schemas
routes/ separate customer/admin API surfaces
services/ queue and QR business logic
scripts/ seed and migration commands
utils/ tokens, QR generation, API response helpers
frontend/
app/ Next.js pages and role dashboards
app/components reusable shells, toast, confirmation, QR scanner
lib/ typed API/session integrationcd backend
npm.cmd run typecheck
cd ../frontend
npm.cmd run buildEnd-to-end API smoke test:
- Start MongoDB locally.
- Run
npm.cmd run seedandnpm.cmd run migrateinbackend. - Start the backend with
npm.cmd run dev; it must listen onhttp://localhost:5000. - Start the frontend with
npm.cmd run dev; it must listen onhttp://localhost:3000. - Open
http://localhost:5000/api/healthand confirm a successful response. - Import SmartQueue.postman_collection.json into Postman.
- Run the collection from top to bottom.
Postman books a same-day appointment because QR check-in is intentionally allowed only on the scheduled appointment date. If all same-day slots have already passed, run the flow through the frontend for a future booking and perform check-in on that date, or temporarily test earlier in the business day.
Recommended UI demo path:
- Register or log in as a customer at
http://localhost:3000/login. - Book a consultation from
/book-appointment. - Confirm the appointment appears with QR details in
/dashboard. - Log in as admin at
http://localhost:3000/admin/login. - Use
/admin/check-into scan or paste the QR payload. - Move the token through waiting, serving, and served from
/admin/queue.
- Set strong
JWT_SECRETand admin credentials through environment variables. - Configure SendGrid to send email confirmations; local operation safely leaves notifications pending when email is disabled.
- Restrict CORS through
CLIENT_URL; local defaults are fixed to frontend port3000. - Rate limiting protects authentication routes.
- MongoDB indexes prevent active double-booking and duplicate daily tokens.
- Run
npm.cmd run migrateafter schema/workflow changes before deployment.