Skip to content

DANUCKSAN/emsbackend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Event Management System Backend

A complete Event Management System Backend built with Spring Boot, Java, MySQL, Spring Data JPA, Spring Security, and Spring Mail.

This backend supports user registration, host registration, admin authentication, event creation, event booking, seat selection, MFA verification, dashboards, reviews, approval workflows, cancellation, and refund management.

Overview

The EMS Backend is the server-side application for an Event Management System. It provides REST APIs for clients, hosts, and admins.

Users can register, log in with MFA verification, browse events, book tickets, select seats, manage bookings, cancel bookings, and submit reviews.

Hosts can register, log in with MFA verification, create events, manage their hosted events, view bookings, cancel events, process refunds, and reply to reviews.

Admins can manage users, hosts, events, approvals, and overall platform statistics through admin dashboard APIs.

Features

  • User registration
  • User login with MFA verification
  • Host registration
  • Host login with MFA verification
  • Admin registration and login
  • Admin MFA verification
  • Event creation by hosts
  • View all events
  • View events by host
  • View event details
  • Event approval status workflow
  • User approval workflow
  • Host approval workflow
  • Ticket booking
  • Seat layout generation
  • Selected seat booking
  • Booking cancellation
  • Refund status management
  • Host dashboard statistics
  • Admin dashboard statistics
  • Event reviews
  • Host replies to reviews
  • Public review listing
  • My events / user booking history
  • Email-based MFA support
  • Demo mode for MFA when mail is disabled
  • MySQL database integration
  • REST API architecture
  • CORS support for frontend integration

Tech Stack

  • Java 17
  • Spring Boot 3.5.4
  • Spring Web
  • Spring Data JPA
  • Spring Security
  • Spring Mail
  • MySQL
  • Hibernate
  • Lombok
  • Jakarta Persistence API
  • Jakarta Validation API
  • Maven

Project Structure

emsbackend/
├── .mvn/
├── sql/
│   └── seed_events_50.sql
│
├── src/
│   ├── main/
│   │   ├── java/
│   │   │   └── com/
│   │   │       └── sihe/
│   │   │           └── emsbackend/
│   │   │               ├── config/
│   │   │               │   ├── SecurityConfig.java
│   │   │               │   └── WebConfig.java
│   │   │               │
│   │   │               ├── controller/
│   │   │               │   ├── AdminAuthController.java
│   │   │               │   ├── AdminDashboardController.java
│   │   │               │   ├── AuthController.java
│   │   │               │   ├── BookingController.java
│   │   │               │   ├── EventController.java
│   │   │               │   ├── HostController.java
│   │   │               │   ├── HostDashboardController.java
│   │   │               │   ├── ReviewController.java
│   │   │               │   └── UserController.java
│   │   │               │
│   │   │               ├── dto/
│   │   │               │   ├── HostLoginRequest.java
│   │   │               │   ├── LoginRequest.java
│   │   │               │   ├── MfaChallengeResponse.java
│   │   │               │   └── MfaVerifyRequest.java
│   │   │               │
│   │   │               ├── exception/
│   │   │               │   ├── InvalidCredentialsException.java
│   │   │               │   └── UserNotFoundException.java
│   │   │               │
│   │   │               ├── model/
│   │   │               │   ├── Admin.java
│   │   │               │   ├── Booking.java
│   │   │               │   ├── Event.java
│   │   │               │   ├── Host.java
│   │   │               │   ├── MfaChallenge.java
│   │   │               │   ├── Review.java
│   │   │               │   └── User.java
│   │   │               │
│   │   │               ├── repository/
│   │   │               │   ├── AdminRepository.java
│   │   │               │   ├── BookingRepository.java
│   │   │               │   ├── EventRepository.java
│   │   │               │   ├── HostRepository.java
│   │   │               │   ├── MfaChallengeRepository.java
│   │   │               │   ├── ReviewRepository.java
│   │   │               │   └── UserRepository.java
│   │   │               │
│   │   │               ├── service/
│   │   │               │   ├── AdminService.java
│   │   │               │   ├── EventService.java
│   │   │               │   ├── HostService.java
│   │   │               │   ├── MfaDeliveryService.java
│   │   │               │   ├── MfaService.java
│   │   │               │   ├── NotificationService.java
│   │   │               │   ├── SeatLayoutService.java
│   │   │               │   └── UserService.java
│   │   │               │
│   │   │               └── EmsbackendApplication.java
│   │   │
│   │   └── resources/
│   │       └── application.properties
│   │
│   └── test/
│
├── .gitignore
├── mvnw
├── mvnw.cmd
├── pom.xml
└── README.md

