Skip to content

AthosExarchou/My-Book-Database

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My Book Database

This project was developed for the Web Development course at Harokopio University of Athens – Dept. of Informatics and Telematics. It is a simple web application for managing a book database. It allows users to add new books and search for existing ones. The application consists of a front-end interface built with HTML, CSS, and JavaScript, and a back-end server powered by Node.js with Express.js and SQLite3.

Table of Contents

Features

  • Add New Books: Users can add new books to the database by providing the author, title, genre, and price.
  • Search Functionality: Users can search for books by a specific keyword, which matches against the book's title.
  • Database Storage: Book information is stored persistently in an SQLite database.
  • Responsive Design: The application's UI is simple and functional.

Project Structure

The project is organized into the following files:

  • index.html: The main HTML file for the user interface.
  • server.js: The Node.js server that handles API requests and database interactions.
  • style.css: The CSS file for styling the web page.
  • books.sqlite: The SQLite database file where book data is stored.

Technologies Used

  • Frontend:
    • HTML5: For the structure of the web page.
    • CSS3: For styling the application.
    • JavaScript: For front-end logic, handling form submissions, and fetching data from the server.
  • Backend:
    • Node.js: The JavaScript runtime environment.
    • Express.js: The web framework for building the API.
    • SQLite3: A self-contained, serverless database engine for storing book data.
  • Database:
    • body-parser: Middleware for parsing request bodies.

Getting Started

Follow these steps to set up and run the project locally.

Prerequisites

You'll need to have Node.js installed on your machine.

Installation

  1. Clone this repository to your local machine:
    git clone [https://github.com/AthosExarchou/my-book-database.git](https://github.com/AthosExarchou/my-book-database.git)
  2. Navigate to the project directory:
    cd my-book-database
  3. Install the required Node.js packages:
    npm install express body-parser sqlite3

Running the Application

  1. Start the server from the project directory:
    node app.js
  2. Open your web browser and navigate to http://localhost:3000 to access the application.

Usage

Adding a Book

  1. Fill out the Author, Title, Genre, and Price fields in the first form.
  2. Click the "Add Book" button to save the book to the database.

Searching for a Book

  1. Enter a keyword (e.g., a part of the book's title) into the "Keyword" input field.
  2. Click the "Search" button.
  3. The results will be displayed in a table below the search form.

API Endpoints

  • POST /books: Adds a new book to the database.
    • Request Body: {"author": "...", "title": "...", "genre": "...", "price": "..."}
    • Response: {"Result": "Book added successfully!"} on success.
  • GET /books/:keyword: Searches for books whose titles contain the specified keyword.
    • URL Parameter: :keyword (e.g., http://localhost:3000/books/moby)
    • Response: An array of matching book objects.

Author

License

MIT License

About

This project is a simple web application for managing a book database. It allows users to add new books and search for existing ones.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors