Skip to content

A comprehensive backend for a digital bookstore. This Spring Boot API uses Spring Data JPA to manage a catalog of books and authors, providing endpoints for adding, retrieving, updating, and searching for literary works.

Notifications You must be signed in to change notification settings

w0lzard/Biblioteka-Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š Biblioteka - Online Bookstore API

Spring Boot Java License Build Status API Status

A comprehensive REST API for managing an online bookstore with advanced search capabilities

πŸš€ Quick Start β€’ πŸ“– API Documentation β€’ πŸ§ͺ Testing β€’ πŸ”§ Configuration


✨ Features

πŸ“– Book Management

  • βœ… Full CRUD operations
  • βœ… ISBN-based lookups
  • βœ… Stock quantity tracking
  • βœ… Price and publication management
  • βœ… Multi-language support

πŸ‘¨β€πŸ’Ό Author Management

  • βœ… Author profiles with biographies
  • βœ… Birth date tracking
  • βœ… Book count statistics
  • βœ… Name-based search

🏷️ Genre Management

  • βœ… Genre categorization
  • βœ… Popularity rankings
  • βœ… Description management
  • βœ… Book count per genre

πŸ” Advanced Search

  • βœ… Multi-criteria filtering
  • βœ… Price range queries
  • βœ… Date-based filtering
  • βœ… Stock availability checks

πŸ› οΈ Technology Stack

Technology Version Purpose
Java 24 Core Language
Spring Boot 3.5.6 Framework
Spring Data JPA Latest Data Access
H2 Database Latest Development DB
MySQL 8.0+ Production DB
Gradle 8.14.3 Build Tool

πŸš€ Quick Start

πŸ“‹ Prerequisites

β˜‘οΈ Java 24 or higher
β˜‘οΈ Gradle (included via wrapper)
β˜‘οΈ Your favorite API testing tool (Postman, curl, etc.)

πŸƒβ€β™‚οΈ Running the Application

πŸ”§ 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

πŸ—„οΈ Database Access

πŸ”§ Development (H2)
http://localhost:8080/h2-console
JDBC URL: jdbc:h2:mem:bookstore
Username: sa | Password: password

πŸ“– API Documentation

🌟 Base URL: http://localhost:8080/api

πŸ“š Books API

πŸ“– 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 βœ…

πŸ‘¨β€πŸ’Ό Authors API

πŸ‘€ 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 βœ…

🏷️ Genres API

πŸ“‚ 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 βœ…

πŸ§ͺ Testing

πŸš€ Quick Test Commands

πŸ“š 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"

🎯 Automated Testing

Run the comprehensive test script:

chmod +x api-test-examples.sh
./api-test-examples.sh

πŸ”§ Configuration

🏠 Development Environment

πŸ—„οΈ Database: H2 In-Memory
🌐 Port: 8080
πŸ” H2 Console: /h2-console
πŸ“Š Logging: DEBUG level

πŸ”§ Auto-reload: Enabled
πŸ“ DDL: create-drop
πŸ” SQL Logging: Enabled
⚑ Performance: Development optimized

πŸš€ Production Setup

🐬 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

πŸ›‘οΈ Error Handling

Status Code Description Example
200 Successful GET requests Data retrieved
201 Successful POST requests Resource created
204 Successful DELETE requests Resource deleted
400 Validation errors Invalid input data
404 Resource not found Book ID doesn't exist
409 Resource already exists Duplicate ISBN
500 Internal server error Database connection issue

πŸ—οΈ Building & Deployment

πŸ“¦ Local Development

# Build the project
./gradlew build

# Run tests
./gradlew test

# Start application
./gradlew bootRun

πŸš€ Production Build

# Create production JAR
./gradlew build

# Run production build
java -jar build/libs/Biblioteka-0.0.1-SNAPSHOT.jar

πŸ“Š Project Statistics

Metric Count Status
πŸ“š API Endpoints 32+ βœ… Fully Tested
πŸ” Search Methods 15+ βœ… Working
πŸ›‘οΈ Validation Rules 20+ βœ… Active
πŸ“ Entity Classes 3 βœ… Complete
πŸ”§ Service Methods 50+ βœ… Implemented

🀝 Contributing

Found a bug? Report it
Have an idea? Suggest a feature
Want to contribute? Fork the repo


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Built with ❀️ using Spring Boot | © 2025 Biblioteka

About

A comprehensive backend for a digital bookstore. This Spring Boot API uses Spring Data JPA to manage a catalog of books and authors, providing endpoints for adding, retrieving, updating, and searching for literary works.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published