Main Modules

User Module

The user module handles customer-related operations.

Main features:

  • User registration
  • User login
  • MFA verification
  • User profile update
  • Get user by ID
  • User booking history

Host Module

The host module handles event organiser functionality.

Main features:

  • Host registration
  • Host login
  • MFA verification
  • Host profile update
  • Create events
  • Manage hosted events
  • View event bookings
  • Cancel events
  • Manage refunds
  • Reply to reviews

Admin Module

The admin module handles platform management.

Main features:

  • Admin registration
  • Admin login
  • MFA verification
  • View platform dashboard
  • View users, hosts, and events
  • Approve or reject users
  • Approve or reject hosts
  • Approve or reject events

Event Module

The event module handles event-related APIs.

Main features:

  • Create event
  • Get all events
  • Get event by ID
  • Get events by host
  • Get event seat layout
  • Cancel event
  • Track event status
  • Track approval status

Booking Module

The booking module handles ticket booking and cancellation.

Main features:

  • Create booking
  • Assign selected seats
  • Validate ticket quantity
  • Calculate total price on the backend
  • Reduce ticket availability after booking
  • View bookings by user
  • View booking details
  • Cancel booking
  • Mark refund as pending

Review Module

The review module handles customer feedback.

Main features:

  • Create event review
  • Validate rating from 1 to 5
  • View reviews by event
  • View reviews by host
  • View public reviews
  • Host reply to reviews

MFA Module

The MFA module adds an extra verification layer during login.

Main features:

  • Generate verification code
  • Store hashed MFA code
  • Send code using email
  • Demo mode when mail is disabled
  • Verify MFA challenge
  • Expire previous active challenges
  • Prevent reused verification codes

API Endpoints

User APIs

Method Endpoint Description
POST /api/users/register Register a new user
PUT /api/users/{id} Update user details
GET /api/users/{id} Get user by ID

User Authentication APIs

Method Endpoint Description
POST /api/login User login and MFA challenge creation
POST /api/login/verify-mfa Verify user MFA code

Host APIs

Method Endpoint Description
POST /api/hosts/register Register a new host
POST /api/hosts/login Host login and MFA challenge creation
POST /api/hosts/login/verify-mfa Verify host MFA code
PUT /api/hosts/{id} Update host details

Admin APIs

Method Endpoint Description
POST /api/admin/register Register an admin
POST /api/admin/login Admin login and MFA challenge creation
POST /api/admin/login/verify-mfa Verify admin MFA code

Admin Dashboard APIs

Method Endpoint Description
GET /api/admin/dashboard Get admin dashboard data
PATCH /api/admin/dashboard/users/{id}/approval Update user approval status
PATCH /api/admin/dashboard/hosts/{id}/approval Update host approval status
PATCH /api/admin/dashboard/events/{id}/approval Update event approval status

Event APIs

Method Endpoint Description
POST /api/events/create Create a new event
GET /api/events/all Get all events
GET /api/events/{id} Get event by ID
GET /api/events/host/{hostId} Get events by host
GET /api/events/{id}/seat-layout Get event seat layout
DELETE /api/events/{eventId} Cancel an event
GET /api/events/my-events?email=user@example.com Get bookings by user email

Booking APIs

Method Endpoint Description
POST /api/bookings Create a booking
GET /api/bookings/user/{userId} Get bookings by user
GET /api/bookings/layout/{eventId} Get event seat layout
GET /api/bookings/{bookingId} Get booking details
DELETE /api/bookings/{bookingId} Cancel booking

Host Dashboard APIs

Method Endpoint Description
GET /api/host-dashboard/{hostId} Get host dashboard data
PUT /api/host-dashboard/events/{eventId} Update host event
PATCH /api/host-dashboard/events/{eventId}/cancel Cancel host event
PATCH /api/host-dashboard/bookings/{bookingId}/refund Update refund status

Review APIs

