Event & Ticket Booking Platform
A scalable, modular backend platform for managing community events, ticket reservations with seat-count inventory, and role-based event organization.
⚠️ CRITICAL EVALUATION RULE (ZERO-MARK POLICY): You must follow this assignment specification strictly. Every API endpoint path, HTTP method, access criteria, request header, request body key (snake_case), and response body structure must match this document 100%. Because your submission will be evaluated using automated testing scripts, any deviation from the specified endpoints, methods, access criteria, headers, request bodies, or response structures will result in 0 Marks.
| Technology / Concept | Requirement & Note |
|---|---|
| Node.js | LTS runtime (22.x or 24.x) |
| TypeScript | Strict mode enabled (strict: true, which includes noImplicitAny), latest stable version |
| Express.js | Feature-based (modular) & Layered architecture (route → controller → service → repository). The repository layer is optional |
| Express Version | Express 5.x |
| PostgreSQL | Relational database using native pg (Pool) driver. No ORMs allowed. |
| Raw SQL | Parameterized queries (pool.query($1, $2)) mandatory for every database operation to completely prevent SQL injection. Never concatenate user input into SQL. |
| bcrypt | Password hashing (salt rounds between 8 and 12) |
| jsonwebtoken | JWT generation & verification |
| Zod (Optional) | Request body, query parameter and path parameter validation via custom validation middleware |
| Error Handling | Centralized error-handling middleware utilizing a custom AppError class |
| Role | Allowed Actions |
|---|---|
| attendee | • Register and log in • Browse and search events (all events are publicly visible; there is no draft/published state) • Book tickets for events (with automatic available seat validation & price calculation) • View own booking history & cancel own bookings |
| organizer | • All attendee permissions, except booking tickets for their own events (rejected with 403)• Create, update, and delete their own organized events |
| Field | Constraint / Rules | Description |
|---|---|---|
id |
Primary Key | Unique identifier for each account |
name |
Required | Full display name of the user |
email |
Unique, Required | Unique login email address |
password |
Required | Hashed password string (never returned in responses) |
role |
Default: attendee, Required, must be attendee or organizer |
Access control role |
created_at |
Auto Timestamp | Account creation timestamp |
updated_at |
Auto Timestamp | Last update timestamp |
| Field | Constraint / Rules | Description |
|---|---|---|
id |
Primary Key | Unique identifier for each event |
title |
Required | Headline title of the event |
description |
Required | Detailed description of the event |
category |
Required | Category tag (e.g., tech, music, workshop) |
date |
Required | Scheduled date and time |
location |
Required | Venue location or online link |
total_seats |
Required, must be greater than 0 | Maximum ticket capacity |
available_seats |
Required, never below 0 and never above total_seats |
Current available seats (initialized equal to total_seats on create; recalculated on updates, see Update Event) |
price |
Required, must be 0 or greater, decimal with 2 places | Price per single ticket |
organizer_id |
Foreign Key (References users.id), Required |
Links the event to the organizing user |
created_at |
Auto Timestamp | Event creation timestamp |
updated_at |
Auto Timestamp | Event update timestamp |
| Field | Constraint / Rules | Description |
|---|---|---|
id |
Primary Key | Unique identifier for each booking |
event_id |
Foreign Key (References events.id), Required |
Links the booking to the event. Cancelled bookings are removed together with their event (cascade delete). Events with confirmed bookings cannot be deleted. |
attendee_id |
Foreign Key (References users.id), Required |
Links the booking to the attending user |
tickets_booked |
Required, must be greater than 0 | Number of seats reserved |
total_price |
Required, decimal with 2 places | Automatically calculated as tickets_booked * event.price |
status |
Default: confirmed, Required, must be confirmed or cancelled |
Booking state |
created_at |
Auto Timestamp | Booking creation timestamp |
updated_at |
Auto Timestamp | Booking update timestamp |
🕒 Timestamps:
created_atandupdated_atare set automatically on insert.updated_atmust also be refreshed whenever a record is updated (event update, booking cancel, seat changes).
💡 Database integrity: Enforce the rules above at the database level too, using
CHECK,UNIQUE,NOT NULLand foreign key constraints, in addition to your application checks.
📌 Note on Relational Queries (
JOINvs. Multiple Queries): Where an endpoint requires related data from another table (such asorganizerdetails on a single event oreventdetails on user bookings), you may either use a SQLJOINquery or execute separate queries on multiple tables and combine/structure the data using JavaScript/TypeScript object manipulation. Both approaches are fully allowed.
- JWT payload:
{ "id": <user id>, "role": "<role>" }. - Environment variables:
DATABASE_URL,JWT_SECRET,JWT_EXPIRES_IN(e.g.7d),PORT. - Header: every protected endpoint expects the token in the
Authorizationheader. The auth middleware must accept bothAuthorization: Bearer <JWT_TOKEN>andAuthorization: <JWT_TOKEN>. - Missing, malformed, expired or invalid token →
401. - Valid token but wrong role →
403. req.user: after verifying the token, the auth middleware attaches the decoded payload (id,role) toreq.user. Since Express'sRequesttype has nouserproperty, extend the type once (for example with a TypeScript declaration file) soreq.usercompiles under strict mode.- For endpoints that use a resource id (
:id), check that the resource exists first (404), then check ownership/permission (403).
- Endpoint:
POST /api/v1/auth/signup - Access: Public
- Request Body:
roleis optional and defaults toattendeewhen omitted. Onlyattendeeandorganizerare accepted.{ "name": "Sarah Connor", "email": "sarah@eventhive.com", "password": "securePassword123", "role": "organizer" } - Success Response (201 Created):
{ "success": true, "message": "User registered successfully", "data": { "id": 1, "name": "Sarah Connor", "email": "sarah@eventhive.com", "role": "organizer", "created_at": "2026-11-15T09:00:00.000Z", "updated_at": "2026-11-15T09:00:00.000Z" } } - Error Cases:
400validation failure ·409email already registered
- Endpoint:
POST /api/v1/auth/login - Access: Public
- Request Body:
{ "email": "sarah@eventhive.com", "password": "securePassword123" } - Success Response (200 OK):
{ "success": true, "message": "Login successful", "data": { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "user": { "id": 1, "name": "Sarah Connor", "email": "sarah@eventhive.com", "role": "organizer" } } } - Error Cases:
400validation failure ·401invalid email or password (use the same message for both cases)
- Endpoint:
POST /api/v1/events - Access: Protected (
organizerrole only) - Headers:
Authorization: Bearer <JWT_TOKEN>(orAuthorization: <JWT_TOKEN>) - Request Body:
{ "title": "TypeScript Advanced Architecture", "description": "Deep dive into enterprise TS patterns and modular design.", "category": "tech", "date": "2026-12-10T10:00:00.000Z", "location": "Dhaka Tech Hub", "total_seats": 50, "price": 1500.00 } - Success Response (201 Created):
{ "success": true, "message": "Event created successfully", "data": { "id": 1, "title": "TypeScript Advanced Architecture", "description": "Deep dive into enterprise TS patterns and modular design.", "category": "tech", "date": "2026-12-10T10:00:00.000Z", "location": "Dhaka Tech Hub", "total_seats": 50, "available_seats": 50, "price": "1500.00", "organizer_id": 1, "created_at": "2026-11-15T10:30:00.000Z", "updated_at": "2026-11-15T10:30:00.000Z" } }💡 Developer Hint: Extract
organizer_idsecurely from the decoded JWT token (req.user.id), never from the request body. Initializeavailable_seats = total_seats. - Error Cases:
400validation failure ·401missing/invalid token ·403caller is not an organizer
- Endpoint:
GET /api/v1/events(orGET /api/v1/events?search=TypeScript) - Access: Public
- Query Parameters & Rules:
search(optional): Case-insensitive partial match (ILIKE) ontitleordescription. When omitted, return all events ordered bycreated_atdescending (newest first).
- Success Response (200 OK):
{ "success": true, "message": "Events retrieved successfully", "data": [ { "id": 1, "title": "TypeScript Advanced Architecture", "description": "Deep dive into enterprise TS patterns and modular design.", "category": "tech", "date": "2026-12-10T10:00:00.000Z", "location": "Dhaka Tech Hub", "total_seats": 50, "available_seats": 50, "price": "1500.00", "organizer_id": 1, "created_at": "2026-11-15T10:30:00.000Z", "updated_at": "2026-11-15T10:30:00.000Z" } ] }💡 An empty result returns
200with"data": [].
- Endpoint:
GET /api/v1/events/:id - Access: Public
- Success Response (200 OK):
{ "success": true, "message": "Event retrieved successfully", "data": { "id": 1, "title": "TypeScript Advanced Architecture", "description": "Deep dive into enterprise TS patterns and modular design.", "category": "tech", "date": "2026-12-10T10:00:00.000Z", "location": "Dhaka Tech Hub", "total_seats": 50, "available_seats": 50, "price": "1500.00", "organizer_id": 1, "organizer": { "id": 1, "name": "Sarah Connor", "email": "sarah@eventhive.com" }, "created_at": "2026-11-15T10:30:00.000Z", "updated_at": "2026-11-15T10:30:00.000Z" } }💡 Developer Hint: If you are comfortable with SQL
JOIN, you can fetch the event and organizer in a single query. Otherwise, query theeventstable first, then query theuserstable byorganizer_id, and attach theorganizerobject using JavaScript/TypeScript object manipulation. - Error Cases:
400invalid id ·404event not found
- Endpoint:
PATCH /api/v1/events/:id - Access: Protected (
organizerrole who created the event; any other user gets403) - Headers:
Authorization: Bearer <JWT_TOKEN>(orAuthorization: <JWT_TOKEN>) - Updatable fields:
title,description,category,date,location,total_seats,price(at least one required). - Request Body:
{ "title": "TypeScript Masterclass", "total_seats": 60 }💡 Developer Hint: Only the fields present in the request body should be changed. Build the
SETpart of yourUPDATEquery dynamically from the provided fields, and keep every value parameterized ($1, $2, ...). Never insert user input directly into the SQL text.⚠️ Business Rule (Seat Adjustment): Count the confirmed tickets already sold for the event (the sum oftickets_bookedfor its bookings with statusconfirmed). Whentotal_seatsis updated, setavailable_seats = new_total_seats - sold. Iftotal_seatsis not part of the request,available_seatsstays unchanged. If that value would be negative (the new total is lower than the tickets already sold), reject with400 Bad Request.Example: an event has 50 seats and 10 are sold. Updating
total_seatsto 60 givesavailable_seats = 50.Changing
priceaffects only future bookings. Existing bookings keep their originaltotal_price. - Success Response (200 OK): (the example assumes no tickets have been sold yet)
{ "success": true, "message": "Event updated successfully", "data": { "id": 1, "title": "TypeScript Masterclass", "description": "Deep dive into enterprise TS patterns and modular design.", "category": "tech", "date": "2026-12-10T10:00:00.000Z", "location": "Dhaka Tech Hub", "total_seats": 60, "available_seats": 60, "price": "1500.00", "organizer_id": 1, "created_at": "2026-11-15T10:30:00.000Z", "updated_at": "2026-11-15T11:00:00.000Z" } } - Error Cases:
400validation failure / empty body /total_seatsbelow tickets sold ·401·403not the owner ·404event not found
- Endpoint:
DELETE /api/v1/events/:id - Access: Protected (
organizerrole who created the event) - Headers:
Authorization: Bearer <JWT_TOKEN>(orAuthorization: <JWT_TOKEN>) - Business Rule: Before deleting, check whether the event has any bookings with status
confirmed. If any exist, prohibit deletion and return400 Bad Requestto preserve booking history. Otherwise delete the event. Any remainingcancelledbookings of that event are removed together with it (cascade delete). - Success Response (200 OK):
{ "success": true, "message": "Event deleted successfully", "data": null } - Error Cases:
400event has confirmed bookings ·401·403not the owner ·404event not found
- Endpoint:
POST /api/v1/bookings - Access: Protected (
attendeeororganizer) - Headers:
Authorization: Bearer <JWT_TOKEN>(orAuthorization: <JWT_TOKEN>) - Request Body:
{ "event_id": 1, "tickets_booked": 2 } - Business Rules:
- Find the event by
event_id. If not found, return404 Not Found. - If the event's
organizer_idequalsreq.user.id, return403 Forbidden(organizers cannot book their own events). - If the event
datehas already passed, return400 Bad Request. - Check if
available_seats >= tickets_booked. If insufficient, return400 Bad Request(Sold Out / Insufficient seats). - Calculate
total_price = event.price * tickets_booked. - Decrement
available_seatson the event and insert the booking record with statusconfirmed.
- Find the event by
- Success Response (201 Created):
{ "success": true, "message": "Tickets booked successfully", "data": { "id": 1, "event_id": 1, "attendee_id": 2, "tickets_booked": 2, "total_price": "3000.00", "status": "confirmed", "created_at": "2026-11-15T11:15:00.000Z", "updated_at": "2026-11-15T11:15:00.000Z" } } - Error Cases:
400validation failure / insufficient seats / event already passed ·401·403organizer booking own event ·404event not found
- Endpoint:
GET /api/v1/bookings - Access: Protected (any authenticated user; returns only the bookings of
req.user.id, newest first) - Headers:
Authorization: Bearer <JWT_TOKEN>(orAuthorization: <JWT_TOKEN>) - Success Response (200 OK):
{ "success": true, "message": "Bookings retrieved successfully", "data": [ { "id": 1, "event": { "id": 1, "title": "TypeScript Masterclass", "date": "2026-12-10T10:00:00.000Z", "location": "Dhaka Tech Hub" }, "tickets_booked": 2, "total_price": "3000.00", "status": "confirmed", "created_at": "2026-11-15T11:15:00.000Z" } ] }💡 Developer Hint: You can populate the nested
eventobject using a SQLJOIN, or by querying the user's bookings first, fetching the matching events from theeventstable, and structuring the nestedeventobject using JavaScript/TypeScript object manipulation. An empty list returns200with"data": []. - Error Cases:
401missing/invalid token
- Endpoint:
PATCH /api/v1/bookings/:id/cancel - Access: Protected (any authenticated user, attendee or organizer, who owns the booking)
- Headers:
Authorization: Bearer <JWT_TOKEN>(orAuthorization: <JWT_TOKEN>) - Business Rules:
- Find the booking. If it does not exist, return
404 Not Found. If it exists butattendee_idis notreq.user.id, return403 Forbidden. - If the booking status is already
cancelled, return409 Conflict. - If the event
datehas already passed, return400 Bad Request(a booking cannot be cancelled after the event has started). - Update the booking status to
cancelledand addtickets_bookedback to the event'savailable_seats.
- Find the booking. If it does not exist, return
- Success Response (200 OK):
{ "success": true, "message": "Booking cancelled successfully", "data": { "id": 1, "event_id": 1, "attendee_id": 2, "tickets_booked": 2, "total_price": "3000.00", "status": "cancelled", "created_at": "2026-11-15T11:15:00.000Z", "updated_at": "2026-11-15T12:00:00.000Z" } } - Error Cases:
400invalid id / event already passed ·401·403booking belongs to another user ·404booking not found ·409already cancelled
- Standard Success Response Structure:
{ "success": true, "message": "Operation description", "data": {} } - Standard Error Response Structure:
{ "success": false, "message": "Validation Error", "errors": [{ "field": "tickets_booked", "message": "Must be at least 1" }] }Business-rule failures (for example sold out, or deletion blocked) return a clear
messagesuch as"Insufficient available seats for this event". Theerrorsarray is optional for them. Never expose stack traces or raw SQL errors. - HTTP Status Codes Reference:
200 OK: SuccessfulGET,PATCH,DELETErequests.201 Created: SuccessfulPOSTrequest resulting in resource creation.400 Bad Request: Zod validation failure, invalid input, sold-out/insufficient seats, booking or cancelling for an event that already passed,total_seatslower than tickets sold, or deletion prohibited due to active bookings.401 Unauthorized: Missing, expired, or invalid JWT token.403 Forbidden: Valid token but insufficient role permissions, an organizer booking their own event, or attempting to access/modify resources owned by another user.404 Not Found: Requested resource (event,booking,user) does not exist.409 Conflict: Duplicate unique email, or conflicting state (e.g., cancelling an already cancelled booking).500 Internal Server Error: Unexpected server or database failure.
Example structure for a feature-based layered/moduler architecture (route → controller → service → repository). Adjust or add files as needed:
├── README.md
├── package.json
├── tsconfig.json
└── src/
├── app.ts
├── server.ts
├── config/
│ ├── db.ts
│ └── env.ts
├── middleware/
│ ├── auth.middleware.ts
│ └── error.middleware.ts
├── utils/
└── modules/
├── auth/
├── event/
└── booking/
Each module contains its own route, controller, service, and other nedded files.
Questions:
- JWT Authentication Flow: How do JSON Web Tokens work for stateless authentication, and how do you securely verify them in Express middleware?
- Role-Based Authorization: Explain how you implement role-based access control (RBAC) middleware to restrict event creation to
organizeraccounts versusattendeeaccounts. - SQL Injection & Parameterized Queries: How does SQL injection happen in raw SQL queries, and how do parameterized queries (
$1, $2) inpgprevent it? - Database Connection Pooling: What is database connection pooling (
pg.Pool) in PostgreSQL, and why is it preferred over opening and closing a single client connection for every request? - Centralized Error Handling: How does a 4-parameter centralized error-handling middleware catch both synchronous and asynchronous errors across your layered architecture?
Recording Instructions:
- Use your smartphone selfie camera or laptop webcam in landscape (horizontal) mode.
- Record in a well-lit, quiet room with your face fully visible throughout the video.
- Select and answer any 2 questions from the list above.
- Keep each answer between 2–4 minutes. Speak naturally from your understanding. Avoid reading verbatim from notes or scripts.
- Upload your video to Google Drive (set access to "Anyone with the link") or YouTube (Unlisted), and include the public link in your submission and
README.md.
- Strict Specification Adherence (Zero-Mark Warning): You must follow the exact API endpoint paths, HTTP methods, access criteria, headers, request body structure, and response body structure specified in this document. Any deviation will cause automated evaluation tests to fail and result in 0 Marks.
- API Documentation (
README.md): Include a well-structuredREADME.mdwith project overview, live deployment URL, setup instructions, environment variable example (.env.example), interview video link, and complete API endpoint documentation.
- Deploy backend to Render, Railway, or Vercel.
- Host PostgreSQL database on NeonDB, Supabase, or Aiven.
✅ GitHub Repo (Public): https://github.com/yourusername/eventhive-api
✅ Live Deployment (Public): https://eventhive-api.onrender.com
✅ Interview Video (Public): https://drive.google.com/... or https://youtu.be/...
💡 Pro Tips: Ensure your repository has at least 10 meaningful commits showing progressive development. Double-check all links in an incognito window before submitting.
- Assignment Release: November 26, 2026 – 8:00 PM (Thursday)
- 60 Marks Deadline: December 02, 2026 – 11:59 PM (Wednesday)
- 50 Marks Deadline: December 03, 2026 – 11:59 PM (Thursday)
- 30 Marks Deadline: December 03, 2026 (after 11:59 PM) to December 24, 2026 – before 11:59 PM (Next 21 Days)
- Plagiarism will not be tolerated. All submissions must be your original work.
- Copied repositories, or interview answers read out verbatim from AI-generated or other pre-written scripts, will result in 0 Marks. You may be asked to explain any part of your code.