Skip to content

christopherkochaneck/smarthome

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

384 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Security Rating Maintainability Rating Bugs Code Smells Vulnerabilities Vulnerabilities Vulnerabilities

Smarthome

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.

Features

  • 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

Technologies Used

Getting Started

  1. Clone this repository

    $ git clone https://github.com/christopherkochaneck/smarthome.git
  2. Install the dependencies

    Using npm

    $ cd client
    $ npm i
    $ cd ..
    $ cd server
    $ npm i

    Using yarn

    $ cd client
    $ yarn
    $ cd ..
    $ cd server
    $ yarn
  3. Set the environment variables

    For Development
    The client directory, aswell as the server directory each have a .env.sample included, which is a template so you know which environment variables you need to set.

    For Production
    The docker-compose.example.yml is an example how your docker-compose could look like. To set envirmoment varibles for Production, I would recommend making use of the environment tag.

  4. Launch up the backend and the frontend. You can do that using npm or yarn.

    Using npm

    $ cd client
    $ npm run dev
    $ cd server
    $ npm run dev

    Using yarn

    $ cd client
    $ yarn dev
    $ cd server
    $ yarn dev
  5. Check the functionality

    Open http://localhost:3000 in 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.

Testing

This project includes jest tests to test the endpoints of the project. You can simply run the tests by running

$ npm run test

or

$ yarn test

An instance of Sonarqube is also running for this project to improve code quality.

Deployment

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.

  1. Set the Environment Valiables in the docker-compose.yml

    Take a look at the docker.example.yml. This should give you an idea which variables you need to set.
  2. Launch the containers

    In order to launch the cotainers, use docker-compose up --build in the root directory of the project to start the containers. If everything is setup correctly
  3. Check if the project is running

    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

FAQ

1. Why should I use a self-hosted option instead of a cloud solution?

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.

Licensing

I am using the folowing resources that I do NOT own (Click to get to the Link):

Smarthome Icon: Intelligentes-zuhause

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages