Skip to content

Book Review Hub is a comprehensive and scalable book review platform built with a modern backend architecture using Spring Boot and MySQL. Designed as a learning-oriented, Goodreads-inspired application, it follows industry best practices for system design, database management, and API security.

Notifications You must be signed in to change notification settings

tlavu2004/book-review-hub-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š Book Review Hub - Backend

Java Spring Boot License: MIT Build

This is the backend service for Book Review Hub, a web application that allows users to review, rate, and discover books.

It provides a RESTful API for managing users, books, genres, and reviews, with authentication and authorization features.


πŸ—‚οΈ Table of Contents


πŸš€ Basic Features

  • βœ… User registration & login
  • βœ… Role-based access control (user, moderator, admin)
  • βœ… Book management with genres
  • βœ… Book reviews and rating system
  • βœ… Review voting (upvote/downvote)
  • βœ… Validation and error handling
  • βœ… Secure password hashing and authentication
  • βœ… RESTful API design
  • βœ… Database versioning with Flyway (development only)

🧱 Tech Stack

Layer Technology
Language Java 21
Framework Spring Boot 3.4.4
Build Tool Maven
Database MySQL (Railway)
ORM Spring Data JPA (Hibernate)
Migration Tool Flyway
Auth Spring Security + JWT
Validation Bean Validation (Hibernate)
Development Lombok, Spring DevTools
Deployment Render.com (Backend)

πŸ“‚ Project Structure

(MVP Stage)

bookreviewhub-backend/
β”œβ”€β”€ .gitattributes
β”œβ”€β”€ .gitignore
β”œβ”€β”€ mvnw
β”œβ”€β”€ mvnw.cmd
β”œβ”€β”€ pom.xml
β”œβ”€β”€ README.md
└── src/
    β”œβ”€β”€ main/
    β”‚   β”œβ”€β”€ java/
    β”‚   β”‚   └── com/
    β”‚   β”‚       └── bookreviewhub/
    β”‚   β”‚           └── backend/
    β”‚   β”‚               β”œβ”€β”€ BookReviewHubApplication.java
    β”‚   β”‚               β”œβ”€β”€ common/                                             # Share the whole application
    β”‚   β”‚               β”‚   β”œβ”€β”€ dto/
    β”‚   β”‚               β”‚   β”‚   └── response/
    β”‚   β”‚               β”‚   β”‚       β”œβ”€β”€ ErrorResponse.java
    β”‚   β”‚               β”‚   β”‚       └── SuccessResponse.java
    β”‚   β”‚               β”‚   β”œβ”€β”€ exception/
    β”‚   β”‚               β”‚   β”‚   └── GlobalExceptionHandler.java
    β”‚   β”‚               β”‚   └── security/
    β”‚   β”‚               β”‚       β”œβ”€β”€ jwt/
    β”‚   β”‚               β”‚       β”‚	└── JwtService.java
    β”‚   β”‚               β”‚       β”œβ”€β”€ filter/
    β”‚   β”‚               β”‚       β”‚	└── JwtAuthenticationFilter.java
    β”‚   β”‚               β”‚       └── handler/
    β”‚   β”‚               β”‚			β”œβ”€β”€ CustomAccessDeniedHandler.java
    β”‚   β”‚               β”‚			└── CustomAuthenticationEntryPoint.java
    β”‚   β”‚               β”œβ”€β”€ config/
    β”‚   β”‚               β”‚   β”œβ”€β”€ JwtConfig.java
    β”‚   β”‚               β”‚   └── SecurityConfig.java
    β”‚   β”‚               β”œβ”€β”€ auth/
    β”‚   β”‚               β”‚   β”œβ”€β”€ controller/
    β”‚   β”‚               β”‚   β”‚   └── AuthController.java
    β”‚   β”‚               β”‚   β”œβ”€β”€ dto/
    β”‚   β”‚               β”‚   β”‚   β”œβ”€β”€ request/
    β”‚   β”‚               β”‚   β”‚   β”‚   β”œβ”€β”€ LoginRequest.java
    β”‚   β”‚               β”‚   β”‚   β”‚   └── RegisterRequest.java
    β”‚   β”‚               β”‚   β”‚   └── response/
    β”‚   β”‚               β”‚   β”‚       └── AuthResponse.java
    β”‚   β”‚               β”‚   β”œβ”€β”€ entity/
    β”‚   β”‚               β”‚   β”‚   └── User.java
    β”‚   β”‚               β”‚   β”œβ”€β”€ repository/
    β”‚   β”‚               β”‚   β”‚   └── UserRepository.java
    β”‚   β”‚               β”‚   └── service/
    β”‚   β”‚               β”‚       β”œβ”€β”€ AuthService.java
    β”‚   β”‚               β”‚       └── CustomUserDetailsService.java
    β”‚   β”‚               └── testapi/
    β”‚   β”‚                   └── controller/
    β”‚   β”‚                       └── TestController.java
    β”‚   β”‚
    β”‚   └── resources/
    β”‚       β”œβ”€β”€ application.properties
    β”‚       β”œβ”€β”€ application-dev.properties
    β”‚       β”œβ”€β”€ application-prod.properties
    β”‚       β”œβ”€β”€ static                                                          # (currently empty)
    β”‚       β”œβ”€β”€ templates                                                       # (currently empty)
    β”‚       └── db/
    β”‚           └── migration/
    β”‚               β”œβ”€β”€ R__mvp_seed_data.sql
    β”‚               └── V1__init_schema.sql
    └── test/
        └── com/
            └── bookreviewhub/
                └── backend/
                    └── ...

