A robust and modular RESTful API for a Bookstore application, built using Java Spring Boot as part of a backend developer assignment. This API enables book and user management with features like JWT authentication, CRUD operations, filtering, search, pagination, and interactive Swagger documentation.
- Language: Java 17+
- Framework: Spring Boot
- Database: MySQL
- ORM: JPA/Hibernate
- Authentication: JWT (JSON Web Tokens)
- Documentation: Swagger / OpenAPI (Springdoc)
- Dependencies: Lombok, Spring Security, Spring Data JPA, MySQL Driver
- Signup & Login with JWT-based authentication.
- Secure protected routes using tokens.
- Full CRUD for books.
- Filter books by
author,category, andrating. - Search books by
title(partial match supported).
- Proper HTTP status codes (
400,401,404, etc.) - Input validation for all endpoints.
- Pagination: Paginated book listing with sorting support.
- Swagger UI: Live API docs at
/swagger-ui.html. - Clean Architecture: Services, controllers, DTOs, repositories, and security are modularly separated.
- Java 17+
- MySQL installed and running
- Maven installed
- Postman (optional, for testing with screenshots)
git clone <repository-url>
cd bookstoreCreate a database:
CREATE DATABASE bookstore_db;Update src/main/resources/application.properties:
spring.datasource.url=jdbc:mysql://localhost:3306/bookstore_db
spring.datasource.username=<your-username>
spring.datasource.password=<your-password>mvn clean install
mvn spring-boot:runApp starts at:
http://localhost:8080
Navigate to:
http://localhost:8080/swagger-ui.html
Explore and test endpoints interactively!
- POST
/api/auth/signup
{
"email": "user@example.com",
"password": "password123"
}- POST
/api/auth/login
{
"email": "user@example.com",
"password": "password123"
}β Response includes a
JWT Tokento use asAuthorization: Bearer <token>
- POST
/api/books
{
"title": "The Great Gatsby",
"author": "F. Scott Fitzgerald",
"category": "Fiction",
"price": 10.99,
"rating": 4.5,
"publishedDate": "1925-04-10"
}- GET
/api/books
- GET
/api/books/{id}
- PUT
/api/books/{id}
- DELETE
/api/books/{id}
- GET
/api/books/filter?author=<author>&category=<category>&rating=<rating>
Example:
/api/books/filter?author=Fitzgerald&category=Fiction&rating=4
- GET
/api/books/search?keyword=<keyword>
Example:
/api/books/search?keyword=Gatsby
- GET
/api/books/paginated?page=<page>&size=<size>&sortBy=<field>
Example:
/api/books/paginated?page=0&size=5&sortBy=price
Located in the screenshots/ folder:
signup.pngβ User signuplogin.pngβ User login (JWT)create-book.pngβ Book creationget-all-books.pngβ Fetch all booksfilter-books.pngβ Filter books
- All book-related APIs require JWT authentication.
- Rating must be a value between 0 and 5.
- Pagination defaults:
page=0,size=5,sortBy=price. - MySQL is the default DB (adjustable in
application.properties).
- Swagger UI for easy testing and understanding.
- Paginated + sorted responses for large datasets.
- Flexible filtering with custom repository queries.
bookstore/
βββ src/
β βββ main/
β β βββ java/com/bookstore/bookstore/
β β β βββ controller/ # REST Controllers
β β β βββ dto/ # DTOs
β β β βββ entity/ # Entities
β β β βββ repository/ # JPA Repositories
β β β βββ security/ # JWT & Security Config
β β β βββ service/ # Business Logic
β βββ resources/
β βββ application.properties
βββ pom.xml
- Start the app.
- Use Postman or Swagger UI to hit the endpoints.
- Refer to screenshots for sample requests.
- GitHub: Share the public repo URL
- ZIP: Or package and upload the project directory
Built with β€οΈ for learning, growth, and backend excellence.









