Skip to content

Latest commit

Β 

History

31 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯€ Vital Vending Machine (VVM) - Smart Vending Management System

Java JavaFX Arduino MySQL License Version

πŸŽ“ University Project | A complete smart vending machine management system with hardware integration


πŸ“‹ Table of Contents


🎯 Overview

Vital Vending Machine (VVM) is a comprehensive smart vending machine management system developed as a university capstone project. It seamlessly integrates a modern JavaFX desktop application with Arduino hardware through serial communication, creating a complete vending solution.

The system simulates a real-world vending environment with:

  • πŸ” Multi-level authentication (User/Admin)
  • πŸ“Š Real-time sales tracking and analytics
  • πŸ“ Comprehensive logging system
  • 🎨 Modern glass-morphism UI design
  • πŸ€– Hardware integration with Arduino
  • πŸ“’ Smart advertisement display system

✨ Key Features

πŸ” Advanced Authentication System

Feature Description
πŸ‘€ User Login Secure access for regular users
πŸ‘‘ Admin Login Privileged access for administrators
πŸ›‘οΈ Role-based Access SuperAdmin, Manager, Operator levels
πŸ“ Activity Logging Complete entry/exit tracking
πŸ”’ Password Security BCRYPT hashing for credentials

πŸ‘₯ User & Admin Management

  • βœ… Create Users with complete profiles
  • βœ… Create Admins with specific permission levels
  • βœ… View & Manage user lists
  • βœ… Edit Profiles with full CRUD operations
  • βœ… Permission-based interface rendering

πŸ›’ Smart Sales System

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Product       │────▢│   Confirmation  │────▢│   Payment       β”‚
β”‚   Selection     β”‚     β”‚   & Settings    β”‚     β”‚   Processing    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  • 🎯 Two-step sales interface
  • βš™οΈ Customizable product settings (sweetness, caffeine, temperature)
  • πŸ“Š Automatic sales logging
  • πŸ“ˆ Real-time inventory tracking
  • πŸ’³ Multiple payment methods support

πŸ“Š Comprehensive Logging System

Log Type Tracked Data
πŸ“ Entry/Exit Logs User/Admin access times, IP, device info
πŸ’° Sales Logs Products, quantities, prices, timestamps
πŸ‘¨β€πŸ’Ό Admin Actions All administrative activities
πŸ“ˆ System Events Application events and errors

πŸ“’ Smart Advertisement Mode

graph LR
    A[Active Session] -->|1 min idle| B[Advertisement Mode]
    B -->|Click/Key Press| A
    B -->|Slideshow| C[Display Ads]
    C -->|Loop| B
Loading
  • ⏱️ Auto-activates after 1 minute of inactivity
  • πŸ–ΌοΈ Dynamic slideshow of advertisement images
  • πŸ”„ Returns instantly on user interaction
  • πŸ“ Auto-loads from server directory

🎨 Modern UI/UX Design

  • πŸŒ“ Dynamic Dark/Light mode based on time
  • πŸͺŸ Glass-morphism effects with iOS 16 aesthetics
  • ✨ Smooth animations and transitions
  • πŸ“± Responsive layout for all screen sizes
  • 🎯 Intuitive navigation with visual feedback

πŸ€– Hardware Integration

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   JavaFX    │────▢│   Serial     │────▢│   Arduino   β”‚
β”‚   App       │◀────│ Communication│◀────│   Hardware  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  • πŸ”˜ Physical button triggers
  • πŸ’‘ LED status indicators
  • πŸ“Ÿ LCD display integration
  • πŸ”Œ Real-time hardware feedback

πŸ“Έ Screenshots

Login Page
πŸ” Login Page
User Dashboard
πŸ‘€ User Dashboard
Admin Panel
πŸ‘‘ Admin Panel
Add User
βž• Add User
Add Admin
πŸ‘₯ Add Admin
Sales Step 1
πŸ›’ Product Selection
Sales Step 2
βœ… Confirmation Page
Sales Logs
πŸ“Š Sales Logs
Entry Logs
πŸ“ Entry Logs
Admin Logs
πŸ” Admin Logs
Advertisement Page
πŸ“’ Advertisement Mode

