State-Driven Tea Machine (Core Java, Dockerization)
State-Driven Tea Machine (Core Java, Dockerization)

Click Here To See The Project Codebase

A sophisticated Java desktop application demonstrating advanced software design patterns and architectural principles. This project implements a state-driven tea machine control system with real-time monitoring, database persistence, and a modern Swing-based GUI.

Project Overview

This application simulates a tea machine control system that manages different operational states (Empty, Idle, Boiling Water, Making Tea, Done) with comprehensive state management, event-driven architecture, and persistent data storage. The system demonstrates enterprise-level Java development practices and design pattern implementations.

Architecture & Design Patterns

GoF Design Patterns Implemented

State Pattern - Manages machine state transitions with 5 concrete state implementations (Empty, Idle, Boiling Water, Making Tea, Done). Eliminates complex conditional logic and encapsulates state-specific behavior.

Observer Pattern - Decouples UI updates from business logic using Subject-Observer architecture. Implements event-driven reactive updates with type-safe Event records.

Strategy Pattern - Encapsulates different timer execution algorithms (MakeTeaTimerStrategy, BoilWaterTimerStrategy) with runtime strategy selection.

Decorator Pattern - Composable message system with dynamic functionality addition (WarningDecorator, ThresholdDecorator) enabling flexible message composition.

Singleton Pattern - Database connection management with static initialization for resource pooling.

MVC Architecture - Model-View-Controller separation with MachineContext (Model/Subject), MainInterface (View/Observer), and MachineController (Controller).

Technologies & Frameworks

Core Technologies:

  • Java 17 (Records, Pattern Matching, Text Blocks, Optional API, LocalDateTime, Stream API, Lambda Expressions)
  • Java Swing (Desktop GUI framework)
  • MySQL Connector/J 8.0.32 (JDBC database connectivity)
  • Maven (Dependency management and build automation)
  • Docker (Containerized MySQL database)
  • JDBC (Database access layer with Prepared Statements)

Database:

  • MySQL with normalized schema design, foreign key relationships, prepared statements for SQL injection prevention, and transaction support

Key Features

  • State Management: 5 operational states with controlled transitions and database persistence
  • Concurrency: Asynchronous execution using java.util.Timer and TimerTask with thread-safe operations
  • Message System: Decorated messages with automatic threshold detection and warnings
  • Database Integration: Persistent storage with daily/monthly analytics and threshold management
  • User Interface: Swing GUI with real-time updates via Observer pattern, state visualization, and input validation

Advanced Java Concepts

Modern Java Features:

  • Records for immutable DTOs
  • Pattern matching with switch expressions
  • Text blocks for multi-line SQL queries
  • Optional API for null safety
  • Stream API and functional programming
  • Lambda expressions and functional interfaces

Best Practices:

  • SOLID Principles (Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion)
  • DRY (Don't Repeat Yourself)
  • Separation of Concerns
  • Encapsulation
  • Polymorphism and interface-based programming

Concurrency & Threading:

  • Timer & TimerTask for asynchronous task scheduling
  • Thread-safe synchronization mechanisms
  • Event-driven architecture with non-blocking UI updates

Database Best Practices:

  • Connection management with Singleton pattern for connection pooling
  • Try-with-resources for automatic resource cleanup
  • Normalized schema design
  • Prepared statements for SQL injection prevention

Technical Skills Demonstrated

  • Object-Oriented Design with advanced OOP principles
  • GoF Design Patterns (State, Observer, Strategy, Decorator, Singleton)
  • Java Enterprise Development
  • Database Integration (JDBC, SQL, data persistence)
  • GUI Development (Swing framework, event handling)
  • Software Architecture (MVC, layered architecture)
  • Modern Java (Java 17 features and best practices)
  • Concurrency and Threading
  • Docker containerization
  • Maven build automation

Project Highlights

  • 6 Design Patterns implemented (State, Observer, Strategy, Decorator, Singleton, MVC)
  • Java 17 modern features throughout
  • Database persistence with MySQL
  • Thread-safe concurrent operations
  • Clean Architecture with separation of concerns
  • Comprehensive error handling and validation
  • Dockerized database setup