Skip to content

Robertise/Smart-Home-Management-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

104 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Building Smart Home Management System

COS20031 - Database Design Project

A comprehensive web-based Building Management System designed for monitoring and controlling building infrastructure, including rooms, devices, sensors, and automated scheduling. Built as a full-stack application with a modern React frontend and Node.js backend.


πŸ“‹ Project Overview

This is a Swinburne University Database Design course project that implements a Building Management System. The system provides real-time monitoring of room conditions (temperature & humidity), device management, automated scheduling, maintenance tracking, and room booking capabilities.

Key Features

  • Real-Time Monitoring: Track temperature and humidity across multiple rooms with live sensor data
  • Device Management: View and control active/inactive devices with state management
  • Automated Scheduling: Schedule device operations with cron-based automation
  • Notifications & Alerts: Receive real-time notifications and alerts for system events
  • System Logs: Comprehensive logging of all system activities for audit trails
  • Room Bookings: Manage and view room availability and bookings
  • Worker Management: Track maintenance workers and assignments
  • User Authentication: Secure login system with role-based access control
  • Historical Data: Access sensor historical data and trends with visualization

πŸ› οΈ Technology Stack

Frontend

  • React 19 - UI library
  • Vite - Fast build tool and dev server
  • TailwindCSS - Utility-first CSS framework
  • Material-UI - Pre-built UI components
  • Recharts - Data visualization library
  • React Router - Client-side routing
  • Supabase JS Client - Backend integration

Backend

  • Node.js - Runtime environment
  • Express 5.x - Web framework
  • Supabase - Backend-as-a-Service (Database, Authentication)
  • Node-cron - Job scheduling
  • CORS - Cross-origin resource sharing

Database

  • PostgreSQL - Relational database (via Supabase)
  • Sensor readings and device state management
  • User and worker information
  • System logs and notifications

πŸ“ Project Structure

Smart-Home-Management-System/
β”œβ”€β”€ Backend/                          # Node.js Express API server
β”‚   β”œβ”€β”€ index.js                      # Main server entry point
β”‚   β”œβ”€β”€ package.json                  # Backend dependencies
β”‚   └── functions/
β”‚       β”œβ”€β”€ get/                      # GET endpoints for data retrieval
β”‚       β”‚   β”œβ”€β”€ getAllDevices.js
β”‚       β”‚   β”œβ”€β”€ getAllSensors.js
β”‚       β”‚   β”œβ”€β”€ getCurrentData.js     # Real-time sensor data
β”‚       β”‚   β”œβ”€β”€ getSchedules.js
β”‚       β”‚   β”œβ”€β”€ getNotifications.js
β”‚       β”‚   β”œβ”€β”€ getSystemLogs.js
β”‚       β”‚   β”œβ”€β”€ getMaintenance.js
β”‚       β”‚   └── ... (other get functions)
β”‚       β”œβ”€β”€ insert/                   # POST endpoints for data creation
β”‚       β”‚   β”œβ”€β”€ insertSchedule.js
β”‚       β”‚   └── insertBooking.js
β”‚       β”œβ”€β”€ update/                   # PUT endpoints for data updates
β”‚       β”‚   β”œβ”€β”€ updateDeviceState.js
β”‚       β”‚   └── updateSchedules.js
β”‚       └── delete/                   # DELETE endpoints
β”‚           └── deleteSchedule.js
β”œβ”€β”€ Frontend/                         # React Vite application
β”‚   β”œβ”€β”€ index.html                    # Main HTML template
β”‚   β”œβ”€β”€ indexlogin.html               # Login page
β”‚   β”œβ”€β”€ package.json                  # Frontend dependencies
β”‚   β”œβ”€β”€ vite.config.js                # Vite configuration
β”‚   β”œβ”€β”€ tailwind.config.js            # TailwindCSS configuration
β”‚   └── src/
β”‚       β”œβ”€β”€ main/
β”‚       β”‚   β”œβ”€β”€ App.jsx               # Main app component with routing
β”‚       β”‚   β”œβ”€β”€ main.jsx              # Entry point
β”‚       β”‚   └── index.css             # Global styles
β”‚       β”œβ”€β”€ pages/                    # Page components
β”‚       β”‚   β”œβ”€β”€ DashboardPage.jsx     # Main dashboard
β”‚       β”‚   β”œβ”€β”€ Logs.jsx              # System logs viewer
β”‚       β”‚   β”œβ”€β”€ Notifications.jsx     # Notifications page
β”‚       β”‚   β”œβ”€β”€ Login.jsx             # Login page
β”‚       β”‚   β”œβ”€β”€ RoomComponents/       # Room-related pages
β”‚       β”‚   β”‚   β”œβ”€β”€ SystemOverview.jsx
β”‚       β”‚   β”‚   β”œβ”€β”€ RoomDetails.jsx
β”‚       β”‚   β”‚   └── SensorHistorical.jsx
β”‚       β”‚   └── BookingComponents/    # Booking-related pages
β”‚       β”‚       β”œβ”€β”€ Booking.jsx
β”‚       β”‚       └── MakeBooking.jsx
β”‚       β”œβ”€β”€ components/               # Reusable components
β”‚       β”‚   β”œβ”€β”€ Header.jsx
β”‚       β”‚   β”œβ”€β”€ Sidebar.jsx
β”‚       β”‚   β”œβ”€β”€ Layout.jsx
β”‚       β”‚   └── ProtectedRoute.jsx
β”‚       β”œβ”€β”€ hooks/                    # Custom React hooks
β”‚       β”‚   β”œβ”€β”€ getApiData.jsx        # API data fetching
β”‚       β”‚   β”œβ”€β”€ getDetailData.jsx
β”‚       β”‚   └── useTheme.jsx
β”‚       └── assets/                   # Images and fonts
β”œβ”€β”€ ScheduleJob.sql                   # PostgreSQL scheduled jobs
└── README.md                         # This file