Method Endpoint Description
GET /api/reviews/event/{eventId} Get reviews for an event
GET /api/reviews/host/{hostId} Get reviews for a host
GET /api/reviews/public Get public reviews
POST /api/reviews Create a review
PATCH /api/reviews/{reviewId}/reply Add host reply to review

Database Models

User

Stores customer account details.

Typical fields include:

  • ID
  • First name
  • Last name
  • Email
  • Password
  • Nickname
  • Phone
  • Gender
  • Approval status

Host

Stores event organiser account details.

Typical fields include:

  • ID
  • First name
  • Last name
  • Email
  • Password
  • Mobile number
  • Date of birth
  • Event category
  • Approval status

Admin

Stores admin account details.

Typical fields include:

  • ID
  • Name
  • Email
  • Password

Event

Stores event details.

Fields include:

  • ID
  • Image URL
  • Title
  • Category
  • Date
  • Location
  • Description
  • Ticket quantity
  • Ticket price
  • Status
  • Approval status
  • Created date
  • Updated date
  • Host

Booking

Stores customer booking details.

Typical fields include:

  • Booking ID
  • Event
  • User
  • Quantity
  • Seat numbers
  • Total price
  • Booking status
  • Refund status
  • Refund amount
  • Cancellation reason
  • Notification message
  • Cancelled date
  • Refunded date

Review

Stores customer event reviews.

Typical fields include:

  • Review ID
  • Event
  • User
  • Rating
  • Comment
  • Host reply
  • Created date
  • Replied date

MFA Challenge

Stores login verification sessions.

Typical fields include:

  • Challenge ID
  • Principal type
  • Principal ID
  • Email
  • Hashed code
  • Expiry time
  • Consumed status
  • Created date

Authentication Flow

User / Host / Admin submits login details
        |
        v
Backend validates credentials
        |
        v
MFA challenge is generated
        |
        v
Verification code is sent by email or shown in demo mode
        |
        v
User submits MFA code
        |
        v
Backend verifies code
        |
        v
Login is completed

Booking Flow

User selects event
        |
        v
User selects quantity or seats
        |
        v
Backend validates event and user
        |
        v
Seat layout service assigns seats
        |
        v
Backend reduces available ticket quantity
        |
        v
Booking is saved
        |
        v
Booking confirmation is returned

Cancellation and Refund Flow

User or host cancels booking/event
        |
        v
Booking status changes to CANCELLED
        |
        v
Refund status changes to PENDING
        |
        v
Refund amount is recorded
        |
        v
Host updates refund status
        |
        v
Booking can be marked as REFUNDED

Approval Workflow

Admins can approve, reject, or keep pending status for:

  • Users
  • Hosts
  • Events

Supported approval statuses:

PENDING
APPROVED
REJECTED

Event Statuses

Common event statuses:

ACTIVE
CANCELLED

Booking Statuses

Common booking statuses:

CONFIRMED
CANCELLED
REFUNDED

Refund Statuses

Common refund statuses:

PENDING
REFUNDED

Prerequisites

Before running the project, make sure you have installed:

  • Java 17 or higher
  • Maven
  • MySQL Server
  • MySQL Workbench or another database client
  • IntelliJ IDEA, VS Code, or another Java IDE

Database Setup

Create a MySQL database:

CREATE DATABASE ems_db;

Optional: import seed data from:

sql/seed_events_50.sql

Environment Configuration

The project currently uses application.properties.

Recommended configuration:

spring.datasource.url=jdbc:mysql://localhost:3306/ems_db
spring.datasource.username=${DB_USERNAME}
spring.datasource.password=${DB_PASSWORD}

spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect

server.port=8080

app.mail.enabled=false
app.mail.from=no-reply@ems-demo.local

app.mfa.code-length=6
app.mfa.expiry-minutes=10

spring.mail.host=${MAIL_HOST}
spring.mail.port=587
spring.mail.username=${MAIL_USERNAME}
spring.mail.password=${MAIL_PASSWORD}
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true

Important: do not commit real database passwords or email passwords to GitHub.

Installation and Setup

1. Clone the repository

git clone https://github.com/DANUCKSAN/emsbackend.git

2. Navigate to the project folder

cd emsbackend

3. Configure MySQL database

Create the database:

CREATE DATABASE ems_db;

Update your database username and password in application.properties, or use environment variables.

4. Run the application

Using Maven wrapper:

./mvnw spring-boot:run

On Windows:

