Welcome to BookNook, a simple web application that allows users to browse, add, rate, and review books. This platform provides an easy way for users to discover new books, share their thoughts, and see what others have to say.
- Features
- Technologies Used
- Folder Structure
- Setup Instructions
- API Endpoints
- Database Schema
- Optional Features
- Contributing
- License
- Book Browsing: View a list of books with titles, authors, and average ratings.
- Book Details: Click on a book to see more details, including a description, user reviews, and ratings.
- Add Books: Users can contribute by adding new books to the platform.
- Submit Reviews: Users can rate books and leave detailed reviews.
- Filter and Sort: Filter books by genre or author, and sort by highest rating or most reviewed.
- Backend: Go (Golang) for RESTful API
- Database: MySQL for storing book and review data
- HTML/CSS/JavaScript: For the frontend UI
booknook/
├── api/ - Go backend API folder
│ ├── main.go # entry point for the api
│ ├── handlers/ # request handlers folder
│ │ ├── bookHandler.go # handles book-related routes
│ │ └── reviewHandler.go # handles review-related routes
│ ├── models/ # database models folder
│ │ ├── book.go # book model definition
│ │ └── review.go # review model definition
│ ├── routes/ # api routes folder
│ │ └── routes.go # defines api routes
│ ├── database/ # database connection folder
│ │ └── db.go # manages database connection
│ ├── utils/ # utility functions folder
│ │ └── utils.go # common utility functions
│ ├── templates/ # html templates folder (Go templates)
│ │ ├── index.html # homepage template
│ │ ├── book_details.html # book details page template
│ │ ├── add_book.html # add new book page template
│ │ └── login.html # login page template
│ └── static/ # static assets folder
│ ├── css/ # css styles folder
│ │ └── styles.css # main stylesheet
│ └── js/ # javascript folder
│ ├── book-details.js # javascript for book details page
│ ├── book-list.js # javascript for book list page
│ └── review.js # javascript for review page
├── sql/ - MySQL # sql scripts folder
│ ├── schema.sql # database schema script
│ └── seed.sql # initial seed data script
├── README.md # project setup and instructions
└── .gitignore # git ignore file
- Go: Ensure you have Go installed (version 1.16 or later).
- MySQL: Ensure MySQL is installed and running.
Navigate to the api/
directory:
cd booknook/api
Install Go dependencies:
go mod tidy
Set up the database:
CREATE DATABASE booknook;
mysql -u $MYSQL_ROOT_USER -p$MYSQL_ROOT_PASSWORD booknook < sql/schema.sql
Run the API:
go run main.go
The API will run on http://localhost:8080
.
Run the schema script:
mysql -u $MYSQL_ROOT_USER -p$MYSQL_ROOT_PASSWORD booknook < sql/schema.sql
(Optional) Seed the database:
mysql -u $MYSQL_ROOT_USER -p$MYSQL_ROOT_PASSWORD booknook < sql/seed.sql
- POST /books: Add a new book.
- GET /books: Retrieve a list of all books.
- GET /books/{id}: Retrieve details for a specific book, including reviews.
- POST /books/{id}/reviews: Add a review to a specific book.
-
Books:
id
: Primary keytitle
: Book titleauthor
: Book authordescription
: Book descriptioncover_image
: URL to the book cover image (optional)average_rating
: Average rating of the book
-
Reviews:
id
: Primary keybook_id
: Foreign key to the Books tableuser_id
: ID of the user who left the reviewrating
: Rating given by the user (1-5)review_text
: Review text
We welcome contributions! Please fork the repository, create a new branch, and submit a pull request.