πŸš€ Getting Started

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn
  • Supabase account and project credentials
  • Environment variables configured

Installation

1. Clone the Repository

git clone <repository-url>
cd Smart-Home-Management-System

2. Backend Setup

Navigate to the backend directory and install dependencies:

cd Backend
npm install

Create a .env file in the Backend directory with your Supabase credentials:

PORT=8000
SUPABASE_URL=your_supabase_url
SUPABASE_KEY=your_supabase_key

Start the backend server:

# Development mode with auto-reload
npm run dev

# Production mode
npm start

The backend will run on http://localhost:8000

3. Frontend Setup

Navigate to the frontend directory and install dependencies:

cd Frontend
npm install 

Create a .env.local file in the Frontend directory:

VITE_SUPABASE_URL=your_supabase_url
VITE_SUPABASE_KEY=your_supabase_key
VITE_API_URL=http://localhost:8000

Start the development server:

npm run dev

The frontend will run on http://localhost:5173


πŸ“Š API Endpoints

Data Retrieval (GET)

  • GET / - Welcome message
  • GET /rooms-sensors - Get all rooms with their sensors
  • GET /rooms-devices - Get all rooms with their devices
  • GET /notifications - Get all notifications
  • GET /alerts - Get all alerts
  • GET /schedules - Get all device schedules
  • GET /device/:deviceid - Get specific device details

Updates (PUT)

  • PUT /devices/:id - Update device state
  • PUT /schedules - Update device schedules
  • PUT /schedules/manual/:id - Manually update specific schedule

Creation (POST)

  • POST /schedules - Create new schedule
  • POST /login - User login
  • POST /booking - Create room booking

Deletion (DELETE)

  • DELETE /schedules/:id - Delete schedule

πŸ”„ Automated Processes

The backend includes a cron job that runs every minute to:

  • Check and execute scheduled device operations
  • Update device states based on schedules
  • Monitor sensor readings
  • Generate system alerts

πŸ‘₯ Team Members

Name Role Responsibilities
Do Gia Huy Supporter Database Designer, Full-stack Developer
Huynh Trung Chien Leader Database Designer, Full-stack Developer
Tran Nguyen Khai Nghi Member IoT Engineer
Le Pham Tu Quynh Member Technical Writer

πŸ“ Database Schema

Key tables in the PostgreSQL database:

  • users - User authentication and profiles
  • device - Device information and states
  • sensor - Sensor configurations per device
  • sensorreading - Historical sensor data (temperature, humidity)
  • temphumsensor - Temperature and humidity specific readings
  • notification - System notifications and alerts
  • schedule - Device operation schedules
  • booking - Room booking records
  • systemlog - Audit and system operation logs

πŸ” Security Features

  • User authentication with secure login
  • Protected routes for authenticated users only
  • CORS enabled for secure cross-origin requests
  • Role-based access control
  • Environment variables for sensitive credentials

πŸ“„ License

This project is part of COS20031 - Database Design at Swinburne University.


About

A full-stack Building Management System featuring real-time sensor monitoring, automated device scheduling via Node-cron, and a robust PostgreSQL database for tracking infrastructure and maintenance.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages