A comprehensive Java Swing-based Supermarket Management System for managing customers, inventory, sales, and reporting. This project is designed to demonstrate best practices in Java desktop application development, including secure authentication, modular code organization, and user-friendly GUI design.
- Features
- Screenshots
- Technologies Used
- Getting Started
- Usage
- Project Structure
- Database Schema
- Security
- Contributing
- License
- Contact
-
User Authentication
- Secure login system using BCrypt password hashing
- User registration with validation
- Password reset (with safe update in the database)
-
Customer Management
- Register new customers with required details (name, contact, gender, email, etc.)
- List, update, or delete customers
- Track customer balances
-
Inventory Management
- Add, update, delete, and search products by name or category
- Categorize products and manage product units (e.g., kg, ml, pcs)
- Track product expiry dates and stock levels
-
Sales and Purchases
- Sell products to customers, automatically deducting from their balance
- Print receipts for purchases
- Record purchase history for each customer
-
Reports & Data Export
- Generate and view reports for purchases, customers, and products
- Export reports to Excel (
.xlsx) or CSV format - Clear purchase history with confirmation
-
User Interface
- Modern, intuitive UI built with NetBeans GUI Builder
- Easy navigation between modules
- Responsive feedback and error messages
-
Extensible & Maintainable Code
- Modular class structure (DAL, Helper, UI forms)
- Easy to add new features or modify existing ones
- Java SE (Swing)
- NetBeans IDE (GUI builder and code editor)
- MySQL (database)
- JDBC (database connectivity)
- jBCrypt (password encryption)
- Apache POI (Excel export)
- Maven (optional, for dependency management)
- Java JDK 8 or above
- NetBeans IDE (recommended)
- MySQL Server
- Maven (optional, for managing dependencies)
-
Clone the repository
git clone https://github.com/Hedayatbakhshi/Supermarket-Project.git
-
Open the project in NetBeans
- Go to
File > Open Project…and select the cloned folder.
- Go to
-
Set up the database
- Create a database named
supermarketin MySQL. - Import the SQL schema provided in the project (
docs/schema.sqlor similar). - Example (replace with your actual SQL file):
mysql -u yourUser -p supermarket < docs/schema.sql
- Create a database named
-
Configure database credentials
- Open
DAL.javaand update the MySQL host, username, and password as needed.
- Open
-
Build and run the project
- Press
F6or click the Run button in NetBeans. - The application will launch, starting with the login window.
- Press
- Login
- Use your username and password or register as a new user.
- Customer Management
- Add, update, or remove customers.
- Inventory Management
- Add new products, update details, or search for products.
- Sales
- Select products, enter quantity, and process sales. Receipts are generated and customer balances updated automatically.
- Reports
- Choose a report type (purchases, customers, products) and export to Excel or CSV.
Supermarket-Project/
├── src/
│ └── supermarket/
│ ├── DAL.java // Data Access Layer
│ ├── Helper.java // Utility and helper methods
│ ├── Login.java // Login window
│ ├── Dashboard.java // Main dashboard
│ ├── UserAddCustomerInformation.java // Customer registration
│ ├── SupermarketInventorySystem.java // Inventory management
│ ├── Reports.java // Reporting and export
│ └── ... // Other UI and logic classes
├── docs/
│ └── schema.sql // SQL schema for the database
├── lib/
│ └── ... // Third-party JARs (jBCrypt, Apache POI, etc.)
├── README.md
└── ...
Tip: Adjust the schema details below to match your actual implementation.
Tables:
users: Stores user info (user_id,username,password,email,gender,balance, etc.)products: Stores product details (product_id,product_name,unit_price,unit,category,product_date,expire_date)purchases: Records each purchase (purchase_id,user_id,product_id,quantity,total_cost,purchase_date)
Sample SQL Table:
CREATE TABLE users (
user_id INT PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(50) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
email VARCHAR(100),
gender VARCHAR(10),
balance DOUBLE DEFAULT 0,
contact_number VARCHAR(20),
fathername VARCHAR(50)
);
CREATE TABLE products (
product_id INT PRIMARY KEY AUTO_INCREMENT,
product_name VARCHAR(100) NOT NULL,
unit_price DOUBLE NOT NULL,
unit VARCHAR(10),
category VARCHAR(50),
product_date DATE,
expire_date DATE
);
CREATE TABLE purchases (
purchase_id INT PRIMARY KEY AUTO_INCREMENT,
user_id INT,
product_id INT,
quantity INT,
total_cost DOUBLE,
purchase_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(user_id),
FOREIGN KEY (product_id) REFERENCES products(product_id)
);- Passwords are stored as hashed strings using BCrypt, not plain text.
- All sensitive operations (like password reset, user management) perform validation and error handling.
- SQL injection is prevented by using prepared statements in all database operations.
- Fork this repository.
- Clone your fork:
git clone https://github.com/Hedayatbakhshi/Supermarket-Project.git
- Commit your changes with clear messages.
- Push to your fork and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
- Author: Hedayat Bakhshi
- GitHub: Hedayatbakhshi
- Issues: Submit a bug or feature request
If you find this project useful or inspiring, please star the repository and share your feedback!











