This project allows users to perform CRUD (Create, Read, Update, Delete) operations on student data. However, only users with admin privileges can delete or update student data and have the ability to change a student's status to "inactive." It uses the H2 in-memory database to store student data. The database is lightweight and runs entirely in memory, making it suitable for testing and development purposes. Once the application is shut down, the data is lost.
H2 is an in-memory relational database primarily used for lightweight, embedded databases in Java applications. It supports SQL queries and is commonly used for testing and development because it doesn't require installation.
URL to access the H2 database: http://localhost:8083/h2-console/
The following validations have been implemented on student data:
@NotEmpty(message = "Name is required")
@NotEmpty(message = "Address is required")
@NotEmpty(message = "Students should register at least one student")
In this project, soft deleting is used instead of hard deleting student data. This is achieved by using a StudentStatus
field of type enum
. When a user tries to delete student data, it doesn't get permanently deleted from the database. Instead, the StudentStatus
enum is set to INACTIVE
, indicating that the student is inactive but still exists in the system for audit or record-keeping purposes.
Here’s a quick breakdown of the REST endpoints:
GET /api/students
: Retrieves a list of students, paginated bypageNo
.GET /api/students/{id}
: Retrieves details of a student by their ID.POST /api/students
: Registers a new student.PUT /api/students
: Updates student data.PATCH /api/students/{id}
: Updates the address of a student.DELETE /api/students/{id}
: Soft deletes a student by setting their status toINACTIVE
.
You can test the endpoints using Postman or Swagger UI.
Swagger documentation is included to test the endpoints directly from the browser. It provides sample data for each endpoint and automatically generates the necessary URL. You can access the Swagger documentation by visiting the following URL: http://localhost:8083/swagger-ui/index.html#/
Swagger UI Documentation
The Swagger UI will display the available endpoints, response codes, and response messages, allowing you to interact with the API easily.
- Sending Emails to Students
I plan to implement an email notification system to send emails to students:- After successful registration.
- Whenever their details are updated.
This project provides simple and effective management of student data with the ability to soft delete records. The API is fully documented using Swagger, making it easy for developers to test and interact with the endpoints. The use of H2 as an in-memory database ensures that the application is lightweight and easy to set up for testing or development purposes.