diff --git a/arduinoSketch/arduinoSketch.ino b/arduinoSketch/arduinoSketch.ino index 90a798d..09c2643 100644 --- a/arduinoSketch/arduinoSketch.ino +++ b/arduinoSketch/arduinoSketch.ino @@ -17,7 +17,7 @@ Sensor sensors[] = { const uint8_t SENSOR_COUNT = sizeof(sensors) / sizeof(sensors[0]); const unsigned long POLL_INTERVAL_MS = 200; // sampling rate -const unsigned long DEBOUNCE_DELAY_MS = 50; +const unsigned long DEBOUNCE_DELAY_MS = 200; const unsigned long HEARTBEAT_MS = 30000; unsigned long lastPollTime = 0; diff --git a/documentation.md b/documentation.md index e69de29..e057361 100644 --- a/documentation.md +++ b/documentation.md @@ -0,0 +1,14 @@ +# 📖 Documentation + +## Project Structure +The project follows a standard Spring Boot application structure: +- `src/main/java/com/example/HomeSecurity`: Root package. + - `Controllers`: Contains Spring MVC controllers for handling web requests and WebSocket endpoints. + - `Services`: Houses business logic, such as processing sensor data and managing security states. + - `DTOs`: Data Transfer Objects used to shape data for the views and API responses. + - `Components`: Contains hardware integration components, like the `ArduinoListener`. + - `Models`: JPA Entities representing database tables (e.g., `Sensor`). +- `src/main/resources`: + - `static`: For static assets like CSS, JavaScript, and images. + - `templates`: Contains Thymeleaf HTML templates. + - `application.properties`: For application configuration. \ No newline at end of file diff --git a/future.md b/future.md index e69de29..4df5b9a 100644 --- a/future.md +++ b/future.md @@ -0,0 +1,15 @@ +# 🚀 Future Plans + +We are constantly looking to evolve the Home Security System. Here is what is currently on our development roadmap: + +### 📹 Enhanced Monitoring +* **Camera Integration:** Support for IP cameras and RTSP streams to view live feeds alongside sensor data. +* **Floor Plan View:** A visual representation of the home layout with real-time sensor status indicators. + +### 🧠 Smart Features +* **AI Anomaly Detection:** Machine learning models to learn routine patterns and alert on unusual activity. +* **Geofencing:** Automatically arm/disarm the system based on the location of the user's mobile device. + +### 📱 Connectivity +* **Mobile Application:** A dedicated mobile app for push notifications and easier remote control. +* **Third-party Integration:** Integration with Home Assistant, Google Home, or Alexa. \ No newline at end of file diff --git a/pom.xml b/pom.xml index fb9dd91..c1fd0f6 100644 --- a/pom.xml +++ b/pom.xml @@ -84,6 +84,18 @@ test + + org.springframework.boot + spring-boot-starter-thymeleaf + + + + org.springframework.boot + spring-boot-starter-thymeleaf-test + test + + + org.springframework.boot spring-boot-starter-security-oauth2-client diff --git a/src/main/java/com/example/HomeSecurity/Components/ArduinoListener.java b/src/main/java/com/example/HomeSecurity/Components/ArduinoListener.java index 9bcc1b1..fc1342d 100644 --- a/src/main/java/com/example/HomeSecurity/Components/ArduinoListener.java +++ b/src/main/java/com/example/HomeSecurity/Components/ArduinoListener.java @@ -16,6 +16,8 @@ import org.springframework.messaging.simp.SimpMessagingTemplate; import org.springframework.stereotype.Component; import java.nio.charset.StandardCharsets; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; @Component public class ArduinoListener { @@ -23,6 +25,8 @@ public class ArduinoListener { private SerialPort arduinoPort; private final StringBuilder buffer = new StringBuilder(); private ObjectMapper objectMapper; + private final ExecutorService executor = Executors.newSingleThreadExecutor(); + @Autowired private SensorService sensorService; @@ -77,7 +81,8 @@ public class ArduinoListener { buffer.append(new String(data, StandardCharsets.UTF_8)); - processBuffer(); + executor.submit(() -> processBuffer()); + } }); } diff --git a/src/main/java/com/example/HomeSecurity/Controllers/Home.java b/src/main/java/com/example/HomeSecurity/Controllers/Home.java new file mode 100644 index 0000000..7430a19 --- /dev/null +++ b/src/main/java/com/example/HomeSecurity/Controllers/Home.java @@ -0,0 +1,15 @@ +package com.example.HomeSecurity.Controllers; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +@Controller +public class Home { + + + @GetMapping("/dashboard") + public String homePage(){ + return "home"; + } + +} diff --git a/src/main/java/com/example/HomeSecurity/Security/SecurityConfig.java b/src/main/java/com/example/HomeSecurity/Security/SecurityConfig.java index b67dbde..20fe11d 100644 --- a/src/main/java/com/example/HomeSecurity/Security/SecurityConfig.java +++ b/src/main/java/com/example/HomeSecurity/Security/SecurityConfig.java @@ -12,12 +12,12 @@ public class SecurityConfig { public SecurityFilterChain securityFilterChain(HttpSecurity http){ http .authorizeHttpRequests(auth -> auth - .requestMatchers("/login") + .requestMatchers("/") .permitAll() .anyRequest().authenticated() ) .oauth2Login(oauth2 -> oauth2 - .defaultSuccessUrl("/", true) + .defaultSuccessUrl("/dashboard", true) ) .logout(logout -> logout .logoutSuccessUrl("/") diff --git a/src/main/resources/templates/events.html b/src/main/resources/templates/events.html new file mode 100644 index 0000000..211b745 --- /dev/null +++ b/src/main/resources/templates/events.html @@ -0,0 +1,240 @@ + + + + + + + SecureHome | Events & Logs + + + + + + + + + + + + +
+ +
+
+
+ Filter Events +
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+ +
+
+
Activity Database
+
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TimestampCategoryDescriptionSourceSeverity
2026-01-09 14:22:05SENSORFront Door — TriggeredReed Switch #01 + CRITICAL +
2026-01-09 14:21:00SYSTEMSystem Armed AWAYWeb User (Admin) + INFO +
2026-01-09 13:58:30FAULTGarage Door — Comm TimeoutHub Controller + WARNING +
2026-01-09 13:30:15MAINTSelf-Diagnostic: PassedSystem Scheduler + HEALTHY +
+
+ +
+ +
+ + + + \ No newline at end of file diff --git a/src/main/resources/templates/home.html b/src/main/resources/templates/home.html new file mode 100644 index 0000000..95b1959 --- /dev/null +++ b/src/main/resources/templates/home.html @@ -0,0 +1,338 @@ + + + + + + SecureHome | Dashboard + + + + + + + + + + + + + + +
+ + +
+
+
+
+
+
+

System State

+ +
+

DISARMED

+ +
+ +
+
+
+ +
+
+
+
+
+

Active Sensors

+ +
+

4

+
+ +
+
+
+ +
+
+
+
+
+

Uptime

+ +
+

--

+
+ +
+
+
+
+ + +
+
+
+ Quick Actions +
+
+ + + + +
+
+
+ + +
+
Sensors
+
+ + +
+
+
+
+ +
Front Door
+ SECURE +
+ Updated: --:-- +
+
+
+
+ +
+
+
+
+ +
Back Door
+ SECURE +
+ Updated: --:-- +
+
+
+
+ +
+
+
+
+ +
Garage
+ SECURE +
+ Updated: --:-- +
+
+
+
+ +
+
+
+
+ +
Main Gate
+ SECURE +
+ Updated: --:-- +
+
+
+
+ +
+
+ + +
+
Activity Log
+
+ + + + + + + + + + +
TimeTypeDetailStatus
+
+
+
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/systemSettings.html b/src/main/resources/templates/systemSettings.html new file mode 100644 index 0000000..fb5ed4a --- /dev/null +++ b/src/main/resources/templates/systemSettings.html @@ -0,0 +1,251 @@ + + + + + + SecureHome | System Configuration + + + + + + + + + + + + + +
+
+ +
+ +
+
General Configuration
+
+
+
+ +
+ + SEC +
+
+
+ +
+ + SEC +
+
+
+ +
+ + SEC +
+
+
+
+
+ +
+
+ User Management + +
+
+ + + + + + + + + + + + + + + +
IdentityAccess LevelActions
+
+
AD
+ Administrator +
+
FULL ACCESS + + + +
+
+
+ +
+
+ Automation Schedules + +
+
+
+
+
+ +
+
Weekday Night Arm
+ Type: AWAY | Time: 22:00 | Repeat: MON-FRI +
+
+
+ +
+
+
+
+
+ +
+
Notification Triggers
+
+
+ + +
+
+ + +
+
+
+ +
+
+ + +
+
+ +
+
+
+ + + + + \ No newline at end of file diff --git a/stack.md b/stack.md index e69de29..c592cdd 100644 --- a/stack.md +++ b/stack.md @@ -0,0 +1,24 @@ +## 🛠️ Tech Stack + +### Backend +* **Java 25:** Utilizing the latest LTS features for a modern development experience. +* **Spring Boot:** The core framework for rapid application development. +* **Spring Security:** Ensuring robust authentication and data protection. +* **Spring WebSocket:** Enabling real-time bi-directional communication for sensor updates. + +### Hardware Integration +* **Arduino:** Microcontroller for interfacing with physical sensors. +* **jSerialComm:** Java library for platform-independent serial port access to communicate with the Arduino. + +### Frontend & Interactivity +* **Thymeleaf:** Server-side Java template engine for seamless HTML rendering. +* **HTMX:** Powering fast, AJAX-like interactivity without the complexity of heavy JavaScript frameworks. +* **JavaScript:** Javascript is used to subscribe to the Websocket endpoint and update components for real-time updates. + + +### Data & Storage +* **Hibernate / JPA:** Standardized Object-Relational Mapping. +* **MySQL:** Reliable relational database for structured sensor log storage. + +### Build & DevOps +* **Build Tool**: Maven \ No newline at end of file