Architecture๏ƒ

MVC Pattern๏ƒ

SpringBootLibrary follows the classic Model-View-Controller (MVC) pattern, adapted for a REST API:

HTTP Client (Browser / Postman)
        โ”‚
        โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚    Controller     โ”‚  โ† Handles HTTP requests & responses
โ”‚  (REST endpoints) โ”‚    com.example.library.controller
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚     Service       โ”‚  โ† Business logic
โ”‚                   โ”‚    com.example.library.service
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Repository      โ”‚  โ† Spring Data JPA interfaces
โ”‚                   โ”‚    com.example.library.repository
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Database (MySQL) โ”‚  โ† Entities via Hibernate / JPA
โ”‚  H2 (tests)       โ”‚    com.example.library.model
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Package Structure๏ƒ

Package

Responsibility

controller/

REST endpoints โ€” BookController, BorrowingController, UserController

service/

Business logic โ€” BookService, BorrowingService, UserService

repository/

JPA repositories โ€” CRUD + custom queries

model/

JPA entities โ€” Book, Borrowing, User

Key Design Decisions๏ƒ

Spring Data JPA is used for the persistence layer. Repository interfaces extend JpaRepository, providing standard CRUD operations without boilerplate code.

H2 in-memory database is activated automatically in the test Spring profile, so unit and integration tests run without requiring a real MySQL instance (except when using @SpringBootTest with the integration Maven profile, which spins up a MySQL Docker container via GitHub Actions).

Springdoc OpenAPI auto-generates an interactive Swagger UI from the controller annotations at runtime, always reflecting the current API surface.

Static Resources๏ƒ

The frontend is a plain HTML + JavaScript + CSS single-page application located at:

src/main/resources/static/
โ”œโ”€โ”€ index.html
โ”œโ”€โ”€ app.js
โ””โ”€โ”€ style.css

It communicates with the backend over REST, keeping the view layer decoupled from the server.