Skip to content

dheeraj574/datascience

Repository files navigation

BookShop - Full Stack React & Node.js Application

A comprehensive book shop application built with React frontend and Node.js backend, featuring user authentication, book browsing, search functionality, and review system.

πŸš€ Features

General Users (No Authentication Required)

  • βœ… Get all books - Browse the complete book catalog (2 Points)
  • βœ… Search by ISBN - Find specific books using ISBN (2 Points)
  • βœ… Search by Author - Discover books by your favorite authors (2 Points)
  • βœ… Search by Title - Find books by title keywords (2 Points)
  • βœ… View book reviews - Read what others think about books (2 Points)
  • βœ… User Registration - Create a new account (3 Points)
  • βœ… User Login - Access your account (3 Points)

Registered Users (Authentication Required)

  • βœ… Add/Modify reviews - Share your thoughts about books (2 Points)
  • βœ… Delete reviews - Remove your own reviews (2 Points)

Node.js Backend Methods (Using Different Async Patterns)

  • βœ… Get all books - Using async callback function (2 Points)
  • βœ… Search by ISBN - Using Promises (2 Points)
  • βœ… Search by Author - Using async/await (2 Points)
  • βœ… Search by Title - Using async/await (2 Points)

πŸ›  Tech Stack

Backend

  • Node.js - Runtime environment
  • Express.js - Web framework
  • JWT - Authentication
  • bcryptjs - Password hashing
  • Axios - HTTP client for API methods
  • JSON Files - Data storage (books, users, reviews)

Frontend

  • React 18 - UI library
  • React Router - Client-side routing
  • Axios - API communication
  • Context API - State management
  • Modern CSS - Responsive design

πŸ“ Project Structure

bookshop/
β”œβ”€β”€ server.js              # Main backend server
β”œβ”€β”€ package.json           # Backend dependencies
β”œβ”€β”€ bookMethods.js         # Node.js methods with different async patterns
β”œβ”€β”€ data/                  # JSON data files
β”‚   β”œβ”€β”€ books.json         # Book catalog
β”‚   β”œβ”€β”€ users.json         # User accounts
β”‚   └── reviews.json       # Book reviews
β”œβ”€β”€ client/                # React frontend
β”‚   β”œβ”€β”€ package.json       # Frontend dependencies
β”‚   β”œβ”€β”€ public/           
β”‚   β”‚   └── index.html
β”‚   └── src/
β”‚       β”œβ”€β”€ App.js         # Main app component
β”‚       β”œβ”€β”€ App.css        # Global styles
β”‚       β”œβ”€β”€ index.js       # Entry point
β”‚       β”œβ”€β”€ components/    # Reusable components
β”‚       β”‚   β”œβ”€β”€ Navbar.js
β”‚       β”‚   β”œβ”€β”€ BookCard.js
β”‚       β”‚   └── ProtectedRoute.js
β”‚       β”œβ”€β”€ pages/         # Page components
β”‚       β”‚   β”œβ”€β”€ Home.js
β”‚       β”‚   β”œβ”€β”€ Login.js
β”‚       β”‚   β”œβ”€β”€ Register.js
β”‚       β”‚   β”œβ”€β”€ Search.js
β”‚       β”‚   β”œβ”€β”€ BookDetail.js
β”‚       β”‚   └── Profile.js
β”‚       β”œβ”€β”€ context/       # React Context
β”‚       β”‚   └── AuthContext.js
β”‚       └── services/      # API services
β”‚           └── api.js
└── README.md

πŸš€ Quick Start

Prerequisites

  • Node.js (v14 or higher)
  • npm or yarn

Installation

  1. Clone and install backend dependencies:
git clone <repository-url>
cd bookshop
npm install
  1. Install frontend dependencies:
cd client
npm install
cd ..
  1. Start the backend server:
npm start
# Server runs on http://localhost:5000
  1. In a new terminal, start the frontend:
cd client
npm start
# Frontend runs on http://localhost:3000
  1. Open your browser: Navigate to http://localhost:3000

πŸ”§ API Endpoints

Public Endpoints

  • GET /api/books - Get all books
  • GET /api/books/isbn/:isbn - Get book by ISBN
  • GET /api/books/author/:author - Get books by author
  • GET /api/books/title/:title - Get books by title
  • GET /api/reviews/:isbn - Get reviews for a book
  • POST /api/register - Register new user
  • POST /api/login - Login user

Protected Endpoints (Require Authentication)

  • POST /api/reviews - Add/update book review
  • DELETE /api/reviews/:isbn - Delete user's review
  • GET /api/user/reviews - Get user's reviews

πŸ§ͺ Testing the Node.js Methods

Run the Node.js methods demonstration:

node bookMethods.js

This will demonstrate all four async patterns:

  1. Callback function for getting all books
  2. Promises for ISBN search
  3. Async/await for author search
  4. Async/await for title search

πŸ‘€ Demo Credentials

For testing purposes, use these credentials:

Email: [email protected]
Password: password123

Or register a new account!

🎨 Features Showcase

Modern UI/UX

  • Responsive design that works on all devices
  • Modern gradient navigation
  • Card-based layout
  • Smooth animations and transitions
  • Loading states and error handling

Authentication System

  • JWT-based authentication
  • Password hashing with bcrypt
  • Protected routes
  • Persistent login sessions

Review System

  • Star rating (1-5 stars)
  • Add, edit, and delete reviews
  • User-specific review management
  • Review display with author and date

Search Functionality

  • Multiple search types (Title, Author, ISBN)
  • Real-time search results
  • Search suggestions and tips
  • Error handling for no results

πŸ”’ Security Features

  • Password hashing with bcrypt
  • JWT token authentication
  • Protected API endpoints
  • Input validation
  • XSS protection

πŸ“± Responsive Design

The application is fully responsive and works on:

  • Desktop computers
  • Tablets
  • Mobile phones
  • Various screen sizes

πŸš€ Production Deployment

For production deployment:

  1. Build the frontend:
cd client
npm run build
  1. Serve built files from Express: Add this to your server.js:
app.use(express.static(path.join(__dirname, 'client/build')));
  1. Set environment variables:
  • NODE_ENV=production
  • JWT_SECRET=your-production-secret
  • PORT=your-production-port

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License.

🎯 Scoring Summary

Total Points: 28/28 βœ…

  • General User Features: 14 Points
  • Registered User Features: 4 Points
  • Node.js Methods: 8 Points
  • Modern React Implementation: 2 Points (Bonus)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors