A self-hosted, web-based solution for controlling Shelly IoT devices using Next.js, TypeScript, and Express.js, as well as MongoDB for data storage and Docker for containerization.
- Authorization and Authentication using NextAuth.js
- Control Shelly IoT devices using their HTTP API
- Real-time updates on device status and data
- User-friendly interface for controlling devices
- Data storage with MongoDB
- Containerized using Docker
- Integration Testion using jest.js
- Runtime: Node.js
- Language: TypeScript
- Frontend: Next.js
- Backend: Express.js
- Testing: Jest.js, Sonarqube
- Datbase: MongoDB
- Containerization: Docker
-
$ git clone https://github.com/christopherkochaneck/smarthome.git
-
Using npm
$ cd client $ npm i $ cd .. $ cd server $ npm i
Using yarn
$ cd client $ yarn $ cd .. $ cd server $ yarn
-
For Development
The client directory, aswell as the server directory each have a.env.sampleincluded, which is a template so you know which environment variables you need to set.For Production
Thedocker-compose.example.ymlis an example how your docker-compose could look like. To set envirmoment varibles for Production, I would recommend making use of the environment tag. -
Using npm
$ cd client $ npm run dev $ cd server $ npm run dev
Using yarn
$ cd client $ yarn dev $ cd server $ yarn dev
-
Open
http://localhost:3000in your browser. If you set up the Project correctly, you should be able to reach the frontend. If not, the console will most likely print you a stacktrace, which error happend and where.
This project includes jest tests to test the endpoints of the project. You can simply run the tests by running
$ npm run testor
$ yarn testAn instance of Sonarqube is also running for this project to improve code quality.
The project uses Docker to launch seperate containers for the frontend, backend and database. This should make it easy to deploy and update the Containers seperately.
-
Take a look at the
docker.example.yml. This should give you an idea which variables you need to set. -
In order to launch the cotainers, use
docker-compose up --buildin the root directory of the project to start the containers. If everything is setup correctly -
Try to connect to the IP Adress where you deployed the project.
If you haven't setup any custom Routing using e.g. traefik, you should be able to connect to the Smarthome with the Server IP, following the port (Default: 3000).
Example with a randomized ip:http://209.191.162.183:3000
Actually, it's quite simple: data protection. Whereas with a cloud solution you never know exactly what happens to your data, with a self-hosted cloud solution all the data is where you can manage and oversee it yourself without any problems.
I am using the folowing resources that I do NOT own (Click to get to the Link):
Smarthome Icon: Intelligentes-zuhause