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.
- π Basic Features
- π§± Tech Stack
- π Project Structure
- βοΈ Configuration
- π οΈ Set Up Database
βΆοΈ Run the Application- π¬ API Documentation
- π Planned Features (under evaluation)
- π οΈ Features Implemented at MVP Stage
- π§© Future Improvements (unevaluated features)
- π License
- β 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)
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) |
(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/
βββ ...
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.
- Java 21
- Maven 3.8+
- MySQL 8.0+ database (locally or via a cloud provider like Railway)
- (Optional) Docker (for containerization, future support planned)
- Create a MySQL database, e.g., bookreviewhub_db.
- (Optional) Host on Railway or any MySQL provider.
- 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.
Coming soon (under preparation)
git clone https://github.com/tlavu2004/bookreviewhub-backend.git
cd bookreviewhub-backend
./mvnw clean install -DskipTests
or
mvn clean package
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.
- 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!
Swagger UI is configured but not yet deployed.
It will be available soon at:
http://localhost:8080/swagger-ui/index.html
(Coming soon)
- 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.)
β
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 |
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 |
- 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.
- ...
This project is under the MIT License.