REST API built with Spring Boot, following industry best practices for security, testing, and scalability.
The system simulates a library catalog, where users can browse books and administrators manage the catalog (create, update, and delete books).
- Java
- Spring Boot
- Spring Security
- JWT (JSON Web Token)
- Spring Data JPA
- Hibernate
- MySQL
- Maven
- Docker & Docker Compose
- Prometheus
- Grafana
- Springdoc OpenAPI (Swagger)
- JUnit
- ✅ Full CRUD operations for books (admin only)
- ✅ Public access for users to view books
- ✅ Pagination and sorting
- ✅ Filtering via query parameters (one filter at a time)
- ✅ Authentication with JWT
- ✅ Role-based access control (USER / ADMIN)
- ✅ Data validation with Bean Validation
- ✅ DTO pattern for request/response
- ✅ Global exception handling
- ✅ Unit tests (Controller, Service, Repository, JWT Service)
- ✅ Integration tests (including JWT and security)
- ✅ API documentation (Swagger/OpenAPI)
- ✅ Monitoring with Prometheus
- ✅ Metrics visualization with Grafana
- ✅ Dockerized environment
The application follows a layered architecture, ensuring clear separation of concerns:
Controller → Service → Repository → Database
↓
DTO
↓
Security (JWT)
↓
Exception Handler
↓
Actuator → Prometheus → Grafana
src/
├── main/
│ ├── java/library/com/
│ │ ├── configurations/
│ │ ├── controller/
│ │ ├── dto/
│ │ ├── entity/
│ │ ├── exceptions/
│ │ ├── repository/
│ │ ├── service/
│ │ └── ComApplication.java
│ └── resources/
│ └── application.properties
│
├── test/
│ ├── java/library/com/
│ │ ├── configurations/
│ │ ├── controller/
│ │ ├── integration/
│ │ ├── repository/
│ │ ├── service/
│ │ └── util/
│ └── resources/
│ └── application-test.properties
- Stateless authentication using JWT
- User registration and login
- Protected routes with Spring Security
- USER → can view books
- ADMIN → can create, update, and delete books
Authorization: Bearer YOUR_TOKENGET /books?page=0&size=10&sort=title,asctitle→ partial, case-insensitive searchauthor→ filter by author (case-insensitive)genre→ filter by genre
⚠️ Only one filter can be applied per request.
- Required fields (e.g., title, author, description, status)
- Publication date cannot be in the future
- ID is automatically generated by the database
- Text search is partial and case insensitive
The project includes comprehensive test coverage:
- Controller
- Service
- Repository
- JWT Service
- Full application flow
- JWT authentication
- Security validation
/actuator/prometheus- Prometheus collects application metrics
- Grafana provides visualization dashboards
Documentation is automatically generated using Springdoc OpenAPI.
http://localhost:8080/swagger-ui/index.html- Interactive endpoint testing
- Request/response visualization
- Clear API contract
Run the full environment using Docker:
mvn clean package
docker compose up --buildgit clone https://github.com/JKSJ15/libraryAPI.gitcd libraryAPIEdit application.properties
./mvnw spring-boot:runThis project was built to simulate a real-world library system, where users can explore a book catalog and administrators manage the collection.
It focuses on applying professional back-end concepts such as:
- Security with JWT
- Layered architecture
- Testing strategies
- Monitoring and observability
Using Java and Spring Boot.