This project, named "University Event Management," is a powerful Spring Boot application designed to streamline the organization and coordination of university events and student information. This system features secure data storage using an H2 Database, strict validation checks on student attributes, and efficient endpoints for adding, updating, and retrieving student and event records. Manage your university's events effortlessly with the user-friendly application, ensuring accurate event details and student information.
- Framework: Spring Boot
- Language: Java
- Build Tool: Maven
The project relies on the following dependencies, each serving a specific purpose in the application:
-
Spring Boot Starter Data JPA
- Description: Provides support for JPA (Java Persistence API) and simplifies database access using Spring Data repositories.
- Maven Dependency:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency>
-
Spring Boot Starter Validation
- Description: Includes validation support for request data binding and response data rendering.
- Maven Dependency:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency>
-
Spring Boot Starter Web
- Description: Provides support for building web applications, including RESTful APIs.
- Maven Dependency:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>
-
H2 Database (Runtime Dependency)
- Description: An in-memory database for development and testing purposes.
- Maven Dependency:
<dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>runtime</scope> </dependency>
-
Project Lombok (Optional)
- Description: A library that simplifies Java code by reducing boilerplate code, such as getters and setters.
- Maven Dependency:
<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency>
-
Spring Boot Starter Test (For Testing)
- Description: Provides support for testing Spring Boot applications.
- Maven Dependency (Test Scope):
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency>
The project enforces rigorous data validation in the model layer to maintain data integrity and consistency. Below are the key data validations applied to the student and event models:
- Validation: Auto-generated by the database (Primary Key)
- Description: The
studentId
is automatically generated by the database and serves as the primary key for student records.
- Validation:
@Pattern(regexp = "^[A-Z][a-zA-Z]*$", message = "Only alphabets are allowed with the first letter as capital")
- Description: The
firstName
andlastName
fields must start with a capital letter and contain only alphabetic characters.
- Validation:
@Min(value = 18)
,@Max(value = 25)
- Description: The
age
field must be between 18 and 25.
- Validation: Enumerated values (ME, ECE, CIVIL, CSE)
- Description: The
studentDepartment
field must have one of the predefined department values: ME, ECE, CIVIL, CSE.
- Validation: Auto-generated by the database (Primary Key)
- Description: The
eventId
is automatically generated by the database and serves as the primary key for event records.
- Validation: None
- Description: The
eventName
field does not have additional validation as it represents the name of the event.
- Validation: None
- Description: The
locationOfEvent
field does not have additional validation as it represents the location of the event.
- Validation: None
- Description: The
eventDate
field does not have additional validation as it represents the date of the event.
- Validation: None
- Description: The
startTime
andendTime
fields do not have additional validation as they represent the event's start and end times.
These comprehensive data validations ensure that the university event management system captures accurate and reliable information.
The Controller layer is responsible for handling incoming HTTP requests and delegating them to the appropriate services. It defines API endpoints for various operations on student and event records.
@RestController
public class StudentController {
@Autowired
StudentService studentService;
// Add a student
@PostMapping("student")
public String addAStudent(@RequestBody Student student) {
return studentService.addAStudent(student);
}
// Get all students
@GetMapping("students")
public Iterable<Student> getAllStudents() {
return studentService.getAllStudents();
}
// ...
}
-
Add Student
- Endpoint:
POST /student
- Description: Add a new student to the system.
- Endpoint:
-
Add Students
- Endpoint:
POST /students
- Description: Add multiple students to the system at once.
- Endpoint:
-
Get All Students
- Endpoint:
GET /students
- Description: Retrieve a list of all student records.
- Endpoint:
-
Get Student by ID
- Endpoint:
GET /student/{studentId}
- Description: Retrieve a specific student's details by providing their
studentId
in the URL.
- Endpoint:
-
Update Student Department
- Endpoint:
PUT /student/{studentId}/{department}
- Description: Update a student's department by providing their
studentId
and the newdepartment
in the URL.
- Endpoint:
-
Delete Student by ID
- Endpoint:
DELETE /student/{studentId}
- Description: Remove a student from the system by specifying their
studentId
in the URL.
- Endpoint:
-
Add Event
- Endpoint:
POST /event
- Description: Add a new event to the system.
- Endpoint:
-
Add Events
- Endpoint:
POST /events
- Description: Add multiple events to the system at once.
- Endpoint:
-
Get All Events
- Endpoint:
GET /events
- Description: Retrieve a list of all event records.
- Endpoint:
-
Get Event by ID
- Endpoint:
GET /event/{eventId}
- Description: Retrieve details of a specific event by providing its
eventId
in the URL.
- Endpoint:
-
Get Events on the Same Date
- Endpoint:
GET /events/date
- Request Parameter:
date
(e.g., 2023-09-20) - Description: Retrieve a list of events that occur on the specified date by providing the date as a request parameter.
- Endpoint:
-
Update Event Location by ID
- Endpoint:
PUT /event/id/{eventId}/location/{loc}
- Description: Update the location of a specific event by providing its
eventId
and the newloc
(location) in the URL.
- Endpoint:
-
Delete Event by ID
- Endpoint:
DELETE /event/{eventId}
- Description: Remove an event from the system by specifying its
eventId
in the URL.
- Endpoint:
The Services layer implements the core business logic, data processing, and interaction with the data repository. It handles data validations, CRUD operations on student and event data, and data transformations.
@Service
public class StudentService {
@Autowired
IStudentRepo studentRepo;
public String addAStudent(Student student) {
studentRepo.save(student);
return "A student is added!";
}
// Get all students
public Iterable<Student> getAllStudents() {
return studentRepo.findAll();
}
// ...
}
-
Get All Students: Retrieve a list of all student records.
-
Get Student by ID: Retrieve details of a specific student by
studentId
. -
Add Student: Add a new student to the system.
-
Add Students: Add multiple students to the system at once.
-
Update Student Department: Update a student's department by
studentId
. -
Delete Student by ID: Remove a student from the system by
studentId
.
-
Get All Events: Retrieve a list of all event records.
-
Get Event by ID: Retrieve details of a specific event by
eventId
. -
Add Event: Add a new event to the system.
-
Add Events: Add multiple events to the system at once.
-
Get Events on the Same Date: Retrieve events that occur on the specified date.
-
Update Event Location by ID: Update the location of a specific event by
eventId
. -
Delete Event by ID: Remove an event from the system by
eventId
.
The Repository layer manages data access to the underlying H2 Database. It manages data access to the underlying database using Spring Data repositories. It handles database operations such as Create, Read, Update, and Delete (CRUD) for student and event data.
@Repository
public interface IStudentRepo extends JpaRepository<Student, Integer> {
// Custom query methods can be added here
}
-
Get Students: Retrieve a list of all student records.
-
Get Student by ID: Retrieve details of a specific student by
studentId
. -
Add Student: Add a new student to the database.
-
Update Student Department: Update a student's department by
studentId
. -
Delete Student by ID: Remove a student from the database by
studentId
.
-
Get Events: Retrieve a list of all event records.
-
Get Event by ID: Retrieve details of a specific event by
eventId
. -
Add Event: Add a new event to the database.
-
Get Events on the Same Date: Retrieve events that occur on the specified date.
-
Update Event Location by ID: Update the location of a specific event by
eventId
. -
Delete Event by ID: Remove an event from the database by
eventId
.
The project's database design includes tables for student and event management, each with specific fields. Below are the details of the database design:
Column Name | Data Type | Description |
---|---|---|
studentId | INT (Primary Key) | Unique identifier for each student |
firstName | VARCHAR(255) | Student's first name |
lastName | VARCHAR(255) | Student's last name |
age | INT | Student's age |
studentDepartment | ENUM | Student's department (ME, ECE, CIVIL, CSE) |
created_at | TIMESTAMP | Timestamp of record creation |
updated_at | TIMESTAMP | Timestamp of record modification |
Column Name | Data Type | Description |
---|---|---|
eventId | INT (Primary Key) | Unique identifier for each event |
eventName | VARCHAR(255) | Event name |
locationOfEvent | VARCHAR(255) | Location of the event |
eventDate | DATE | Date of the event |
startTime | TIME | Start time of the event |
endTime | TIME | End time of the event |
created_at | TIMESTAMP | Timestamp of record creation |
updated_at | TIMESTAMP | Timestamp of record modification |
INSERT INTO Student (studentId, firstName, lastName, age, studentDepartment)
VALUES
(1, 'John', 'Doe', 20, 'CSE'),
(2, 'Alice', 'Johnson', 22, 'ECE');
INSERT INTO Event (eventId, eventName, locationOfEvent, eventDate, startTime, endTime)
VALUES
(1, 'Tech Conference', 'Conference Center', '2023-10-15', '09:00:00', '17:00:00'),
(2, 'Sports Day', 'Stadium', '2023-11-05', '09:00:00', '16:00:00');
SELECT * FROM Student;
SELECT * FROM Event;
SELECT * FROM Student WHERE studentDepartment = 'CSE';
UPDATE Student SET age = 21 WHERE studentId = 1;
UPDATE Event SET locationOfEvent = 'Indoor Arena' WHERE eventId = 2;
DELETE
FROM Student WHERE studentId = 2;
DELETE FROM Event WHERE eventId = 1;
The project utilizes the following data structures:
The Student
class defines the structure for student data and includes fields such as studentId
, firstName
, lastName
, age
, studentDepartment
, and timestamps.
The Event
class defines the structure for event data and includes fields such as eventId
, eventName
, locationOfEvent
, eventDate
, startTime
, endTime
, and timestamps.
studentDepartment
(ME, ECE, CIVIL, CSE): An enumeration representing the departments available for students.
The University Event Management project is a robust Spring Boot application designed for efficient management of student and event data. It offers a set of RESTful API endpoints for adding, retrieving, updating, and deleting student and event records.
- Framework: Spring Boot
- Language: Java
- Build Tool: Maven
The Controller layer handles incoming HTTP requests and routes them to the appropriate services. It defines API endpoints for various operations on students and events.
The Services layer implements core business logic, data processing, and interaction with the data repository. It handles data validations, CRUD operations, and data transformations.
The Repository layer manages data access to the underlying H2 Database. It handles database operations for student and event data.
The project's database design includes tables for student and event management, each with specific fields. This design ensures data integrity and organized storage.
The project utilizes data structures such as the Student
and Event
classes, along with enumerations, to represent and manage student and event data.
- RESTful API endpoints for student and event management.
- Comprehensive data validation for student attributes.
- Structured database design for efficient data storage.
- Dynamic default values for date and time fields.
- Clean code separation with a layered architecture (Controller, Services, Repository).
The University Event Management project serves as a practical example of Spring Boot application development, demonstrating best practices in API design and data management. It offers a solid foundation for managing university events and student information efficiently.
This project is licensed under the BSD 3-Clause License.
Thank you to the Spring Boot and Java communities for providing excellent tools and resources.
For questions or feedback, please contact Pratik Sharma .