Skip to content

About

A Student Management REST API built with Spring Boot, Spring MVC, Spring Data JPA, Hibernate, MySQL, and Spring Security. Includes student and course management, CRUD operations, validation, database relationships, and role-based API authorization.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Student Management REST API

A RESTful Student Management API built with Java and Spring Boot. The project demonstrates backend development concepts including REST APIs, CRUD operations, Spring Data JPA, Hibernate, MySQL, validation, and entity relationships.

πŸš€ Features

  • Student management with CRUD operations
  • Course management
  • Student-course enrollment management
  • RESTful API endpoints
  • MySQL database integration
  • Spring Data JPA and Hibernate
  • Jakarta Bean Validation
  • Entity relationships with JPA
  • OpenAPI / Swagger API documentation
  • Spring Boot Actuator

πŸ› οΈ Tech Stack

Technology Purpose
Java 26 Programming language
Spring Boot 4.1.1 Application framework
Spring MVC REST API development
Spring Data JPA Data access
Hibernate ORM
MySQL Relational database
Jakarta Validation Request validation
Maven Build & dependency management
Springdoc OpenAPI API documentation
Spring Boot Actuator Application monitoring

πŸ“š Main Resources

The API manages three main resources:

Student

Stores student information such as:

  • ID
  • First name
  • Last name
  • Email
  • Date of birth
  • Phone number

Course

Stores information about available courses, including a generated course code.

Student Course

Represents the relationship between a student and a course.

It contains information such as:

  • Student
  • Course
  • Enrollment date
  • Grade

The StudentCourse resource demonstrates a JPA relationship between students and courses.

πŸ”— API Structure

The API uses the /api base path.

Students

Method Endpoint Description
GET /api/students Get all students
GET /api/students/{id} Get a student by ID
POST /api/students Create a student
PUT /api/students/{id} Update a student

Courses

Method Endpoint Description
GET /api/courses Get all courses
GET /api/courses/{id} Get a course by ID
POST /api/courses Create a course
PUT /api/courses/{id} Update a course
DELETE /api/courses/{id} Delete a course

Student Courses

The StudentCourse resource connects students with courses and stores enrollment information and grades.

Example relationship:

Student
   β”‚
   β”‚ 1
   β”‚
   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€*
   β”‚
StudentCourse
   β”‚
   β”‚ *
   β”‚
   └───────────1
          Course

βœ… Validation

The API uses Jakarta Bean Validation to validate incoming request data.

For example:

@Valid
@RequestBody Student student

Validation annotations can then be applied to fields to ensure that invalid data is rejected before it reaches the business logic.

πŸ—„οΈ Database

The application uses MySQL as its relational database.

JPA and Hibernate handle the mapping between Java objects and database tables.

The main database relationships include:

students
    β”‚
    β”‚
    └── student_courses ── courses

This allows a student to be associated with courses through the student_courses table.

πŸ“– API Documentation

The project uses Springdoc OpenAPI to generate API documentation and a Swagger UI interface.

After starting the application, Swagger UI can be accessed through the configured Springdoc endpoint.

βš™οΈ Getting Started

1. Clone the repository

git clone https://github.com/BeatrixBlaine/Student-Management-RestAPI.git
cd Student-Management-RestAPI

2. Configure MySQL

Create a MySQL database for the application.

Then configure the database connection in:

src/main/resources/application.properties

Example:

spring.datasource.url=jdbc:mysql://localhost:3306/student_management
spring.datasource.username=your_username
spring.datasource.password=your_password

Use your own MySQL username and password.

3. Run the application

Using the Maven wrapper:

Windows

mvnw.cmd spring-boot:run

macOS / Linux

./mvnw spring-boot:run

Or run the main Spring Boot application directly from your IDE.

The API will then be available at:

http://localhost:8080

πŸ§ͺ Example Request

Create a Student

POST /api/students
Content-Type: application/json

Example request body:

{
  "firstName": "John",
  "lastName": "Doe",
  "email": "john.doe@example.com",
  "dateOfBirth": "2000-01-15",
  "phone": "081234567890"
}

Get All Students

GET /api/students

πŸ—οΈ Project Architecture

The application follows a layered Spring Boot architecture:

Controller
    ↓
Service
    ↓
Repository
    ↓
JPA / Hibernate
    ↓
MySQL

Controller

Handles HTTP requests and exposes REST endpoints.

Service

Contains application/business logic.

Repository

Handles database operations through Spring Data JPA.

Entity

Represents database tables and their relationships.

DTO

Used when request or response data needs to be separated from the database entity model.

🎯 What I Practiced

This project was built to practice and strengthen backend development skills with Java and Spring Boot, including:

  • Building REST APIs
  • HTTP methods and REST conventions
  • CRUD operations
  • Spring MVC
  • Dependency injection
  • Spring Data JPA
  • Hibernate
  • MySQL
  • JPA entity relationships
  • DTOs
  • Jakarta Bean Validation
  • OpenAPI / Swagger
  • Maven
  • Debugging REST APIs

πŸ“Œ Future Improvements

Possible future improvements include:

  • Global exception handling
  • More comprehensive DTO mapping
  • Pagination
  • Sorting and filtering
  • Automated unit and integration tests
  • Improved API documentation
  • Improved error response structure

πŸ‘€ Author

Beatrix Blaine

GitHub: https://github.com/BeatrixBlaine


This project is part of my ongoing Java and Spring Boot backend development practice.

About

A Student Management REST API built with Spring Boot, Spring MVC, Spring Data JPA, Hibernate, MySQL, and Spring Security. Includes student and course management, CRUD operations, validation, database relationships, and role-based API authorization.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages