Skip to content

JavaFX-based Bookstore Management System built with Java and Maven. Originally an assignment to demonstrate advanced OOP and the State Design Pattern, the project was later enhanced with MySQL integration to replace file-based storage.

Notifications You must be signed in to change notification settings

SansarSharma/BookstoreApplication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bookstore Application

This project is a JavaFX-based Bookstore Management System developed in Java. This was originally an assignment from my class, COE528 (Object-Oriented Analysis Design), where I needed to demonstrate advance Object-Oriented Programming (OOP) concepts, and the implementation of design patterns (State Design Pattern). After the semester, I decided to improve the project and implemented MySQL as the database instead of the traditional file storage. Also, this project uses Maven for the build and dependency management.

Features

  • Manage bookstore operations: adding, removing, and updating books and customers.
  • Customer login, shopping cart, checkout, and point notification system.
  • Admin panel for managing users and books.
  • Preloaded books and users at first run to populate the Bookstore.
  • State Design Pattern to notify the Customer Points Status (None, Silver, Gold, Platinum).
  • Passwords are hashed securely using SHA-256 before saving to the database.
  • JavaFX-based User Interface with full-windowed fullscreen support.

File Structure

  • com.bookstore.database
    • DatabaseConnection.java: Connects to the MySQL database.
    • DatabaseManager.java: Handles loading, saving, updating books and customers.
  • com.bookstore.models
    • Book.java: Represents a book entity.
    • Customer.java: Represents a customer entity.
    • Owner.java: Represents an owner entity.
    • User.java: Parent class for all users.
    • ShoppingCart.java: Represents a ShoppingCart entity.
  • com.bookstore.scenes
    • LoginScene.java: Customer and owner login interface.
    • OwnerScene.java: Owner dashboard.
    • CustomerScene.java: Customer dashboard.
    • ShoppingCartScene.java: Shopping cart interface.
    • CustomerCostScene.java: Checkout interface.
    • ThankYouScene.java: Confirmation scene after a successful purchase.
    • OwnerUserManageScene.java: Manage customer accounts.
    • OwnerBookManageScene.java: Manage books.
    • SceneManager.java: Handles scene transitions.
  • com.bookstore.handlers
    • LoginHandler.java: Handles user's logging into application.
    • OwnerHandler.java: Handles owner operations.
    • PaymentHandler.java: Handles payment operations.
    • ShoppingCartHandler.java: Manages shopping cart operations.
  • com.bookstore.states
    • CustomerState.java: State interface.
    • NoneState.java, SilverState.java, GoldState.java, PlatinumState.java: State pattern classes.
  • com.bookstore.utilities
    • InputValidator.java: Validates user input.
    • PasswordHasher.java: Hashes passwords securely.

Requirements

  • Java Development Kit (JDK) 17 or later
  • Apache Maven 3.6 or later
  • MySQL Server (8.0 recommended)
  • MySQL Workbench (for database inspection)

How to Run

Follow the steps below carefully:

# Bookstore Application - Setup Instructions

# Prerequisites
# - Java JDK 17 or later installed
# - Apache Maven installed
# - MySQL Server installed and running
# - MySQL Workbench (optional, for viewing database)

# Step 1: Clone the Project
git clone https://github.com/SansarSharma/BookstoreApplication.git
cd BookStoreApplication

# Step 2: Create the MySQL Database
# Open MySQL Workbench and run:
CREATE DATABASE bookstore;

# Step 3: Configure Database Credentials
# Open the file src/main/java/com/bookstore/database/DatabaseConnection.java
# and make sure these values match your MySQL setup:
#
# Example:
# private static final String URL = "jdbc:mysql://localhost:3306/bookstore";
# private static final String USER = "root";
# private static final String PASSWORD = "your_mysql_password";

# Step 4: Ensure Preloaded Data Exists
# The following two files must be present inside src/main/resources:
# - PreloadedBooks.txt
# - PreloadedUsers.txt
#
# These files contain books and users that will be inserted automatically if the tables are empty on first run.

# Step 5: Build and Run the Project
mvn clean install
mvn javafx:run

# Step 6: First Run Behavior
# - The application will automatically:
#     - Create 'books' and 'customers' tables if they don't exist.
#     - Populate the database with:
#         - Books from PreloadedBooks.txt
#         - Users from PreloadedUsers.txt

# Step 7: Default Login Information
# You can use the following customer accounts immediately:

# Example (from PreloadedUsers.txt):
# Username: JackMiller
# Password: read4life7

# Username: NoahKim
# Password: libraryboy5

# Some runs may load the data (users and books) immediately, and other runs you may need to press login 2-3 times before entering the application.
# (Passwords are stored hashed, but you use the plain password from PreloadedUsers.txt.)

# Admin User:
# - You can log in with a manually created admin account (username and password is "admin").
# - Create/Delete Users and Books along with Increasing/Decreasing existing User's balances

# Customer Points Status System
# - None: 0 points
# - Silver: 1 - 999 points
# - Gold: 1000 - 2499 points
# - Platinum: 2500+ points

# Notes
# - Full screen windowed mode is enabled automatically.
# - Secure SHA-256 password hashing is applied before saving to database.
# - The system uses the State Design Pattern to show customer points status.

# Finished!
# After completing these steps, the Bookstore Application will be running successfully with preloaded books, customers, and a fully functional database.

About

JavaFX-based Bookstore Management System built with Java and Maven. Originally an assignment to demonstrate advanced OOP and the State Design Pattern, the project was later enhanced with MySQL integration to replace file-based storage.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages