A Java-based desktop application that facilitates plant donations and orders with secure user authentication, session management, and an admin dashboard for database interaction.
- Overview
- Features
- Tech Stack
- Architecture
- Getting Started
- Project Structure
- Database Schema
- Usage
- Security Considerations
- Troubleshooting
- Contributing
- License
Plant Donation System is a full-featured desktop application designed to manage plant inventory, process donations (both plants and money), and handle plant orders. The system includes secure user authentication with AES encryption, session-based access control, and a comprehensive admin dashboard for monitoring all transactions.
Built with Java Swing for the GUI and MySQL for data persistence, this application demonstrates secure coding practices including prepared statements to prevent SQL injection, encrypted password storage, and role-based access control.
- Secure login with username and password
- AES encryption for password storage
- Session management with automatic logout
- User registration with field validation
- Donate plants (Hibiscus, Mango, Neem, Banyan)
- Monetary donations
- Real-time inventory updates
- Donation history tracking
- Browse available plants with live inventory
- Place orders with quantity selection
- Multiple payment options (Cash, Card, UPI)
- Automatic price calculation and inventory deduction
- View all database tables in tabbed interface
- Real-time data visualization
- User management capabilities
- Transaction monitoring
- AES encryption for sensitive data
- Prepared statements to prevent SQL injection
- Session-based access control
- Admin role verification
| Layer | Technologies |
|---|---|
| Language | Java 17+ |
| GUI | Java Swing |
| Database | MySQL 8.4 (Docker) |
| Containerization | Docker & Docker Compose |
| Encryption | AES (Java Cryptography) |
| Database Driver | MySQL Connector/J |
┌─────────────────────────────────────────────────────────────────────────────┐
│ PLANT DONATION SYSTEM - ARCHITECTURE │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────────────────────────────────────────────────────────┐ │
│ │ JAVA SWING APPLICATION │ │
│ │ │ │
│ │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │ │
│ │ │ Login Page │ │ Home Page │ │ Admin Page │ │ │
│ │ │ │ │ │ │ │ │ │
│ │ │ • Auth login │ │ • Donate │ │ • View users │ │ │
│ │ │ • Registration │ │ • Order │ │ • View orders │ │ │
│ │ │ • Session mgmt │ │ • History │ │ • View storage │ │ │
│ │ └────────┬────────┘ └────────┬────────┘ └────────┬────────┘ │ │
│ │ │ │ │ │ │
│ │ └────────────────────┼────────────────────┘ │ │
│ │ │ │ │
│ │ ┌──────────────────────────────▼────────────────────────────────┐ │ │
│ │ │ UTILITY LAYER │ │ │
│ │ │ │ │ │
│ │ │ Session Util │ EncryptionUtil │ MySQL.java │ │ │
│ │ │ Session mgmt │ AES encryption │ DB connection │ │ │
│ │ └───────────────────────────────────────────────────────────────┘ │ │
│ │ │ │
│ └──────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ │ JDBC │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────────────────┐ │
│ │ MYSQL DATABASE │ │
│ │ │ │
│ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │
│ │ │ users │ │ storage │ │donations │ │ orders │ │ │
│ │ │ │ │ │ │ │ │ │ │ │
│ │ │ accounts │ │ inventory│ │ history │ │purchases │ │ │
│ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │ │
│ │ │ │
│ └──────────────────────────────────────────────────────────────────────┘ │
│ │
│ Secure Authentication → Encrypted Storage → SQL Injection Safe │
└─────────────────────────────────────────────────────────────────────────────┘
- User launches
LoginPage.java - Authentication checks encrypted password against database
- Session is created for authenticated user
- User navigates to donation or order features
- All database operations use prepared statements
- Admin users can access the admin dashboard
- Visual Studio Code (Download)
- Extension Pack for Java (Install from VS Code Extensions)
- Java Development Kit (JDK) 17 or higher (Download)
- Docker Desktop (Download)
- MySQL Connector/J (Already included in repository)
git clone https://github.com/tanishqmudaliar/Plant-Donation-System.git
cd Plant-Donation-System- Launch Visual Studio Code
- Go to File → Open Folder
- Navigate to and select the
Plant-Donation-Systemfolder - Click Select Folder
- Open the Extensions view (
Ctrl+Shift+XorCmd+Shift+Xon Mac) - Search for "Extension Pack for Java"
- Click Install on the official Microsoft extension pack
- Wait for all Java extensions to install
java -versionExpected output (version may vary):
java version "17.0.x" or higher
Java(TM) SE Runtime Environment (build 17.0.x+xx-xxx)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.x+xx-xxx, mixed mode, sharing)
- Download Docker Desktop from Docker Downloads
- Run the installer and follow the setup wizard
- Start Docker Desktop and ensure it's running
- In the project root directory, create a
.envfile:
MYSQL_DB=plant_donation
MYSQL_PASSWORD=your_secure_password_here
MYSQL_PORT=3306your_secure_password_here with a strong password of your choice.
- The
docker-compose.ymlfile is already included in the repository root - Review the configuration to understand the setup:
services:
db:
image: mysql:8.4
container_name: plant_donation_db
environment:
MYSQL_DATABASE: ${MYSQL_DB}
MYSQL_ROOT_PASSWORD: ${MYSQL_PASSWORD}
ports:
# Maps Docker MySQL port (3306) to your PC's port (3306)
- "${MYSQL_PORT}:3306"
volumes:
# Automatically restores backup.sql on first startup
- ./backup.sql:/docker-entrypoint-initdb.d/init.sql
# Persist data even if you delete the container
- db_data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 10s
timeout: 5s
retries: 5
volumes:
db_data:- Place your
backup.sqlfile in the project root directory - This file will automatically initialize the database on first startup
Note: If you don't have a backup.sql, create one with this content:
CREATE DATABASE IF NOT EXISTS plant_donation;
USE plant_donation;
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
name VARCHAR(100) NOT NULL,
email VARCHAR(100) UNIQUE NOT NULL,
mobile VARCHAR(15) NOT NULL,
dob DATE NOT NULL,
gender VARCHAR(10) NOT NULL,
password VARCHAR(255) NOT NULL,
is_admin BOOLEAN DEFAULT FALSE
);
CREATE TABLE storage (
id INT PRIMARY KEY DEFAULT 1,
hibiscus INT DEFAULT 0,
mango INT DEFAULT 0,
neem INT DEFAULT 0,
banyan INT DEFAULT 0,
money_collected INT DEFAULT 0
);
INSERT INTO storage (id, hibiscus, mango, neem, banyan, money_collected)
VALUES (1, 0, 0, 0, 0, 0);
CREATE TABLE donations (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
donation_type VARCHAR(50) NOT NULL,
donation_detail VARCHAR(255),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id)
);
CREATE TABLE orders (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
hibiscus INT DEFAULT 0,
mango INT DEFAULT 0,
neem INT DEFAULT 0,
banyan INT DEFAULT 0,
price INT NOT NULL,
address TEXT NOT NULL,
payment_type VARCHAR(50) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id)
);- Open a terminal in the project root directory
- Start the MySQL container:
docker compose up -d- Verify the database is running:
docker compose psYou should see plant_donation_db with status Up and healthy.
To check if the database is accessible:
On Linux/Mac/Git Bash:
docker compose exec db mysql -uroot -p$(grep MYSQL_PASSWORD .env | cut -d'=' -f2) -e "SHOW DATABASES;"On Windows (PowerShell):
$password = (Get-Content .env | Select-String "MYSQL_PASSWORD").ToString().Split("=")[1]
docker compose exec db mysql -uroot -p"$password" -e "SHOW DATABASES;"On Windows (Command Prompt) - Interactive:
docker compose exec db mysql -uroot -pThen enter your password when prompted and run:
SHOW DATABASES;You should see plant_donation in the list of databases.
To exit the MySQL command-line interface, type
exitand press Enter.
- Navigate to the
src/directory - Copy
config.properties.exampletoconfig.properties:
cp src/config.properties.example src/config.properties- Open
src/config.propertiesand update with your settings:
# Database Configuration
db.url=jdbc:mysql://localhost:3306/plant_donation
db.user=root
db.password=your_secure_password_here
# Application Settings
app.name=Plant Donation System
app.version=1.0- Use the same password you set in the
.envfile - The hostname is
localhostbecause Docker maps port 3306 to your local machine - Never commit
config.propertiesto version control
Your project structure should now include:
Plant-Donation-System/
├── docker-compose.yml # ✓ Created
├── .env # ✓ Created (don't commit!)
├── backup.sql # ✓ Created/Placed
├── src/
│ └── config.properties # ✓ Created (don't commit!)
- In VS Code, find the Java Projects section in Explorer
- Expand Referenced Libraries
- If
mysql-connector-j-x.x.x.jaris not listed:- Click the + icon next to "Referenced Libraries"
- Navigate to the project root or
lib/folder - Select the
mysql-connector-j-x.x.x.jarfile
- Navigate to
src/LoginPage.java - Right-click anywhere in the file editor
- Select Run Java
- The Login window should appear
- Click "Create Account" to register a new user
- Fill in all required fields
- Check "Register as Admin" if you want admin privileges
- After registration, log in with your credentials
Plant-Donation-System/
├── src/
│ ├── Assets/ # UI Images and Icons
│ │ ├── home screen.png
│ │ ├── heading.png
│ │ ├── donate.png
│ │ ├── buy.png
│ │ ├── donate frame head.png
│ │ ├── order frame head.png
│ │ └── refference.png
│ │
│ ├── AdminPage.java # Admin dashboard
│ ├── CenteredComboBoxRenderer.java # UI component
│ ├── config.properties # Database config (create from example)
│ ├── config.properties.example # Configuration template
│ ├── EncryptionUtil.java # AES encryption utility
│ ├── HomePage.java # Main user interface
│ ├── LoginPage.java # Application entry point
│ ├── MySQL.java # Database connection manager
│ ├── RegistrationPage.java # User registration
│ ├── SessionUtil.java # Session management
│ └── WordWrapCellRenderer.java # Table cell renderer
│
├── lib/ # External libraries
│ └── mysql-connector-j-9.1.0.jar
│
├── .env # Environment variables (gitignored)
├── .env.example # Template for .env file
├── backup.sql # Database initialization script
├── docker-compose.yml # Docker MySQL configuration
├── .gitignore # Git ignore rules
├── LICENSE # MIT License
└── README.md # Project documentation
| Column | Type | Description |
|---|---|---|
| id | INT | Primary key, auto-increment |
| username | VARCHAR(50) | Unique username |
| name | VARCHAR(100) | Full name |
| VARCHAR(100) | Unique email | |
| mobile | VARCHAR(15) | Phone number |
| dob | DATE | Date of birth |
| gender | VARCHAR(10) | Gender |
| password | VARCHAR(255) | AES encrypted password |
| is_admin | BOOLEAN | Admin role flag |
| Column | Type | Description |
|---|---|---|
| id | INT | Primary key |
| hibiscus | INT | Hibiscus plant count |
| mango | INT | Mango plant count |
| neem | INT | Neem plant count |
| banyan | INT | Banyan plant count |
| money_collected | INT | Total monetary donations |
| Column | Type | Description |
|---|---|---|
| id | INT | Primary key, auto-increment |
| user_id | INT | Foreign key to users |
| donation_type | VARCHAR(50) | Type of donation |
| donation_detail | VARCHAR(255) | Donation details |
| created_at | TIMESTAMP | Donation timestamp |
| Column | Type | Description |
|---|---|---|
| id | INT | Primary key, auto-increment |
| user_id | INT | Foreign key to users |
| hibiscus | INT | Hibiscus quantity ordered |
| mango | INT | Mango quantity ordered |
| neem | INT | Neem quantity ordered |
| banyan | INT | Banyan quantity ordered |
| price | INT | Total price |
| address | TEXT | Delivery address |
| payment_type | VARCHAR(50) | Payment method |
| created_at | TIMESTAMP | Order timestamp |
- Register: Create a new account from the login page
- Login: Use your credentials to access the system
- Donate: Choose to donate plants or money from the home page
- Order: Browse available plants and place orders
- Admin: Access admin dashboard (admin users only) to view all data
| Feature | Implementation |
|---|---|
| Password Storage | AES encryption for all passwords |
| SQL Injection | Prepared statements for all queries |
| Session Management | Session-based access control |
| Role Verification | Admin role check for dashboard access |
| Configuration | Sensitive data in separate config file |
- Change the AES encryption key in
EncryptionUtil.javafor production use - Never commit
config.propertieswith real credentials to version control - Keep
config.properties.exampleas a template with placeholder values - Use environment variables or secure vault systems for production deployments
- Implement HTTPS if deploying as a web application
- Regular database backups recommended
Solution: Ensure MySQL Connector/J is added to Referenced Libraries in VS Code.
Solution: Verify that the password in src/config.properties matches the password in .env file.
Solution:
- Ensure
backup.sqlis in the project root - Restart the Docker container:
docker compose down && docker compose up -d - The database will be initialized automatically on startup
Solution:
- Check if Docker Desktop is running
- Verify the database container is running:
docker compose ps - Check container health:
docker compose logs db - Restart the container:
docker compose restart db
Solution:
- Stop and remove the container and volumes:
docker compose down -v- Start fresh (this will re-initialize from backup.sql):
docker compose up -dSolution: Update image paths in HomePage.java to use relative paths starting with src/Assets/.
Solution:
- Ensure Java extension pack is installed
- Reload VS Code window (
Ctrl+Shift+P→ "Developer: Reload Window") - Check that JDK is properly configured
| Command | Description |
|---|---|
docker compose up -d |
Start the database in background |
docker compose down |
Stop and remove the database container |
docker compose down -v |
Stop and remove container + delete all data |
docker compose ps |
Check container status |
docker compose logs db |
View database logs |
docker compose restart db |
Restart the database |
docker compose exec db mysql -uroot -p |
Connect to MySQL shell |
Contributions are welcome! Please feel free to submit pull requests or open issues.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is open source and available under the MIT License.
Made with ❤️ for plant lovers
Note: This is an educational project. For production use, implement additional security measures and follow best practices for database management and password storage.

