Skip to content

Commit

Permalink
added readme
Browse files Browse the repository at this point in the history
  • Loading branch information
adhikareeprayush committed Aug 9, 2024
1 parent ddaa0d8 commit bb19115
Show file tree
Hide file tree
Showing 9 changed files with 821 additions and 4 deletions.
174 changes: 174 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
# TheBookDB

TheBookDB is a powerful API built using C++ and the Drogon framework. It provides information about over 11,000 books, sourced from a Kaggle CSV file.

## Features

- Retrieve book information
- Filter books by various criteria
- Add new books to the database
- Update existing book information
- Delete books from the database

## API Endpoints

- `GET /books`: Retrieve a list of books
- `GET /books/filter`: Filter books based on specific criteria
- `POST /books`: Add a new book
- `PATCH /books/{bookID}`: Update an existing book
- `DELETE /books/{bookID}`: Delete a book
- `PUT /books/{bookID}`: Update or add a book

## Technology Stack

- C++
- Drogon framework
- JsonCpp
- Linux (Ubuntu)

## Installation

Thank you for providing the additional dependency information. I'll update the README to include these dependencies. Here's the revised Installation section:

### Prerequisites

Ensure you have the following dependencies installed on your Ubuntu system:

1. Environment setup:

```
sudo apt install git gcc g++ cmake
```

2. JsonCpp:

```
sudo apt install libjsoncpp-dev
```

3. UUID:

```
sudo apt install uuid-dev
```

4. zlib:

```
sudo apt install zlib1g-dev
```

5. OpenSSL (Optional, for HTTPS support):

```
sudo apt install openssl libssl-dev
```

### Building the Project

1. Clone the repository:

```
git clone https://github.com/yourusername/TheBookDB.git
```

2. Navigate to the project directory:

```
cd TheBookDB
```

3. Create a build directory and navigate to it:

```
mkdir build && cd build
```

4. Generate the build files:

```
cmake ..
```

5. Build the project:

```
make
```

6. Run the server:

```
./MyDrogonAPI
```

The server should now be running and ready to accept requests.

## Usage

Once the server is running, you can make HTTP requests to the API endpoints. Here are some examples:

- Get all books:

```
GET http://localhost:8080/books
```

- Filter books:

```
GET http://localhost:8080/books/filter?startDate=01/01/2000&endDate=12/31/2020
```

- Add a new book:

```
POST http://localhost:8080/books
Content-Type: application/json
{
"title": "New Book",
"authors": "John Doe",
"publicationDate": "05/15/2023"
}
```

- Update a new existing (Patch):

```
Patch http://localhost:8080/books/{bookID}
Content-Type: application/json
{
"title": "New Book title",
"authors": "John Doe",
"publicationDate": "05/15/2023"
}
```

- Add or update a book (PUT):

```
PUT http://localhost:8080/books/{bookID}
Content-Type: application/json
{
"title": "Edited or Added Title",
"authors": "John Doe",
"publicationDate": "05/15/2023"
}
```

- Delete a book:

