Clone the repository to your local machine using the following command:
git clone (https://github.com/ArslanXa/ZyneticBookStoreBackend.git)But, preferably download the zip file from Google Forms.
Move into the cloned directory:
cd SpringSecExThe project uses Gradle for building. Run the following command to build the project:
mvn installStart the application using:
mvn spring-boot:runIf you prefer to run the application in a Docker container:
- Build the Docker image:
docker build -t SpringSecEx . - Run the Docker container:
docker run -p 8080:8090 SpringSecEx
Refer to the documentation section for full details on available API endpoints and example usage.
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register | User registration |
| POST | /api/auth/login | JWT login |
Sample Request/Response for Signup
POST /api/auth/register Content-Type: application/json
{ "email": "user@example.com", "password": "securePass123" }
200 OK
{
"token": "jwt_token_here"
}Sample Request/Response for Login
POST /api/auth/login Content-Type: application/json
{ "email": "user@example.com", "password": "securePass123" }
200 OK
{
"token": "jwt_token_here"
}Use JWT token in header:
Authorization: Bearer <your_token>| Method | Endpoint | Description |
|---|---|---|
| POST | /api/books/create | Create a book |
| GET | /api/books/getallbooks | All books |
| GET | /api/books/{id} | Book by ID |
| PUT | /api/books/{id} | Update book |
| DELETE | /api/books/{id} | Delete book |
| GET | /api/books/search | Search by title |
| GET | /api/books/filter | Filter books |
| GET | /api/books/sort | Sort books |
| GET | /api/books/getallbookspaged | Paginated list of books |
Sample Request/Response for Creating a Book
POST /api/books/create Content-Type: application/json
{ "id": 1, "title": "The Alchemist", "author": "Paulo Coelho", "category": "Novel", "price": 350, "rating": 4.8, "publishedDate": "1993-08-01" }
200 OK
{
"id": 1,
"title": "The Alchemist",
"author": "Paulo Coelho",
"category": "Novel",
"price": 350,
"rating": 4.8,
"publishedDate": "1993-08-01"
}Sample Response for Get Book by ID
GET /api/books/1
Response: 200 OK { "id": 1, "title": "The Alchemist", "author": "Paulo Coelho", "category": "Novel", "price": 350, "rating": 4.8, "publishedDate": "1993-08-01" }
Sample Request/Response for Update Book
PUT /api/books/1 Content-Type: application/json
{ "id": 1, "title": "The Alchemist - Updated", "author": "Paulo Coelho", "category": "Novel", "price": 400, "rating": 4.9, "publishedDate": "1993-08-01" }
200 OK
{
"id": 1,
"title": "The Alchemist - Updated",
"author": "Paulo Coelho",
"category": "Novel",
"price": 400,
"rating": 4.9,
"publishedDate": "1993-08-01"
}Sample Response for Get All Books
GET /api/books/getallbooks
Response: 200 OK [ { "id": 1, "title": "The Alchemist", "author": "Paulo Coelho", "category": "Novel", "price": 350, "rating": 4.8, "publishedDate": "1993-08-01" } ]
Sample Response for Search by Title
GET /api/books/search?title=alchemist
Response: 200 OK [ { "id": 1, "title": "The Alchemist", "author": "Paulo Coelho", "category": "Novel", "price": 350, "rating": 4.8, "publishedDate": "1993-08-01" } ]
Sample Response for Filter
GET /api/books/filter?author=Paulo&category=Novel&rating=4.5
Response: 200 OK [ { "id": 1, "title": "The Alchemist", "author": "Paulo Coelho", "category": "Novel", "price": 350, "rating": 4.8, "publishedDate": "1993-08-01" } ]
Sample Response for Sort
GET /api/books/sort?basedOn=rating&ascending=false
Response: 200 OK [ { "id": 1, "title": "The Alchemist", "author": "Paulo Coelho", "category": "Novel", "price": 350, "rating": 4.8, "publishedDate": "1993-08-01" } ]
Sample Response for Pagination
GET /api/books/getallbookspaged?page=0&size=5&sort=price,desc
Response: 200 OK { "content": [ { "id": 1, "title": "The Alchemist", "author": "Paulo Coelho", "category": "Novel", "price": 350, "rating": 4.8, "publishedDate": "1993-08-01" } ], "pageNumber": 0, "pageSize": 5, "totalElements": 1, "totalPages": 1, "last": true }
- JWT Authentication
- Book CRUD
- Search / Filter / Sort
- Pagination
- Swagger Documentation
- Dockerization