βš™οΈ Configuration

Environment-specific configurations are defined in:

  • src/main/resources/application.properties
  • src/main/resources/application-dev.properties
  • src/main/resources/application-prod.properties

Profiles:

Profile File Used for Flyway Hibernate
dev application-dev.properties Local development Auto-migrate validate
prod application-prod.properties Production No migration validate
test application-test.properties Testing (Optional) Manual or none create-drop or none

Note

In production, Flyway migrations are not applied automatically. Always set spring.jpa.hibernate.ddl-auto=validate to ensure schema integrity.


πŸ› οΈ Prerequisites

  • Java 21
  • Maven 3.8+
  • MySQL 8.0+ database (locally or via a cloud provider like Railway)
  • (Optional) Docker (for containerization, future support planned)

πŸ› οΈ Set Up Database

1. Create Database

  • Create a MySQL database, e.g., bookreviewhub_db.
  • (Optional) Host on Railway or any MySQL provider.

2. (Development only) Apply Schema

  • The initial schema is available at src/main/resources/db/migration/V1__init_schema.sql (any other schema will be placed here).
  • Flyway will automatically apply migrations in dev profile when the app starts.

Or you can manually import the SQL file if needed.

3. Entity Relationship Diagram for this project

Coming soon (under preparation)


▢️ Run the Application

1. Clone the repository

git clone https://github.com/tlavu2004/bookreviewhub-backend.git
cd bookreviewhub-backend

2. Build the application

./mvnw clean install -DskipTests

or

mvn clean package

3. Run the application

Using Maven:

./mvnw spring-boot:run "-Dspring-boot.run.profiles=dev" 

Or use IntelliJ / VSCode Spring Boot run configuration.

Note

  • Replace dev with prod or any another profile name as needed.
  • When using Flyway, new migration scripts (if any) will be automatically applied to your database, tracked by the flyway_schema_history table.

4. Optional Commands:

  • Reset database (development only):
./mvnw flyway:clean

# Apply migrations manually (in development)
./mvnw flyway:migrate "-Dspring-boot.run.profiles=dev"

Warning

  • This will drop all tables and reapply migrations.
  • Never run this in production!

πŸ“¬ API Documentation

Swagger UI is configured but not yet deployed.
It will be available soon at:

http://localhost:8080/swagger-ui/index.html

(Coming soon)

πŸ” Authentication

  • This project uses JWT (JSON Web Tokens) for authentication.
  • After registering or logging in via /api/auth/login, you will receive a JWT token.
  • Use this token in the Authorization header for all protected endpoints:
Authorization: Bearer <your-token-here>

(Authentication endpoints are fully functional for MVP stage.)


πŸ“‹ Planned Features (under evaluation)

βœ…

No. Feature Description Importance Complexity Roles Done
1 Login 5/5 Easy All
2 Register 5/5 Easy Users
3 Add books (edit if user is the owner) 4/5 Medium All
4 View book details 5/5 Easy All
5 Add book to favorites (bookmark) 4/5 Medium All
6 Write a review 5/5 Medium All
7 Star rating 4/5 Medium All
8 Upvote/Downvote reviews 3/5 Medium All
9 View others' reviews 5/5 Easy All
10 Manage review history (delete if needed) 3/5 Medium All (except users who did not create the review)
11 Search books by name 5/5 Easy All
12 Filter by genre, author, etc. 3/5 Hard All
13 Pagination 3/5 Medium All
14 View, edit and approve reviews 4/5 Medium Moderators, Admins
15 Manage book list 4/5 Medium Moderators, Admins
16 Manage review list 4/5 Medium Moderators, Admins
17 View user list 3/5 Easy Admins
18 View user details 3/5 Medium Admins
19 Manage books (remove or edit inappropriate books) 4/5 Medium Moderators, Admins
20 View stats (books, members count, etc.) 3/5 Hard Admins
21 Manage reviews (edit/delete any reviews) 5/5 Medium Moderators, Admins
22 Ban/Unban Users 4/5 Hard Admins

πŸ› οΈ Features implemented at MVP Stage

No. Feature Description
1 Login
2 Register
3 Add books (edit if user is the owner)
4 View book details
6 Write a review
9 View others' reviews
11 Search books by name

🧩 Future Improvements (unevaluated features)

  • Email confirmation when registering.
  • Full-text search for books and authors.
  • Report abusive reviews.
  • Insert images into reviews.
  • User promotion/demotion features.
  • Statistics dashboard for admins.
  • ...

πŸ“„ License

This project is under the MIT License.

About

Book Review Hub is a comprehensive and scalable book review platform built with a modern backend architecture using Spring Boot and MySQL. Designed as a learning-oriented, Goodreads-inspired application, it follows industry best practices for system design, database management, and API security.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages