Book Social Network is a full-stack application that enables users to manage their book collections and engage with a community of book enthusiasts. It offers features such as user registration, secure email validation, book management (including creation, updating, sharing, and archiving), book borrowing with checks for availability, book return functionality, and approval of book returns. The application ensures security using JWT tokens and adheres to best practices in REST API design. The backend is built with Spring Boot 3 and Spring Security 6, postgreSQL database, while the frontend is developed using Angular with Bootstrap for styling.
- User Registration: Users can register for a new account.
- Email Validation: Accounts are activated using secure email validation codes.
- User Authentication: Existing users can log in securely.
- Book Management: Users can create, update, share, and archive their books.
- Book Borrowing: Necessary checks to determine if a book can be borrowed.
- Book Returning: Users can return borrowed books.
- Book Return Approval: Functionality to approve book returns.
- Spring Boot 3
- Spring Security 6
- JWT Token Authentication
- Spring Data JPA
- JSR-303 and Spring Validation
- OpenAPI and Swagger UI Documentation
- Docker
- PostgreSQL
- Angular
- Component-Based Architecture
- Lazy Loading
- Authentication Guard
- OpenAPI Generator for Angular
- Bootstrap
By following this project,
- Designing a class diagram from business requirements
- Implementing a mono repo approach
- Securing an application using JWT tokens with Spring Security
- Registering users and validating accounts via email
- Utilizing inheritance with Spring Data JPA
- Implementing the service layer and handling application exceptions
- Object validation using JSR-303 and Spring Validation
- Handling custom exceptions
- Implementing pagination and REST API best practices
- Using Spring Profiles for environment-specific configurations
- Documenting APIs using OpenAPI and Swagger UI
- Implementing business requirements and handling business exceptions
- Dockerizing the infrastructure
- CI/CD pipeline & deployment
-
Register User
- Method:
POST - URL:
http://localhost:8080/api/v1/auth/register - Request Body:
{ "firstname": "sandesh", "lastname": "bhujbal", "email": "bhujbalsandesh52@gmail.com", "password": "Password@123" } - Response:
202 Accepted
- Method:
-
Activate Account
- Method:
GET - URL:
http://localhost:8080/api/v1/auth/activate-account?token=<activation_token> - Response:
200 OK
- Method:
-
Login User
- Method:
POST - URL:
http://localhost:8080/api/v1/auth/authenticate - Request Body:
{ "email": "bhujbalsandesh52@gmail.com", "password": "Password@123" } - Response:
{ "token": "<JWT_access_token>" }- Success Code:
200 OK
- Success Code:
- Method:
All endpoints require a JWT token.
Include the following header in all requests:
Authorization: Bearer <JWT_access_token>- Method:
POST - URL:
http://localhost:8088/books - Request Body:
{ "title": "Java Spring Boot Book", "authorName": "James Gosling", "isbn": "4512", "synopsis": "Book about Java programming", "shareable": true } - Response Body:
{ "id": 58 } - Success Code:
200 OK
- Method:
GET - URL:
http://localhost:8088/books/{book-id} - Response Body:
{ "id": 58, "title": "Java Spring Boot Book", "authorName": "James Gosling", "isbn": "4512", "synopsis": "Book about Java programming", "rate": 4.5, "bookCover": "http://example.com/cover.jpg", "shareable": true, "archived": false } - Success Code:
200 OK
- Method:
GET - URL:
http://localhost:8088/books - Query Params:
page: Page number (default:0)size: Number of items per page (default:10)
- Response Body:
{ "content": [ { "id": 58, "title": "Java Spring Boot Book", "authorName": "James Gosling", "rate": 4.5 } ], "number": 0, "size": 10, "totalElements": 1, "totalPages": 1, "first": true, "last": true } - Success Code:
200 OK
- Method:
GET - URL:
http://localhost:8088/books/owner - Query Params: Same as Find All Books
- Response Body:
{ "content": [ { "id": 58, "title": "Java Spring Boot Book", "authorName": "James Gosling", "rate": 4.5 } ], "number": 0, "size": 10, "totalElements": 1, "totalPages": 1, "first": true, "last": true } - Success Code:
200 OK
- Method:
GET - URL:
http://localhost:8088/books/borrowed - Query Params: Same as Find All Books
- Response Body:
{ "content": [ { "bookId": 58, "title": "Java Spring Boot Book", "authorName": "James Gosling", "isbn": "4512", "borrowed": true, "returned": false, "returnApproved": false } ], "number": 0, "size": 10, "totalElements": 1, "totalPages": 1, "first": true, "last": true } - Success Code:
200 OK
- Method:
GET - URL:
http://localhost:8088/books/returned - Query Params: Same as Find All Books
- Response Body:
{ "content": [ { "bookId": 58, "title": "Java Spring Boot Book", "authorName": "James Gosling", "isbn": "4512", "borrowed": false, "returned": true, "returnApproved": true } ], "number": 0, "size": 10, "totalElements": 1, "totalPages": 1, "first": true, "last": true } - Success Code:
200 OK
- Method:
PATCH - URL:
http://localhost:8088/books/shareble/{book-id} - Response Body:
{ "id": 58, "shareable": false } - Success Code:
200 OK
- Method:
PATCH - URL:
http://localhost:8088/books/archived/{book-id} - Response Body:
{ "id": 58, "archived": true } - Success Code:
200 OK
- Method:
POST - URL:
http://localhost:8088/books/borrow/{book-id} - Response Body:
{ "id": 1, "bookId": 58, "borrowedBy": "sandesh", "borrowedAt": "2024-10-22T10:15:30Z" } - Success Code:
200 OK
- Method:
PATCH - URL:
http://localhost:8088/books/borrow/return/{book-id} - Response Body:
{ "id": 1, "bookId": 58, "returnedAt": "2024-10-22T10:16:36Z" } - Success Code:
200 OK
- Method:
PATCH - URL:
http://localhost:8088/books/borrow/return/approve/{book-id} - Response Body:
{ "id": 1, "bookId": 58, "returnApproved": true, "approvedAt": "2024-10-22T10:23:35Z" } - Success Code:
200 OK
- Method:
POST - URL:
http://localhost:8088/books/cover/{book-id} - Request: Multipart file upload
- Response Body:
{ "bookId": 58, "coverUrl": "http://example.com/book-covers/58.jpg", "uploadedAt": "2024-10-22T10:25:30Z" } - Success Code:
202 Accepted
To set up the backend of the Book Social Network project, follow these steps:
- Clone the repository:
git clone https://github.com/matnrocha/Book-Social-Network.git- Run the docker-compose file
docker-compose up -d- Navigate to the book-social-network directory:
cd book-social-network- Install dependencies (assuming Maven is installed):
mvn clean install- Run the application
java -jar target/book-network-0.0.1.jar- Access the API documentation using Swagger UI:
Open a web browser and go to `http://localhost:8088/api/v1/swagger-ui/index.html
- Access MailDev to receive emails (token receiving):
Open a web browser and go to `http://localhost:1080/#/