πŸ—οΈ System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     PRESENTATION LAYER                       β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚ Login    β”‚  β”‚ User     β”‚  β”‚ Admin    β”‚  β”‚ Screens  β”‚   β”‚
β”‚  β”‚ Pages    β”‚  β”‚ Panels   β”‚  β”‚ Panels   β”‚  β”‚ ayer    β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                     BUSINESS LAYER                           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚ Auth     β”‚  β”‚ Sales    β”‚  β”‚ Cache    β”‚  β”‚ Idle     β”‚   β”‚
β”‚  β”‚ Manager  β”‚  β”‚ Manager  β”‚  β”‚ Manager  β”‚  β”‚ Monitor  β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                      DATA LAYER                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚ ApiClientβ”‚  β”‚ Cache    β”‚  β”‚ Serial   β”‚  β”‚ Database β”‚   β”‚
β”‚  β”‚          β”‚  β”‚ System   β”‚  β”‚ Comm     β”‚  β”‚          β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β–Ό                   β–Ό
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚   MySQL       β”‚   β”‚   Arduino     β”‚
            β”‚   Database    β”‚   β”‚   Hardware    β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Technology Stack

Backend & Core

Technology Version Purpose
β˜• Java 21 LTS Core programming language
πŸ—οΈ JDBC 8.0 Database connectivity
πŸ” BCrypt 0.9 Password hashing
πŸ“¦ Maven 3.9 Build automation

Frontend

Technology Version Purpose
🎨 JavaFX 21 UI framework
πŸ“ FXML - UI markup
🎭 CSS - Styling
✨ Animation - Smooth transitions

Hardware

Component Purpose
πŸ”˜ Arduino Uno Main controller
πŸ“Ÿ LCD 16x2 Display interface
πŸ’‘ LEDs Status indicators
πŸ”Œ Buttons Physical input
πŸ“‘ Serial Port Communication

Database

-- Main tables
β”œβ”€β”€ users
β”œβ”€β”€ admins
β”œβ”€β”€ buttons
β”œβ”€β”€ sales_logs
β”œβ”€β”€ user_login_logs
β”œβ”€β”€ adminlogs
└── api_keys

πŸš€ Getting Started

πŸ“‹ Prerequisites

πŸ“¦ Quick Download

Download

https://sadraghofran.ir/VVM.zip

πŸ’» Usage Guide

πŸ” Login Credentials

Role Username Password Level
πŸ‘‘ SuperAdmin ... ... SuperAdmin
πŸ‘¨β€πŸ’Ό user test_user 123456789 user

πŸ“± User Mode

  1. Login with user credentials
  2. Browse products with pagination
  3. Select product β†’ Configure settings
  4. Confirm order β†’ Complete purchase
  5. View logs of your transactions

πŸ‘‘ Admin Mode

SuperAdmin Features

  • πŸ‘₯ Manage Admins (Add/Edit/Delete)
  • πŸ‘€ Manage Users (Add/Edit/Delete)
  • πŸ–₯️ Manage Devices (Configure)
  • πŸ“¦ Manage Products (Buttons)
  • πŸ“Š View All Logs (System-wide)

Manager Features

  • πŸ‘€ View Users
  • πŸ–₯️ View Devices
  • πŸ“Š View Reports

Operator Features

  • πŸ‘€ Basic User View
  • πŸ–₯️ Device Status

πŸ“Š Database Schema

Core Tables Structure

-- Users table
CREATE TABLE `users` (
  `id` int NOT NULL AUTO_INCREMENT,
  `fullname` varchar(150) NOT NULL,
  `username` varchar(100) NOT NULL UNIQUE,
  `password` varchar(255) NOT NULL,
  `phone` varchar(20),
  `email` varchar(150),
  `address` text,
  `company_name` varchar(150),
  `ceo_name` varchar(150),
  `ceo_phone` varchar(20),
  `ceo_email` varchar(150),
  `device_location` text,
  `background_image` varchar(255) DEFAULT 'default_bg.jpg',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `created_by_admin` varchar(100),
  PRIMARY KEY (`id`)
);

-- Admins table
CREATE TABLE `admins` (
  `id` int NOT NULL AUTO_INCREMENT,
  `username` varchar(50) NOT NULL UNIQUE,
  `password` varchar(255),
  `fullname` varchar(100),
  `email` varchar(100),
  `phone` varchar(20),
  `level` varchar(20),
  PRIMARY KEY (`id`)
);

