Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BookStore — Online Book Store System

A full-stack online bookstore built with React, Node.js/Express, and MySQL. Supports customer shopping, JWT authentication, an admin dashboard, publisher management, and sales reporting.


Tech Stack

Layer Technology
Frontend React 18, Vite, React Router v6
Backend Node.js, Express.js
Database MySQL (mysql2/promise)
Auth JWT (jsonwebtoken), bcrypt
Validation Zod
Dev Tools Nodemon, dotenv, Swagger

Features

Customer

  • Search and browse books with filters (category, price, year, publisher)
  • View book details, manage a shopping cart, and place orders
  • View order history and edit profile

Admin

  • Sales reports (daily, top books, top customers)
  • Manage publishers and book inventory
  • Place and confirm publisher restock orders

Setup

Prerequisites

  • Node.js v18+
  • MySQL 8+

Environment Variables

Create a .env file in the backend folder:

DB_HOST=localhost
DB_USER=your_mysql_user
DB_PASSWORD=your_mysql_password
DB_NAME=bookstore_db
DB_PORT=3306
JWT_SECRET=your_secret_key
PORT=5000

Install & Run

# Backend
cd backend
npm install
npm run dev

# Frontend
cd frontend
npm install
npm run dev

Frontend: http://localhost:5173
Backend: http://localhost:5000
Swagger docs: http://localhost:5000/api-docs


API Reference

Users — /api/users

Method Endpoint Description
POST /signup Register a new user
POST /login Login, returns token
GET /profile Get user profile
PUT /profile Update profile
GET /orders View order history
POST /logout Logout and clear cart

Books — /api/books

Method Endpoint Description
GET /search Search with filters
GET /:isbn Get book by ISBN

Cart — /api/cart

Method Endpoint Description
POST / Add item to cart
GET / View cart
DELETE /:isbn Remove item
PUT /:isbn Update quantity

Publishers — /api/publishers

Method Endpoint Description
POST / Add a publisher
GET / List all publishers
GET /:id Get publisher by ID
DELETE /:id Remove a publisher
POST /orders Place restock order
GET /orders View all restock orders
PUT /orders/:orderId Confirm a restock order

Pages

Route Page Access
/ Home / Search Public
/book/:isbn Book Details Public
/signup Sign Up Public
/login Login Public
/profile Profile User
/view-cart Cart User
/checkout Checkout User
/sales-report Sales Report Admin
/publisher-orders Publisher Orders Admin
/manage-publishers Manage Publishers Admin
/manage-books Manage Books Admin

Authentication

JWT tokens are issued on login and stored in localStorage. Protected routes require the token in the Authorization: Bearer <token> header. Admin routes are protected on both the frontend (RequireAdmin component) and backend (auth middleware).


Roles

Role Permissions
CUSTOMER Browse, cart, checkout, order history, profile
ADMIN All customer permissions + sales reports, publishers, books

Known Issues

  • Duplicate logout method in userController.js — second definition overrides the first.
  • Duplicate getAllPublishers method in publisherController.js — same issue.
  • JWT tokens remain valid after logout (no server-side invalidation).
  • Cart requires login — no guest cart support.

About

Alexandria University – Database Systems (Faculty of Engineering). Order processing system for an online bookstore with customer shopping, admin dashboard, sales reports, and publisher inventory management using React, Node.js, and MySQL.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages