Code Monkey home page Code Monkey logo

amit-ashok-swain / university-event-management Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 1.0 92 KB

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 CRUD operations

License: BSD 3-Clause "New" or "Revised" License

Java 100.00%
event-management event-management-system h2-database java-springboot university-management university-management-system university-event-management

university-event-management's Introduction

University Event Management


Java Maven Spring Boot BSD Clause 3


Overview

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.

Technologies Used

  • Framework: Spring Boot
  • Language: Java
  • Build Tool: Maven

Dependencies

The project relies on the following dependencies, each serving a specific purpose in the application:

  1. 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>
  2. 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>
  3. 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>
  4. 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>
  5. 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>
  6. 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>

Data Validation in the Model Layer

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:

Student Model

Student ID

  • 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.

First Name and Last Name

  • Validation: @Pattern(regexp = "^[A-Z][a-zA-Z]*$", message = "Only alphabets are allowed with the first letter as capital")
  • Description: The firstName and lastName fields must start with a capital letter and contain only alphabetic characters.

Age

  • Validation: @Min(value = 18), @Max(value = 25)
  • Description: The age field must be between 18 and 25.

Department

  • Validation: Enumerated values (ME, ECE, CIVIL, CSE)
  • Description: The studentDepartment field must have one of the predefined department values: ME, ECE, CIVIL, CSE.

Event Model

Event ID

  • 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.

Event Name

  • Validation: None
  • Description: The eventName field does not have additional validation as it represents the name of the event.

Location of Event

  • Validation: None
  • Description: The locationOfEvent field does not have additional validation as it represents the location of the event.

Date

  • Validation: None
  • Description: The eventDate field does not have additional validation as it represents the date of the event.

Start Time and End Time

  • Validation: None
  • Description: The startTime and endTime 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.

Data Flow

Controller

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();
    }

    // ...
}

Student Controller

  1. Add Student

    • Endpoint: POST /student
    • Description: Add a new student to the system.
  2. Add Students

    • Endpoint: POST /students
    • Description: Add multiple students to the system at once.
  3. Get All Students

    • Endpoint: GET /students
    • Description: Retrieve a list of all student records.
  4. Get Student by ID

    • Endpoint: GET /student/{studentId}
    • Description: Retrieve a specific student's details by providing their studentId in the URL.
  5. Update Student Department

    • Endpoint: PUT /student/{studentId}/{department}
    • Description: Update a student's department by providing their studentId and the new department in the URL.
  6. Delete Student by ID

    • Endpoint: DELETE /student/{studentId}
    • Description: Remove a student from the system by specifying their studentId in the URL.

Event Controller

  1. Add Event

    • Endpoint: POST /event
    • Description: Add a new event to the system.
  2. Add Events

    • Endpoint: POST /events
    • Description: Add multiple events to the system at once.
  3. Get All Events

    • Endpoint: GET /events
    • Description: Retrieve a list of all event records.
  4. Get Event by ID

    • Endpoint: GET /event/{eventId}
    • Description: Retrieve details of a specific event by providing its eventId in the URL.
  5. 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.
  6. 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 new loc (location) in the URL.
  7. Delete Event by ID

    • Endpoint: DELETE /event/{eventId}
    • Description: Remove an event from the system by specifying its eventId in the URL.

Services

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();
    }

    // ...
}

Student Service

  • 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.

Event Service

  • 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.

Repository

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 CrudRepository<Student, Integer> {
    // Custom query methods can be added here
}

Student Repository

  • 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.

Event Repository

  • 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.

Database Design

The project's database design includes tables for student and event management, each with specific fields. Below are the details of the database design:

Student Table

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

Event Table

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

Sample H2 Database Queries

Insert Students

INSERT INTO Student (studentId, firstName, lastName, age, studentDepartment)
VALUES
    (1, 'John', 'Doe', 20, 'CSE'),
    (2, 'Alice', 'Johnson', 22, 'ECE');

Insert Events

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');

Retrieve All Students

SELECT * FROM Student;

Retrieve All Events

SELECT * FROM Event;

Retrieve Students by Department

SELECT * FROM Student WHERE studentDepartment = 'CSE';

Update Student Age

UPDATE Student SET age = 21 WHERE studentId = 1;

Update Event Location

UPDATE Event SET locationOfEvent = 'Indoor Arena' WHERE eventId = 2;

Delete Student by ID

DELETE

 FROM Student WHERE studentId = 2;

Delete Event by ID

DELETE FROM Event WHERE eventId = 1;

Data Structures Used

The project utilizes the following data structures:

Student Class

The Student class defines the structure for student data and includes fields such as studentId, firstName, lastName, age, studentDepartment, and timestamps.

Event Class

The Event class defines the structure for event data and includes fields such as eventId, eventName, locationOfEvent, eventDate, startTime, endTime, and timestamps.

Enumerations

  • studentDepartment (ME, ECE, CIVIL, CSE): An enumeration representing the departments available for students.

Project Summary

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.

Key Technologies Used

  • Framework: Spring Boot
  • Language: Java
  • Build Tool: Maven

Data Flow

Controller

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.

Services

The Services layer implements core business logic, data processing, and interaction with the data repository. It handles data validations, CRUD operations, and data transformations.

Repository

The Repository layer manages data access to the underlying H2 Database. It handles database operations for student and event data.

Database Design

The project's database design includes tables for student and event management, each with specific fields. This design ensures data integrity and organized storage.

Data Structures Used

The project utilizes data structures such as the Student and Event classes, along with enumerations, to represent and manage student and event data.

Key Features

  • 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.

License

This project is licensed under the BSD 3-Clause License.

Acknowledgments

Thank you to the Spring Boot and Java communities for providing excellent tools and resources.

Contact

For questions or feedback, please contact Amit Ashok Swain.

university-event-management's People

Contributors

amit-ashok-swain avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

shri0322

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.