mvnw.cmd spring-boot:run

Or using Maven:

mvn spring-boot:run

The backend will run on:

http://localhost:8080

Frontend Integration

The backend is configured for frontend requests from:

http://localhost:3000

This is suitable for a React or Next.js frontend running locally.

Available Maven Commands

Run the application

./mvnw spring-boot:run

Build the project

./mvnw clean install

Run tests

./mvnw test

Package the application

./mvnw clean package

Example Request Bodies

Register User

{
  "firstName": "John",
  "lastName": "Doe",
  "email": "john@example.com",
  "password": "password123",
  "nickname": "Johnny",
  "phone": "+61400000000",
  "gender": "Male"
}

User Login

{
  "email": "john@example.com",
  "password": "password123"
}

Verify MFA

{
  "challengeId": "generated-challenge-id",
  "code": "123456"
}

Register Host

{
  "firstName": "Sarah",
  "lastName": "Smith",
  "email": "sarah@example.com",
  "password": "password123",
  "mobileNumber": "+61400000000",
  "eventCategory": "Music"
}

Create Event

{
  "title": "Live Music Night",
  "category": "Music",
  "date": "2026-08-15",
  "location": "Sydney",
  "description": "A live music event with local artists.",
  "ticketQuantity": 100,
  "ticketPrice": 49.99,
  "imageUrl": "https://example.com/event-image.jpg",
  "host": {
    "email": "sarah@example.com"
  }
}

Create Booking

{
  "eventId": 1,
  "userId": 1,
  "quantity": 2,
  "selectedSeats": ["A1", "A2"]
}

Create Review

{
  "eventId": 1,
  "userId": 1,
  "rating": 5,
  "comment": "Great event and smooth booking experience."
}

Host Reply to Review

{
  "hostReply": "Thank you for your feedback. We are glad you enjoyed the event."
}

Update Approval Status

{
  "approvalStatus": "APPROVED"
}

Cancel Event

{
  "reason": "Event cancelled due to unexpected circumstances."
}

Update Refund Status

{
  "refundStatus": "REFUNDED",
  "refundAmount": 49.99
}

Security Notes

This project includes Spring Security and password hashing support.

Recommended improvements before production:

  • Add JWT-based authentication
  • Add role-based authorization
  • Protect admin and host dashboard APIs
  • Move all secrets to environment variables
  • Disable public admin registration
  • Add request validation
  • Add global exception handling
  • Add rate limiting
  • Add audit logging for admin actions
  • Add HTTPS in production
  • Add proper CORS configuration for production domains only

Learning Outcomes

This project demonstrates practical backend development skills including:

  • Building REST APIs with Spring Boot
  • Structuring a layered backend project
  • Using Spring Data JPA with MySQL
  • Creating entity relationships
  • Handling user, host, and admin workflows
  • Implementing MFA login verification
  • Managing event booking and seat selection
  • Handling event cancellation and refund workflows
  • Creating dashboard APIs
  • Managing review and reply functionality
  • Integrating backend APIs with a frontend application

Future Improvements

  • Add JWT authentication
  • Add role-based API authorization
  • Add Swagger/OpenAPI documentation
  • Add DTO mapping for all request and response objects
  • Add global exception handling
  • Add validation annotations
  • Add email templates for MFA and booking notifications
  • Add payment gateway integration
  • Add QR code tickets
  • Add booking confirmation emails
  • Add automated tests
  • Add Docker support
  • Add Docker Compose with MySQL
  • Add CI/CD pipeline using GitHub Actions
  • Add deployment documentation
  • Add production-ready logging

Repository Description

Event Management System backend built with Spring Boot, MySQL, Spring Security, JPA, MFA login, event booking, host/admin dashboards, reviews, and refund management.

Topics

spring-boot
java
mysql
spring-data-jpa
spring-security
spring-mail
rest-api
backend
event-management-system
ems
event-booking
ticket-booking
mfa
admin-dashboard
host-dashboard
seat-booking
refund-management
reviews
lombok
maven

Author

Danucksan Sathiyaraj

GitHub: DANUCKSAN

License

This project is open-source and available for learning, portfolio, and demonstration purposes.

About

Event Management System backend built with Spring Boot, MySQL, Spring Security, JPA, MFA login, event booking, host/admin dashboards, reviews, and refund management.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages