A RESTful API for an Event Ticketing System built with Node.js, Express, and MongoDB. Deployed on Render.com, it supports user authentication, event management, ticket bookings with QR code generation, email confirmations, and admin analytics.
- User & Admin Roles: Secure JWT authentication and role-based access control.
- Event Management: Create, Read, Update, Delete (CRUD) events with filtering by category, date, and venue.
- Ticket Booking: Validate seat availability, generate QR codes, and receive email confirmation.
- QR Validation: Public endpoint to validate tickets by QR code.
- Admin Dashboard: Analytics view of events with booking summaries.
- Error Handling: Global middleware for JSON and HTML 404 responses based on
Acceptheader.
- Runtime: Node.js
- Server: Express
- Database: MongoDB + Mongoose
- Authentication: JWT + bcrypt.js
- QR Codes:
qrcodepackage - Email: Nodemailer + SendGrid/Ethereal
- Deployment: Render.com
- Node.js v14+ installed
- npm or yarn
- MongoDB instance (local or MongoDB Atlas)
-
Clone the repository:
git clone https://github.com/Seththaro/HOUR_INF653_event-ticketing-api.git cd HOUR_INF653_event-ticketing-api -
Install dependencies:
npm install
Create a .env file based on the .env.example in the project root:
PORT=5000
MONGODB_URI=<your_mongodb_connection_string>
JWT_SECRET=<your_jwt_secret>
# Email (SendGrid SMTP)
EMAIL_HOST=smtp.sendgrid.net
EMAIL_PORT=587
EMAIL_USER=apikey
EMAIL_PASS=SG.your_sendgrid_api_keynpm run dev- Start the server with nodemon for development.npm start- Start the server in production mode.
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
Register a new user |
| POST | /api/auth/login |
Authenticate user and receive JWT |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/events |
List all events (filters: ?category=, ?date=, ?venue=) |
| GET | /api/events/:id |
Get details of a single event |
| POST | /api/events |
Create an event (admin only) |
| PUT | /api/events/:id |
Update an event (admin only) |
| DELETE | /api/events/:id |
Delete an event (admin only) |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/bookings |
Book tickets (user only) |
| GET | /api/bookings |
List bookings for the current user |
| GET | /api/bookings/:id |
Get details of a specific booking |
| GET | /api/bookings/validate/:qr |
Validate a ticket by QR code (public) |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/admin/dashboard |
View events with booking-user analytics (admin only) |
Use the provided api.http file with the VS Code REST Client extension or Postman to run through all endpoints, including edge cases and error scenarios.
-
Push your code to GitHub.
-
On Render.com, create a new Web Service linked to this repository.
-
Set environment variables in the Render dashboard as shown above.
-
Deploy and access your API at:
https://tharoeventicketing.onrender.com
Watch the full demo on YouTube:
- GitHub Repository: https://github.com/Seththaro/HOUR_INF653_event-ticketing-api.git
- YouTube Demo: YOUR_YOUTUBE_VIDEO_LINK
This project is licensed under the MIT License. Feel free to use and modify.