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.
- 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.
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.
- 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.
Follow these steps to set up and run the project locally.
You'll need to have Node.js installed on your machine.
- 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)
- Navigate to the project directory:
cd my-book-database - Install the required Node.js packages:
npm install express body-parser sqlite3
- Start the server from the project directory:
node app.js
- Open your web browser and navigate to
http://localhost:3000to access the application.
- Fill out the Author, Title, Genre, and Price fields in the first form.
- Click the "Add Book" button to save the book to the database.
- Enter a keyword (e.g., a part of the book's title) into the "Keyword" input field.
- Click the "Search" button.
- The results will be displayed in a table below the search form.
POST /books: Adds a new book to the database.- Request Body:
{"author": "...", "title": "...", "genre": "...", "price": "..."} - Response:
{"Result": "Book added successfully!"}on success.
- Request Body:
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.
- URL Parameter:
- Name: Exarchou Athos
- Student ID: it2022134
- Email: it2022134@hua.gr
MIT License