```
DELETE http://localhost:8080/books/{bookID}
```

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
Empty file modified build/MyDrogonAPI
100755 → 100644
Empty file.
17 changes: 17 additions & 0 deletions build/book.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions build/books.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bookID,title,authors,avgRating,isbn,isbn13,languageCode,numPages,ratingsCount,textReviewsCount,publicationDate,publisher
1,Harry Potter and the Half-Blood Prince (Harry Potter #6),J.K. Rowling/Mary GrandPré,4.57,0439785960,9780439785969,eng,652,2095690,27591,9/16/2006,Scholastic Inc.
1,Harry Potter and the Half-Blood Prince (Harry Potter #6),J.K. Rowling/Mary GrandPré,4.50,0439785960,9780439785969,eng,652,2095690,27591,9/16/2006,Scholastic Inc.
2,Harry Potter and the Order of the Phoenix (Harry Potter #5),J.K. Rowling/Mary GrandPré,4.49,0439358078,9780439358071,eng,870,2153167,29221,9/1/2004,Scholastic Inc.
4,Harry Potter and the Chamber of Secrets (Harry Potter #2),J.K. Rowling,4.42,0439554896,9780439554893,eng,352,6333,244,11/1/2003,Scholastic
5,Harry Potter and the Prisoner of Azkaban (Harry Potter #3),J.K. Rowling/Mary GrandPré,4.56,043965548X,9780439655484,eng,435,2339585,36325,5/1/2004,Scholastic Inc.
Expand Down Expand Up @@ -11126,4 +11126,4 @@ bookID,title,authors,avgRating,isbn,isbn13,languageCode,numPages,ratingsCount,te
45634,The Ice-Shirt (Seven Dreams #1),William T. Vollmann,3.96,0140131965,9780140131963,eng,415,820,95,8/1/1993,Penguin Books
45639,Poor People,William T. Vollmann,3.72,0060878827,9780060878825,eng,434,769,139,2/27/2007,Ecco
45641,Las aventuras de Tom Sawyer,Mark Twain,3.91,8497646983,9788497646987,spa,272,113,12,5/28/2006,Edimat Libros
45642,To Kill a Mockingbird,Harper Lee,0.00,0061120081,9780061120084,eng,281,4570755,11512,07/11/1960,J.B. Lippincott & Co.
45642,prayush,prayush,4.50,,,eng,652,2095690,27591,9/16/2006,Scholastic Inc.
166 changes: 165 additions & 1 deletion build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,173 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css">
<link rel="stylesheet" href="styles.css">
<title>Document</title>
</head>
<body>
<h1>HAHAH</h1>
<nav>
<div class="logo">
<i class="bi bi-book"></i>
<span>TheBookDB</span>
</div>
<a href="https://github.com/adhikareeprayush/API/" class="contribute">
<i class="bi bi-github"></i>
</a>
</nav>
<div class="main">
<div class="about">
<div class="header">
<h1>Introduction</h1>
<p>
TheBookDB is a RESTful API that provides information about various books. It provides information about the title, authors, average rating, number of pages, publication date, ISBN, ISBN13, language code, publisher, ratings count, and text reviews count of the books. The API also allows users to add, update, and delete books.
</p>
</div>
</div>
<div class="manual">
<div class="get-req">
<div class="header">
<h1>Get Request</h1>
</div>
<div class="call">
<div class="purpose">List all the Books.</div>
<div class="code">
/api/books
</div>
</div>
<div class="call">
<div class="purpose">List a specific Book.</div>
<div class="code">
/api/books?bookID={bookID}
</div>
<div class="note">
<p>You can use title, authors, avgRating, numPages, publicationDate, isbn, isbn13, languageCode along with bookID. </p>
</div>
</div>
<div class="call">
<div class="purpose">List and sort books according to publicationDate.</div>
<div class="code">
/api/books?startDate={startDate}&endDate={endDate}&sortOrder={sortOrder}
</div>
<div class="note">
<p>sortOrder can be either ASC or DSC.</p>
</div>
</div>
</div>
<div class="post-req">
<div class="header">
<h1>Post Request</h1>
</div>
<div class="call">
<div class="purpose">Add a new Book.</div>
<div class="code">
/api/books
</div>
<div class="note">
<p>Use the following JSON format to add a new book.</p>
<pre>
{
"authors": "Lynsay Sands",
"avgRating": "3.91",
"bookID": "38568",
"isbn": "0060773758",
"isbn13": "9780060773755",
"languageCode": "eng",
"numPages": "360",
"publicationDate": "3/31/2020",
"publisher": "Avon",
"ratingsCount": "35275",
"textReviewsCount": "1370",
"title": "A Quick Bite (Argeneau #1)"
}
</pre>
</div>
</div>
</div>
<div class="put-req">
<div class="header">
<h1>Put Request</h1>
</div>
<div class="call">
<div class="purpose">Update a Book.</div>
<div class="code">
/api/books/{bookID}
</div>
<div class="note">
<p>Use the following JSON format to update a book.</p>
<pre>
{
"authors": "Lynsay Sands",
"avgRating": "3.91",
"bookID": "38568",
"isbn": "0060773758",
"isbn13": "9780060773755",
"languageCode": "eng",
"numPages": "360",
"publicationDate": "3/31/2020",
"publisher": "Avon",
"ratingsCount": "35275",
"textReviewsCount": "1370",
"title": "A Quick Bite (Argeneau #1)"
}
</pre>
</div>
</div>
</div>
<div class="patch-req">
<div class="header">
<h1>Patch Request</h1>
</div>
<div class="call">
<div class="purpose">Update a specific field of a Book.</div>
<div class="code">
/api/books/{bookID}
</div>
<div class="note">
<p>Use the following JSON format to update a specific field of a book.</p>
<pre>
{
"authors": "Lynsay Sands",
"avgRating": "3.91",
"bookID": "38568",
"isbn": "0060773758",
"isbn13": "9780060773755",
"languageCode": "eng",
"numPages": "360",
"publicationDate": "3/31/2020",
"publisher": "Avon",
"ratingsCount": "35275",
"textReviewsCount": "1370",
"title": "A Quick Bite (Argeneau #1)"
}
</pre>
</div>
</div>
</div>
<div class="delete-req">
<div class="header">
<h1>Delete Request</h1>
</div>
<div class="call">
<div class="purpose">Delete a Book.</div>
<div class="code">
/api/books/{bookID}
</div>
</div>
</div>
</div>
</div>

<footer>
<p>@2024 TheBookDB</p>
<div class="contributors">
<a href="https://github.com/pratyoos" class="member">Pratyoos Panta</a>
<a href="https://github.com/rtjsh" class="member">Rajesh Thapa</a>
<a href="https://github.com/prachitvuzel" class="member">Prachit Bhujel</a>
<a href="https://github.com/adhikareeprayush/" class="member">Prayush Adhikari</a>
<a href="#" class="member">Sandesh Pantha</a>

</div>
</footer>
</body>
</html>
Loading

0 comments on commit bb19115

Please sign in to comment.