Skip to content

A Spring-Boot powered ๐Ÿ“š Book Search Engine that allows users to search, add, update, and delete books using PostgreSQL and Docker.

License

Notifications You must be signed in to change notification settings

asadsaud25/Book-Search-Engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

19 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“š Book Search Engine

This is a basic search engine for books built using Spring Boot, Docker, and PostgreSQL. The current implementation allows users to search for books by a given search term, add new books to the database, update existing books, and delete books. ๐Ÿ”

โœจ Features

  • ๐Ÿ”Ž Search Books: A single endpoint to search for books by a search term.
  • โž• Add Books: An endpoint to add new books to the database.
  • โœ๏ธ Update Books: An endpoint to update existing books in the database.
  • ๐Ÿ—‘๏ธ Delete Books: An endpoint to delete books from the database.
  • ๐Ÿ” Search Books by ISBN: An endpoint to search for a book by its ISBN.
  • ๐Ÿ” Search Books by Author: An endpoint to search for books by an author's name.
  • ๐Ÿ” Search Books by Title: An endpoint to search for books by their title.
  • ๐Ÿ“ˆ Scalable Design: Built with Spring Boot, making it easy to add more features in the future.

๐Ÿ’ป Tech Stack

  • ๐Ÿ–ฅ๏ธ Backend: Java with Spring Boot
  • ๐Ÿ“‚ Database: PostgreSQL
  • ๐Ÿณ Containerization: Docker

๐Ÿš€ Getting Started

Prerequisites

  • Docker
  • Java 11 or higher
  • Maven

Running the Application

  1. Clone the repository:

    git clone https://github.com/asadsaud25/Book-Search-Engine.git
    cd book-search-engine
  2. Run the Docker containers:

    docker-compose up -d
  3. Build the project:

    mvn clean install
  4. Run the Spring Boot application:

    mvn spring-boot:run

Inserting Bulk CSV Data for Testing

For testing purposes, you can use the DbImporter.java file to insert bulk CSV data from github gist into the database.

  1. Ensure the database is running:

    docker-compose up -d
  2. Run the DbImporter.java file:

    mvn exec:java -Dexec.mainClass="com.h2.DBImporter"

API Endpoints

  • Search Books: GET /books/search?searchTerm={searchTerm}

    • Example: GET /books/search?searchTerm=Python
    • Response: A list of books matching the search term.
  • Add Book: POST /books/add

    • Request Body:
      {
          "title": "Java Programming",
          "description": "A comprehensive guide to Java programming.",
          "isbn": "123-456-7890",
          "rating": 4.5,
          "language": "English",
          "bookFormat": "PDF",
          "edition": "1st",
          "pages": 500,
          "publisher": "Oracle",
          "publishDate": "2021-01-01",
          "firstPublishDate": "2020-01-01",
          "likedPercent": 90,
          "price": 150.00,
          "authors": ["James Gosling"]
      }
    • Response: The added book details.
  • Update Book: PUT /books/update/{isbn}

    • Request Body:
      {
          "title": "Advanced Java Programming",
          "description": "An advanced guide to Java programming.",
          "rating": 4.8,
          "language": "English",
          "bookFormat": "Hardcover",
          "edition": "2nd",
          "pages": 600,
          "publisher": "Oracle",
          "publishDate": "2022-01-01",
          "firstPublishDate": "2020-01-01",
          "likedPercent": 95,
          "price": 200.00,
          "authors": ["James Gosling"]
      }
    • Response: The updated book details.
  • Delete Book: DELETE /books/delete/{isbn}

    • Example: DELETE /books/delete/123-456-7890
    • Response: A message indicating the book was successfully deleted.
  • Search Book by ISBN: GET /books/search/{isbn}

    • Example: GET /books/search/123-456-7890
    • Response: The book details matching the ISBN.
  • Search Books by Author: GET /books/search/author?authorName={authorName}

    • Example: GET /books/search/author?authorName=James Gosling
    • Response: A list of books matching the author's name.
  • Search Books by Title: GET /books/search/title?title={title}

    • Example: GET /books/search/title?title=Java Programming
    • Response: A list of books matching the title.

๐Ÿ› ๏ธ Development

Running Tests

To run the tests, use the following command:

mvn test

๐Ÿ“„ License

This project is licensed under the MIT License - MIT LICENSE

๐Ÿ”ฎ Future Plans

Security

  • Authentication and Authorization: Implement Spring Security to secure the API endpoints.
  • Role-Based Access Control: Define roles and permissions to control access to different parts of the application.
  • OAuth2/JWT: Integrate OAuth2 and JWT for token-based authentication.

About

A Spring-Boot powered ๐Ÿ“š Book Search Engine that allows users to search, add, update, and delete books using PostgreSQL and Docker.

Topics

Resources

License

Stars

Watchers

Forks