Backend API for a book community platform.
Users browse books, rate & review; admins manage the catalog.
Book Forum is a backend API for a book community platform β think of it as the engine behind a reading app where people discover, discuss, and share their love for books.
- Readers browse the book catalog, search by title/author/category
- Users sign up (email or Google/GitHub), verify email, rate books, leave comments
- Admins add new books, upload covers, manage the catalog
- Security handles authentication, authorization, and rate limiting automatically
| Category | Features |
|---|---|
| Auth | JWT tokens, OAuth2 (Google/GitHub), email verification, password reset |
| Books | CRUD, search, filter, pagination, categories, authors |
| Social | Ratings, comments, user profiles |
| Security | BCrypt, rate limiting, CORS, input validation |
| Cloud | Cloudinary images, Swagger docs, health checks |
# Clone
git clone https://github.com/yourusername/book-forum-backend.git
cd book-forum-backend
# Configure (see .env.example)
cp .env.example .env
# Edit .env with your credentials
# Run
mvn spring-boot:runServer starts at http://localhost:8080
Create .env file with:
# Database
SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/book_forum
SPRING_DATASOURCE_USERNAME=your_user
SPRING_DATASOURCE_PASSWORD=your_password
# JWT
JWT_SECRET=your_secret_key_min_32_chars
JWT_EXPIRATION=1800000
# OAuth2
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_secret
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_secret
# Email (SMTP)
SPRING_MAIL_HOST=smtp.gmail.com
SPRING_MAIL_USERNAME=your_email
SPRING_MAIL_PASSWORD=your_app_password
# Cloudinary
CLOUDINARY_CLOUD_NAME=your_cloud
CLOUDINARY_API_KEY=your_key
CLOUDINARY_API_SECRET=your_secret
# Frontend URL
APP_FRONTEND_URL=http://localhost:3000| Method | Endpoint | Description |
|---|---|---|
| POST | /api/register |
Register user |
| POST | /api/login |
Login |
| GET | /oauth2/authorization/google |
Google OAuth |
| GET | /oauth2/authorization/github |
GitHub OAuth |
| POST | /api/forgot-password |
Password reset |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/books |
List books (paginated) |
| GET | /api/bookid/{id} |
Get book |
| GET | /api/books/search |
Search books |
| POST | /api/addbook |
Add book (Admin) |
| PUT | /api/book/{id} |
Update book (Admin) |
| DELETE | /api/book/{id} |
Delete book (Admin) |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/book/{id}/ratings |
Get ratings |
| POST | /api/book/{id}/rating |
Add rating |
| GET | /api/book/{id}/comment |
Get comments |
| POST | /api/book/{id}/comment |
Add comment |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/user/profile |
Get profile |
| PATCH | /api/user/update-name |
Update name |
| GET | /api/health |
Health check |
Interactive API Documentation: http://api.backend.app/swagger-ui/index.html
- Login β receive
token+refreshToken - Include
Authorization: Bearer <token>in requests - Token expires in 30 min, refresh token in 7 days
- Redirect to
/oauth2/authorization/googleor/github - User authenticates with provider
- Callback redirects to frontend with JWT
Users βββ¬ββ OAuthProvider (1:N)
βββ Comment (1:N)
βββ Rating (1:N)
Book ββββ¬ββ Comment (1:N)
βββ Rating (1:N)
Tables: users, book, comment, rating, oauth_provider
mvn test # All tests
mvn test -Dtest=BookControllerTest # Specific test# Build JAR
mvn clean package -DskipTests
# Run JAR
java -jar target/Book-Forum-API.jarMIT License - See LICENSE
Author: Mohan