The Smart Home Management System is a microservices-based application designed to control and monitor various smart devices in a home environment. This system provides a scalable and flexible architecture for managing smart home devices, user accounts, and device states.
- Architecture
- Services
- Technologies Used
- Project Structure
- Getting Started
- Development
- Testing
- Deployment
- Contributing
- License
The Smart Home Management System follows a microservices architecture, with the following key components:
┌─────────────────┐
│ API Gateway │
└─────────────────┘
│
┌─────────────────┼─────────────────┐
│ │ │
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ Device Service │ │ User Service │ │ Other Services │
└──────────────────┘ └──────────────────┘ └──────────────────┘
│ │ │
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ MongoDB | │ PostgreSQL │ │ Other Databases │
└──────────────────┘ └──────────────────┘ └──────────────────┘
- API Gateway: Routes requests to appropriate microservices.
- Device Service: Manages smart home devices, their states, and operations.
- User Service: Handles user authentication, authorization, and profile management.
- Other Services: Placeholder for future services (e.g., Automation Service, Notification Service).
- Databases: Each service can have it's own database.
The Device Service is responsible for managing smart home devices. It provides the following functionalities:
- Create, read, update, and delete devices
- Manage device states
- List devices for a user
- Implement CQRS pattern with separate read and write models
The User Service handles user-related operations, including:
- User registration and authentication
- User profile management
- Authorization and access control
- Go: Primary programming language
- gRPC: For inter-service communication
- Protocol Buffers: For defining service contracts
- Docker: For containerization
- Kubernetes: For orchestration and deployment
- PostgreSQL: Relational database for User Service
- MongoDB: NoSQL database for Device Service
- Makefile: For automating build, test, and deployment tasks
- GitHub Actions: For CI/CD pipelines
smart-home-system/
├── cmd/
│ ├── device-service/
│ └── user-service/
├── internal/
│ ├── device/
│ └── user/
├── pkg/
│ ├── models/
│ └── proto/
├── deployments/
│ ├── docker-compose.yml
│ └── kubernetes/
├── build/
│ ├── Dockerfile.device
│ └── Dockerfile.user
├── .github/workflows/
├── Makefile
├── go.mod
└── README.md
To get started with the Smart Home Management System:
-
Clone the repository:
git clone https://github.com/yourusername/smart-home-system.git -
Install dependencies:
make deps -
Build the services:
make build -
Run the services locally:
make run-device make run-user
To develop new features or fix bugs:
-
Create a new branch:
git checkout -b feature/your-feature-name -
Make your changes and write tests.
-
Run tests:
make test -
Run integration tests:
make integration-test-all -
Submit a pull request for review.
- Run unit tests:
make test - Run integration tests:
make integration-test-all - Generate coverage report:
make coverage
To deploy the Smart Home Management System:
-
Build Docker images:
make docker-build-all -
Push Docker images:
make docker-push-all -
Deploy to Kubernetes:
make k8s-deploy-all
This project is licensed under the MIT License - see the LICENSE file for details.