Skip to content

ArslanXa/ZyneticBookStoreBackend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README for Zynetic Assignment Repository

Setup Instructions

1. Clone the Repository

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.

2. Navigate to the Project Directory

Move into the cloned directory:

cd SpringSecEx

3. Build the Project

The project uses Gradle for building. Run the following command to build the project:

mvn install

4. Run the Application

Start the application using:

mvn spring-boot:run

5. Docker Setup (Optional)

If 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

API Endpoints and Sample Requests

Refer to the documentation section for full details on available API endpoints and example usage.

🔐 Authentication Endpoints

MethodEndpointDescription
POST/api/auth/registerUser registration
POST/api/auth/loginJWT 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>

📘 Book Endpoints

MethodEndpointDescription
POST/api/books/createCreate a book
GET/api/books/getallbooksAll books
GET/api/books/{id}Book by ID
PUT/api/books/{id}Update book
DELETE/api/books/{id}Delete book
GET/api/books/searchSearch by title
GET/api/books/filterFilter books
GET/api/books/sortSort books
GET/api/books/getallbookspagedPaginated 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 }

✅ Completed Features

  • JWT Authentication
  • Book CRUD
  • Search / Filter / Sort
  • Pagination
  • Swagger Documentation
  • Dockerization

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published