A full-stack IoT home automation system that enables real-time monitoring and control of smart home devices through a web interface, WebSocket communication, and Telegram bot integration.
Modern, responsive dashboard for controlling smart home devices with real-time sensor data
Live sensor data streaming via WebSocket - temperature, humidity, gas, flame, and motion detection
Automated Telegram alerts for critical events and remote control capabilities
RESTful API handling alerts and device commands
Arduino/ESP32 firmware for sensor integration and WebSocket communication
- Real-time Device Control: Control smart home devices instantly via WebSocket connections
- Multi-Room Management: Organize and manage devices across different rooms
- Sensor Data Logging: Track and store sensor readings (temperature, humidity, motion, etc.)
- User Authentication: Secure login system with bcrypt password hashing
- Telegram Bot Integration: Control your home remotely through Telegram commands
- RESTful API: Comprehensive API for device management and data retrieval
- WebSocket Server: Bi-directional real-time communication on port 8080
- Express Backend: Robust REST API with proper middleware architecture
- Database ORM: Sequelize for database operations and migrations
- CORS Enabled: Configured for both local development and production deployment
- Responsive Dashboard: Clean web interface for device monitoring and control
MySmartHome/
βββ config/ # Database configuration
βββ controllers/ # Business logic handlers
βββ models/ # Sequelize database models
βββ routes/ # API route definitions
βββ middleware/ # Custom middleware functions
βββ public/ # Frontend static files
β βββ css/ # Stylesheets
β βββ js/ # Client-side JavaScript
β βββ images/ # UI assets
βββ scripts/ # Utility scripts
βββ __tests__/ # Jest test suites
βββ server.js # Main application entry point
- Node.js (v14 or higher)
- npm or yarn
- SQLite (or your preferred SQL database)
- Clone the repository
git clone https://github.com/adhamNemr/MySmartHome.git
cd MySmartHome- Install dependencies
npm install- Configure environment variables
cp .env.example .env
# Edit .env with your configuration- Initialize the database
node createUser.js # Create initial admin user- Start the server
npm startThe application will be available at:
- Web Interface: http://localhost:3000
- WebSocket Server: ws://localhost:8080
POST /api/login- User authentication
GET /api/devices- List all devicesPOST /api/devices- Create new devicePUT /api/devices/:id- Update deviceDELETE /api/devices/:id- Remove device
GET /api/rooms- List all roomsPOST /api/rooms- Create new room
GET /api/sensors-data- Retrieve sensor readingsPOST /log-sensor- Log new sensor data
GET /api/logs- Fetch system logs
POST /api/commands- Send device commands
Run the test suite:
npm testThe application is configured for deployment on platforms like:
- Vercel (Optimized for frontend deployment)
- Railway / Render (Backend)
- Heroku
CORS is pre-configured for production deployment.
- Password hashing with bcrypt
- JWT-ready architecture
- Environment variable protection
- CORS configuration
- Input validation middleware
The system uses the following main models:
- User: Authentication and user management
- Device: Smart device information
- Room: Room organization
- SensorLog: Historical sensor data
- Command: Device command history
Control your smart home via Telegram bot commands. Configure your bot token in the .env file.
Backend:
- Node.js & Express.js
- WebSocket (ws library)
- Sequelize ORM
- bcrypt for password hashing
- JWT for authentication
Frontend:
- Vanilla JavaScript
- HTML5 & CSS3
- WebSocket client
Testing:
- Jest
Create a .env file with the following variables:
# Database
DATABASE_URL=your_database_url
# JWT Secret
JWT_SECRET=your_jwt_secret
# Telegram Bot
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
# Server Configuration
PORT=3000
WEBSOCKET_PORT=8080Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the ISC License.
Adham Nemr
- GitHub: @adhamNemr
- LinkedIn: Adham Nemr
Built as a comprehensive IoT solution demonstrating full-stack development skills, real-time communication, and modern web technologies.
β If you find this project useful, please consider giving it a star on GitHub!