A comprehensive, full-stack online bookstore application built with standard Java Enterprise technologies. This project demonstrates a complete e-commerce workflow including user authentication, product management, shopping cart functionality, order processing, and an administrative dashboard.
- Features
- Technology Stack
- Project Structure
- Prerequisites
- Installation & Deployment
- Usage Guidelines
- API Documentation
- Troubleshooting
- Authentication: Secure registration and login system with session management.
- Book Discovery:
- Browse books by dynamic categories (Fiction, Technology, etc.).
- Advanced search functionality (Title, Author, Category).
- Rich book details with cover images and descriptions.
- Shopping Experience:
- Persistent shopping cart.
- Real-time stock validation.
- Easy quantity adjustment and item removal.
- Order Management:
- Streamlined checkout process.
- Order history tracking.
- Shipping address management.
- User Profile: View and update personal information.
- Dashboard: Real-time statistics (Total Revenue, Orders, Users, Books).
- Inventory Management:
- Add, Edit, and Delete books.
- Image Upload: Local file upload support for book covers.
- Order Fulfillment:
- View all customer orders.
- Update order status (
Pending->Shipped->Completed).
- User Management: View registered user details.
- Core: Java SE 17
- Web Framework: Jakarta Servlet 6.0
- Server: Apache Tomcat 11.0
- Build Tool: Gradle 8.5
- Data Persistence: File-based JSON storage (Gson library) with thread-safe access.
- Core: HTML5, CSS3, JavaScript (ES6+)
- Styling: Custom responsive CSS (Flexbox/Grid), no external frameworks.
- Communication: Fetch API for asynchronous REST calls.
- Automation: PowerShell scripts for one-click build and deployment.
- Version Control: Git
BookGetter/
โโโ project/
โ โโโ dev/ # Deployment Automation Scripts
โ โ โโโ deploy.ps1 # Build, clean, and deploy to Tomcat
โ โ โโโ start.ps1 # Start Tomcat server
โ โ โโโ stop.ps1 # Stop Tomcat server
โ โโโ src/main/
โ โ โโโ java/com/bookgetter/
โ โ โ โโโ models/ # POJOs (Book, User, Order, Cart)
โ โ โ โโโ servlets/ # REST API Controllers
โ โ โ โโโ services/ # Business Logic Layer
โ โ โ โโโ utils/ # JSON, File, Session utilities
โ โ โโโ webapp/ # Frontend Assets
โ โ โโโ css/ # Stylesheets
โ โ โโโ js/ # Client-side Logic
โ โ โโโ data/ # Runtime Data Storage (JSON)
โ โ โโโ images/ # Uploaded Book Covers
โ โ โโโ admin/ # Admin Dashboard
โ โ โ โโโ index.html
โ โ โโโ *.html # View Templates
โ โโโ build.gradle # Dependencies & Build Config
โ โโโ settings.gradle # Project Name Config
โโโ ้กน็ฎๆๆฏๆ ไฟกๆฏ.md # Environment Configuration Reference
โโโ README.md # Documentation
Before running the project, ensure your environment meets the following requirements. The deploy.ps1 script can auto-detect these if installed in standard locations.
- Java Development Kit (JDK): Version 17 or higher.
- Apache Tomcat: Version 11.0 or compatible 10.x.
- PowerShell: Version 5.1+ (Standard on Windows 10/11).
Tip: Project paths for Java and Tomcat can be configured in
้กน็ฎๆๆฏๆ ไฟกๆฏ.mdif they are in non-standard locations.
This project includes advanced PowerShell scripts to automate the entire build and deployment lifecycle.
git clone https://github.com/SunflowersLwtech/BookGetter.git
cd BookGetter/projectRun the deployment script to build the WAR file, stop any running server, deploy the artifact, and restart the server.
# Run from project root
.\dev\deploy.ps1What this script does:
- Checks for JDK and Tomcat availability.
- Stops Tomcat if it's currently running.
- Cleans old deployments.
- Runs
./gradlew warto build the application. - Copies
BookGetter.warto Tomcat'swebappsdirectory. - Starts Tomcat and opens the application.
- Start Server:
.\dev\start.ps1 - Stop Server:
.\dev\stop.ps1
Once deployed, access the application at: http://localhost:8080/BookGetter/
You can register a new account or use the existing data if available.
- Admin Role: Select "Admin" during registration (or manually update
users.json). - Regular User: Select "Customer" during registration.
Data is stored securely in JSON format within the deployment directory. To reset data, delete the .json files in the data/ folder, and the application will regenerate them (or load defaults for books).
All API endpoints accept and return JSON.
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| Auth | |||
POST |
/api/login |
Authenticate user | No |
POST |
/api/register |
Create account | No |
DELETE |
/api/login |
Logout | Yes |
| Books | |||
GET |
/api/books |
List all books (supports filtering) | No |
GET |
/api/books?id={id} |
Get book details | No |
POST |
/api/admin/books |
Create new book | Admin |
POST |
/api/upload |
Upload book cover image | Admin |
| Cart | |||
GET |
/api/cart |
Get current cart | Yes |
POST |
/api/cart |
Add item to cart | Yes |
PUT |
/api/cart |
Update item quantity | Yes |
| Orders | |||
GET |
/api/orders |
Get order history | Yes |
POST |
/api/orders |
Place new order | Yes |
PUT |
/api/admin/orders/{id} |
Update order status | Admin |
-
Port 8080 Application Issue
- Symptom: "Port 8080 is already in use".
- Fix: Run
.\dev\stop.ps1to kill the process occupying the port.
-
Environment Variables Not Found
- Symptom:
deploy.ps1complains about missing Java or Tomcat. - Fix: Ensure
Start-Processcan findjavain PATH, or setJAVA_HOMEandCATALINA_HOMEenvironment variables manually. Alternatively, edit้กน็ฎๆๆฏๆ ไฟกๆฏ.mdto point to your specific paths.
- Symptom:
-
Image Upload Fails
- Symptom: "Failed to upload image".
- Fix: Ensure the Tomcat process has write permissions to the deployment directory
webapps/BookGetter/images.
Developed by LIUWEI All rights reserved.