-- Buttons table
CREATE TABLE `buttons` (
  `id` int NOT NULL AUTO_INCREMENT,
  `user_id` int NOT NULL,
  `title` varchar(100) NOT NULL,
  `caption` text,
  `image` varchar(255),
  `price` decimal(10,2) NOT NULL,
  `sweetness_level` int DEFAULT 0,
  `caffeine_level` int DEFAULT 0,
  `temperature_level` int DEFAULT 0,
  `stock` int DEFAULT 0,
  PRIMARY KEY (`id`),
  FOREIGN KEY (`user_id`) REFERENCES `users`(`id`)
);

-- Sales logs
CREATE TABLE `sales_logs` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `user_id` int NOT NULL,
  `username` varchar(100) NOT NULL,
  `fullname` varchar(150) NOT NULL,
  `button_id` int NOT NULL,
  `button_title` varchar(100) NOT NULL,
  `quantity` int DEFAULT 1,
  `total_price` decimal(10,2),
  `sold_at` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  FOREIGN KEY (`user_id`) REFERENCES `users`(`id`),
  FOREIGN KEY (`button_id`) REFERENCES `buttons`(`id`)
);

πŸ”§ Hardware Setup

πŸ“‹ Components List

  • 1x Arduino Uno
  • 1x LCD 16x2 with I2C
  • 4x Push buttons
  • 3x LEDs (Red, Green, Blue)
  • 1x Buzzer (optional)
  • Resistors and wires

πŸ”Œ Circuit Diagram

Arduino Uno         Components
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Pin 2   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€ Button1 β”‚
β”‚ Pin 3   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€ Button2 β”‚
β”‚ Pin 4   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€ Button3 β”‚
β”‚ Pin 5   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€ Button4 β”‚
β”‚ Pin 6   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€ LED-Red β”‚
β”‚ Pin 7   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€ LED-Greenβ”‚
β”‚ Pin 8   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€ LED-Blue β”‚
β”‚ Pin 9   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€ Buzzer   β”‚
β”‚ SDA(20) β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€ LCD SDA  β”‚
β”‚ SCL(21) β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€ LCD SCL  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“Ÿ Arduino Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

const int button1 = 2;
const int button2 = 3;
const int button3 = 4;
const int button4 = 5;
const int ledRed = 6;
const int ledGreen = 7;
const int ledBlue = 8;

void setup() {
  Serial.begin(9600);
  lcd.init();
  lcd.backlight();
  
  pinMode(button1, INPUT_PULLUP);
  pinMode(button2, INPUT_PULLUP);
  pinMode(button3, INPUT_PULLUP);
  pinMode(button4, INPUT_PULLUP);
  pinMode(ledRed, OUTPUT);
  pinMode(ledGreen, OUTPUT);
  pinMode(ledBlue, OUTPUT);
  
  lcd.setCursor(0, 0);
  lcd.print("VVM Ready");
}

void loop() {
  if (Serial.available() > 0) {
    String command = Serial.readStringUntil('\n');
    processCommand(command);
  }
  
  checkButtons();
}

void processCommand(String cmd) {
  if (cmd.startsWith("LCD:")) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print(cmd.substring(4));
  }
  else if (cmd.startsWith("LED:")) {
    String ledCmd = cmd.substring(4);
    if (ledCmd == "RED_ON") digitalWrite(ledRed, HIGH);
    if (ledCmd == "RED_OFF") digitalWrite(ledRed, LOW);
    // ... etc
  }
}

void checkButtons() {
  if (digitalRead(button1) == LOW) {
    Serial.println("BUTTON:1");
    delay(200);
  }
  // ... check other buttons
}

πŸ“ˆ Performance

Benchmark Results

Operation Time Cache Status
πŸ” Login < 100ms -
πŸ“‹ Load Products (first) 350ms Miss
πŸ“‹ Load Products (cached) 15ms Hit 🎯
πŸ“Š Load Sales Logs 280ms -
πŸ‘₯ Load Users 320ms -
πŸ–ΌοΈ Load Images 150-500ms Varies

Cache Statistics

  • 🎯 Hit Rate: 85%
  • πŸ“¦ Memory Usage: ~50MB
  • πŸ’Ύ Disk Cache: ~200MB
  • ⚑ Response Time Improvement: 65%

πŸ“ž Contact

Project Team

About

This project is written in Java language

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages