ljodal / plant-monitor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Plant monitor

A web based API to collect and aggregate metrics from plants

Running with docker-compose

Build the containers:

docker-compose build --pull

Run migrations:

docker-compose run --rm web rake sequel:migrate

Create a user:

docker-compose run --rm web ./shell
u = User.new(email: 'admin')
u.set_password('secret')
u.save()

Start the service

docker-compose up

Everything should now be available on port 5000 on your machine.

Requirements

  • Ruby >= 2.0.0
  • Docker

How to run

Install dependencies

gem install bundler
bundle install

Start the database

docker run -p 0.0.0.0:5432:5432 --rm pipelinedb/pipelinedb

Run migrations

bundle exec rake sequel:migrate

Create a user

bundle exec ./shell
u = User.new(email: 'admin')
u.set_password('secret')
u.save()

Start the server application

bundle exec ruby server.rb

How to use

To add some data, PUT against /api/metrics. This accepts json like this:

[
    {
        "id": 1,
        "type": "temp",
        "value": 20
    },
    {
        "id": 1,
        "type": "moisture",
        "value": 200
    }
]

If you save this JSON to a file called metrics.json, you can submit these metrics using curl:

curl -X PUT -u admin:secret -d @- http://localhost:4567/api/metrics < metrics.json

and retrieve the result using curl

curl -u admin:secret http://localhost:4567/api/temperature/1

TODO

  • Frontend

About


Languages

Language:Ruby 81.1%Language:Python 15.7%Language:Dockerfile 3.2%