π Smart Home Automation System
A comprehensive Smart Home Automation System demonstrating the practical application of six fundamental software design patterns . Built as part of CTIS 417 - Software Design Patterns course at Bilkent University.
Name
Role
Onurcan GenΓ§
Developer
Efe Baran Durmaz
Developer
Moein Faghih
Developer
Feature
Description
Pattern Used
π Multi-Protocol Support
WiFi 2.4GHz, WiFi 5GHz, IEEE 802.15.4
Abstract Factory
π‘ Real-time Monitoring
Instant notifications to multiple clients
Observer
π Role-Based Access
Admin and User permission levels
Proxy
π’ Hierarchical Management
Building β Room β Device structure
Composite
ποΈ Centralized Control
All devices coordinated through hub
Mediator
βοΈ Global Configuration
Single source of system settings
Singleton
#
Pattern
Type
Class
Purpose
1
Singleton
Creational
SystemConfiguration
Single instance for global system settings
2
Abstract Factory
Creational
DeviceFactory
Protocol-specific device creation
3
Composite
Structural
BuildingComposite
Hierarchical building/room/device structure
4
Proxy
Structural
SecureDeviceProxy
Role-based access control
5
Observer
Behavioral
Subject/Observer
Event notification system
6
Mediator
Behavioral
SmartHomeHubMediator
Centralized device coordination
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DESIGN PATTERNS β
βββββββββββββββββββ¬ββββββββββββββββββ¬ββββββββββββββββββββββββββ€
β CREATIONAL β STRUCTURAL β BEHAVIORAL β
βββββββββββββββββββΌββββββββββββββββββΌββββββββββββββββββββββββββ€
β β’ Singleton β β’ Composite β β’ Observer β
β β’ Abstract β β’ Proxy β β’ Mediator β
β Factory β β β
βββββββββββββββββββ΄ββββββββββββββββββ΄ββββββββββββββββββββββββββ
The complete system architecture showing all classes, interfaces, and their relationships:
π Click to view diagram explanation
CompositeComponent (Interface): Base interface for all controllable elements
Device (Interface): Extends CompositeComponent, adds reset functionality
Subject/Observer (Interfaces): Enables publish-subscribe pattern
DeviceFactory (Interface): Abstract factory for creating device families
SmartHomeHubMediator : Central coordinator for all device interactions
SecureDeviceProxy : Protection proxy for access control
Inheritance : Device classes implement Device interface
Composition : BuildingComposite contains CompositeComponents
Association : Mediator manages Device collection
Dependency : Factories create Device instances
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Main β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββΌβββββββββββββββββββββββ
βΌ βΌ βΌ
βββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββ
β SystemConfig β β DeviceFactory β β SecureDevice β
β (Singleton) β β (Abstract Fact.)β β Proxy β
βββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββ
β β
βββββββββββββββββΌββββββββββββββββ β
βΌ βΌ βΌ βΌ
ββββββββββββ ββββββββββββ ββββββββββββ β
βWiFi 2.4 β βWiFi 5GHz β βLowPower β β
β Factory β β Factory β β 802.15.4 β β
ββββββββββββ ββββββββββββ ββββββββββββ β
β β β β
βββββββββββββββββΌββββββββββββββββ β
βΌ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SmartHomeHubMediator β
β (Central Hub) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββ¬ββββββββββββΌββββββββββββ¬ββββββββββ
βΌ βΌ βΌ βΌ βΌ
ββββββββββ ββββββββββ ββββββββββββ ββββββββββ ββββββββββ
β Light β βThermo- β β Motion β β Door β βBuildingβ
β β β stat β β Sensor β β Lock β βCompsiteβ
ββββββββββ ββββββββββ ββββββββββββ ββββββββββ ββββββββββ
β β
ββββββββ¬βββββββ
βΌ
βββββββββββββββββββββββββββββββ
β Observers β
βββββββββββββββββββββββββββββββ€
β β’ DashboardView β
β β’ MobileAppClient β
β β’ AlertService β
βββββββββββββββββββββββββββββββ
CTIS417_Java/
β
βββ π CTIS417_Java.iml # IntelliJ IDEA module file
βββ π .gitignore # Git ignore rules
βββ π README.md # This file
βββ π LICENSE # MIT License
β
βββ π src/
β βββ π app/
β β βββ π Main.java # π Entry point
β β
β βββ π config/
β β βββ π SystemConfiguration.java # βοΈ Singleton
β β
β βββ π device/
β β βββ π Device.java # Interface
β β βββ π Light.java # π‘ Light device
β β βββ π Thermostat.java # π‘οΈ Temperature control
β β βββ π MotionSensor.java # ποΈ Motion detection
β β βββ π DoorLock.java # π Security lock
β β
β βββ π factory/
β β βββ π DeviceFactory.java # π Abstract Factory
β β βββ π WiFi24GHzDeviceFactory.java # 2.4GHz implementation
β β βββ π WiFi5GHzDeviceFactory.java # 5GHz implementation
β β βββ π LowPower80215DeviceFactory.java # 802.15.4 implementation
β β
β βββ π composite/
β β βββ π CompositeComponent.java # π§© Component interface
β β βββ π BuildingComposite.java # π’ Composite container
β β
β βββ π observer/
β β βββ π Observer.java # π Observer interface
β β βββ π Subject.java # π’ Subject interface
β β βββ π DashboardView.java # π Dashboard client
β β βββ π MobileAppClient.java # π± Mobile client
β β βββ π AlertService.java # π¨ Alert service
β β
β βββ π mediator/
β β βββ π SmartHomeHubMediator.java # ποΈ Central mediator
β β
β βββ π proxy/
β βββ π SecureDeviceProxy.java # π‘οΈ Security proxy
β
βββ π docs/
β βββ π Class_Diagram.svg # π UML Class Diagram
β βββ π SmartHome_DesignPatterns_CTIS417.pptx # π½οΈ Presentation
β
βββ π out/ # Compiled classes (ignored)
β Java JDK 17 or higher
π» IntelliJ IDEA (recommended) or any Java IDE
π§ Git
# Clone the repository
git clone https://github.com/yourusername/SmartHomeAutomation.git
# Navigate to project directory
cd SmartHomeAutomation
Option 2: Open in IntelliJ IDEA
Open IntelliJ IDEA
File β Open β Select project folder
Trust the project
Wait for indexing to complete
Run Main.java
# Compile all Java files
javac -d out src/** /* .java
# Run the application
java -cp out app.Main
// 1. Get system configuration (Singleton)
SystemConfiguration config = SystemConfiguration .getInstance ();
config .printCurrentConfiguration ();
// 2. Create devices using Abstract Factory
DeviceFactory wifiFactory = new WiFi24GHzDeviceFactory ();
Light light = wifiFactory .createLight ();
Thermostat thermostat = wifiFactory .createThermostat ();
// 3. Set up Observer pattern for notifications
DashboardView dashboard = new DashboardView ();
AlertService alerts = new AlertService ();
thermostat .addObserver (dashboard );
thermostat .addObserver (alerts );
// 4. Use Composite pattern for building structure
BuildingComposite building = new BuildingComposite ();
BuildingComposite livingRoom = new BuildingComposite ();
livingRoom .add (light );
livingRoom .add (thermostat );
building .add (livingRoom );
// Turn on all devices in building
building .turnOn ();
// 5. Use Mediator for centralized control
SmartHomeHubMediator hub = new SmartHomeHubMediator ();
hub .addDevice (light );
hub .addDevice (thermostat );
hub .resetSensors ();
// 6. Use Proxy for access control
CompositeComponent secureLight = new SecureDeviceProxy (light , hub , "admin" );
secureLight .turnOn (); // β
Access granted
CompositeComponent userLight = new SecureDeviceProxy (light , hub , "user" );
userLight .turnOn (); // β Access denied
The SystemConfiguration singleton provides centralized configuration management:
Setting
Default
Description
hubIpAddress
192.168.1.100
Smart Hub IP
hubPort
8080
Hub port number
wifiSSID
SmartHome_Network
WiFi network name
maxConnectedDevices
50
Maximum devices
networkTimeout
30000ms
Connection timeout
Setting
Default
Description
securityEnabled
true
Enable security
maxLoginAttempts
3
Login attempt limit
sessionTimeoutMinutes
30
Session duration
twoFactorEnabled
false
2FA status
encryptionAlgorithm
AES-256
Encryption type
Setting
Default
Description
minTemperatureThreshold
16.0Β°C
Minimum comfortable
maxTemperatureThreshold
28.0Β°C
Maximum comfortable
criticalHighTemperature
40.0Β°C
Fire alarm trigger
criticalLowTemperature
5.0Β°C
Freeze warning
Setting
Default
Description
energySavingMode
false
Energy saving
maxPowerConsumptionWatts
5000W
Power limit
peakHoursStart
17:00
Peak hours begin
peakHoursEnd
21:00
Peak hours end
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SMART HOME SYSTEM CONFIGURATION LOADED β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£
β System: SmartHome Hub Pro β
β Version: 2.1.0 β
β Hub IP: 192.168.1.100:8080 β
β Security: ENABLED β
β Max Devices: 50 β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
=== Singleton Pattern ===
SystemConfiguration instance created.
Same instance: true
=== Abstract Factory Pattern ===
WiFi24GHzDeviceFactory: Creating Light.
WiFi24GHzDeviceFactory: Creating Thermostat.
LowPower80215DeviceFactory: Creating MotionSensor.
LowPower80215DeviceFactory: Creating DoorLock.
=== Observer Pattern ===
-- MotionSensor detects motion --
MotionSensor: Motion detected!
DashboardView: Received update notification. Motion detected!
AlertService: Received update notification. Motion detected!
-- Thermostat detects abnormal temperature --
β οΈ Thermostat: HIGH temperature detected! 45.0Β°C exceeds max threshold
DashboardView: Received update notification. Temperature Alert!
MobileAppClient: Received update notification. Temperature Alert!
=== Mediator Pattern ===
MotionSensor reset. No motion detected as default.
Thermostat reset. Temperature read as 25Β°C by default.
DoorLock reset. Unlocked by default.
Light reset. Off by default.
=== Composite Pattern ===
BuildingComposite: Turning on all children.
Light turned on.
Thermostat turned on.
MotionSensor turned on.
DoorLock locked.
=== Proxy Pattern ===
-- ADMIN user accessing Light --
Mediator: Checking access for role 'admin' to perform 'turnOn'
Mediator: Access GRANTED.
Light turned on.
-- USER accessing Light --
Mediator: Checking access for role 'user' to perform 'turnOn'
Mediator: Access DENIED.
Document
Description
Link
π UML Class Diagram
Complete system architecture
Class_Diagram.svg
π½οΈ Presentation
Project presentation slides
PPTX
π This README
Project documentation
You're here!
π οΈ Technologies Used
Language : Java 17+
IDE : IntelliJ IDEA
Build : Standard Java Compiler
Version Control : Git & GitHub
Documentation : Markdown, Mermaid (UML)
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2024 Onurcan GenΓ§, Efe Baran Durmaz, Moein Faghih
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software...
π CTIS 417 - Software Design Patterns Course
π Bilkent University - Department of Computer Technology and Information Systems
π Gang of Four - Design Patterns: Elements of Reusable Object-Oriented Software
π¨βπ« Our instructor for guidance and feedback
Made with β€οΈ by Onurcan , Efe Baran & Moein
β Star this repository if you found it helpful!