A comprehensive REST API for managing an online bookstore with advanced search capabilities
π Quick Start β’ π API Documentation β’ π§ͺ Testing β’ π§ Configuration
|
|
| Technology | Version | Purpose |
|---|---|---|
| 24 | Core Language | |
| 3.5.6 | Framework | |
| Latest | Data Access | |
| Latest | Development DB | |
| 8.0+ | Production DB | |
| 8.14.3 | Build Tool |
βοΈ Java 24 or higher
βοΈ Gradle (included via wrapper)
βοΈ Your favorite API testing tool (Postman, curl, etc.)π§ Development Setup
# 1οΈβ£ Clone the repository
git clone <repository-url>
cd Biblioteka
# 2οΈβ£ Build the project
./gradlew build
# 3οΈβ£ Run the application
./gradlew bootRunπ Application will start on http://localhost:8080
π§ Development (H2)http://localhost:8080/h2-consoleJDBC URL: jdbc:h2:mem:bookstoreUsername: sa | Password: password
|
π Core Operations
| Method | Endpoint | Description | Status |
|---|---|---|---|
GET |
/books |
Get all books | β |
GET |
/books/{id} |
Get book by ID | β |
GET |
/books/isbn/{isbn} |
Get book by ISBN | β |
POST |
/books |
Create new book | β |
PUT |
/books/{id} |
Update book | β |
PATCH |
/books/{id}/stock?quantity={qty} |
Update stock | β |
DELETE |
/books/{id} |
Delete book | β |
π Search & Filtering
| Method | Endpoint | Description | Status |
|---|---|---|---|
GET |
/books/search/title?title={title} |
Search by title | β |
GET |
/books/search/author?author={author} |
Search by author | β |
GET |
/books/search/genre?genre={genre} |
Search by genre | β |
GET |
/books/search/publisher?publisher={pub} |
Search by publisher | β |
GET |
/books/search?title={}&author={}... |
Advanced multi-search | β |
GET |
/books/price-range?minPrice={}&maxPrice={} |
Price range filter | β |
GET |
/books/published-after?date={yyyy-mm-dd} |
Date filter | β |
GET |
/books/in-stock |
Available books | β |
GET |
/books/language/{language} |
Books by language | β |
GET |
/books/recent |
Recently added | β |
GET |
/books/low-stock?threshold={num} |
Low stock alert | β |
π€ Author Management
| Method | Endpoint | Description | Status |
|---|---|---|---|
GET |
/authors |
Get all authors | β |
GET |
/authors/{id} |
Get author by ID | β |
POST |
/authors |
Create new author | β |
PUT |
/authors/{id} |
Update author | β |
DELETE |
/authors/{id} |
Delete author | β |
GET |
/authors/search?name={name} |
Search by name | β |
GET |
/authors/search/firstname?firstName={name} |
Search by first name | β |
GET |
/authors/search/lastname?lastName={name} |
Search by last name | β |
GET |
/authors/with-books |
Authors with books | β |
GET |
/authors/{id}/book-count |
Author statistics | β |
π Genre Management
| Method | Endpoint | Description | Status |
|---|---|---|---|
GET |
/genres |
Get all genres | β |
GET |
/genres/{id} |
Get genre by ID | β |
GET |
/genres/name/{name} |
Get genre by name | β |
POST |
/genres |
Create new genre | β |
PUT |
/genres/{id} |
Update genre | β |
DELETE |
/genres/{id} |
Delete genre | β |
GET |
/genres/search?name={name} |
Search genres | β |
GET |
/genres/with-books |
Genres with books | β |
GET |
/genres/popular |
Popular genres | β |
GET |
/genres/{id}/book-count |
Genre statistics | β |
π Book Operations
# Create a book
curl -X POST http://localhost:8080/api/books \
-H "Content-Type: application/json" \
-d '{
"title": "The Great Gatsby",
"isbn": "9780743273565",
"description": "A classic American novel",
"publicationDate": "1925-04-10",
"price": 12.99,
"stockQuantity": 100,
"publisher": "Scribner",
"pageCount": 180,
"language": "English"
}'
# Search books by title
curl "http://localhost:8080/api/books/search/title?title=Gatsby"
# Get books in price range
curl "http://localhost:8080/api/books/price-range?minPrice=10&maxPrice=15"π¨βπΌ Author Operations
# Create an author
curl -X POST http://localhost:8080/api/authors \
-H "Content-Type: application/json" \
-d '{
"firstName": "Ernest",
"lastName": "Hemingway",
"birthDate": "1899-07-21",
"biography": "American novelist and journalist"
}'
# Search authors
curl "http://localhost:8080/api/authors/search?name=Hemingway"π·οΈ Genre Operations
# Create a genre
curl -X POST http://localhost:8080/api/genres \
-H "Content-Type: application/json" \
-d '{
"name": "Biography",
"description": "Non-fiction books about people'\''s lives"
}'
# Get popular genres
curl "http://localhost:8080/api/genres/popular"Run the comprehensive test script:
chmod +x api-test-examples.sh
./api-test-examples.sh|
ποΈ Database: H2 In-Memory |
π§ Auto-reload: Enabled |
π¬ MySQL Configuration
Update application.properties:
# MySQL Production Configuration
spring.datasource.url=jdbc:mysql://localhost:3306/bookstore?useSSL=false&serverTimezone=UTC
spring.datasource.username=your_username
spring.datasource.password=your_password
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
spring.jpa.hibernate.ddl-auto=validate# Build the project
./gradlew build
# Run tests
./gradlew test
# Start application
./gradlew bootRun# Create production JAR
./gradlew build
# Run production build
java -jar build/libs/Biblioteka-0.0.1-SNAPSHOT.jar| Metric | Count | Status |
|---|---|---|
| π API Endpoints | 32+ | β Fully Tested |
| π Search Methods | 15+ | β Working |
| π‘οΈ Validation Rules | 20+ | β Active |
| π Entity Classes | 3 | β Complete |
| π§ Service Methods | 50+ | β Implemented |
Found a bug? Report it
Have an idea? Suggest a feature
Want to contribute? Fork the repo
This project is licensed under the MIT License - see the LICENSE file for details.
Built with β€οΈ using Spring Boot | Β© 2025 Biblioteka