This project is a simple, full-stack CRUD (Create, Read, Update, Delete) application for managing student records.
It consists of a Spring Boot backend providing a REST API and a single-page HTML/CSS/JavaScript frontend for the user interface.
- REST API: A backend built with Spring Boot exposes a full set of CRUD endpoints for managing students.
- Frontend UI: A responsive single-page interface built with HTML, Tailwind CSS, and vanilla JavaScript allows for:
- Viewing all students in a table.
- Adding new students via a form.
- Editing existing students (populates the form).
- Deleting students.
- Database: Uses an in-memory H2 database for simplicity and ease of setup.
- Validation: The backend uses
spring-boot-starter-validationto ensure data integrity (e.g., required fields, valid email formats).
- Backend:
- Java 24
- Spring Boot 3.3.0
- Spring Web (REST APIs)
- Spring Data JPA (Repository pattern)
- Lombok
- Frontend:
- HTML
- Tailwind CSS (via CDN)
- Vanilla JavaScript (Fetch API)
- Database:
- H2 In-Memory Database
- Build:
- Apache Maven (via Maven Wrapper)
- JDK 21 or later.
- You do not need to install Maven; the project includes the Maven Wrapper.
-
Clone the repository (or ensure all provided files are in a single project directory).
-
Open a terminal in the root directory of the project.
-
Run the application using the Maven Wrapper:
- On macOS/Linux:
./mvnw spring-boot:run
- On Windows:
.\mvnw.cmd spring-boot:run
- On macOS/Linux:
-
The application will start on
http://localhost:8080.
Once the application is running:
-
Access the Frontend: Open your web browser and navigate to:
http://localhost:8080/studentmanagement.htmlYou can now use the interface to add, edit, view, and delete students.
-
Access the H2 Database Console (Optional): To inspect the in-memory database:
- Navigate to:
http://localhost:8080/h2-console - Use the following settings:
- JDBC URL:
jdbc:h2:mem:studentdb - User Name:
sa - Password: (leave blank)
- JDBC URL:
- Navigate to:
The backend provides the following REST API endpoints, all prefixed with /api/students.
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Retrieves a list of all students. |
GET |
/{id} |
Retrieves a single student by their ID. |
POST |
/ |
Creates a new student. Expects a Student object in the request body. |
PUT |
/{id} |
Updates an existing student by their ID. Expects a Student object in the request body. |
DELETE |
/{id} |
Deletes a student by their ID. |
The Student object used in the API has the following structure.
{
"id": 1,
"rollNumber": "11",
"firstName": "Arya",
"lastName": "Dharmadhikari",
"email": "[email protected]",
"department": "Information Technology",
"year": 2,
"gpa": 8.7
}