For a list of dependencies see the package.json file. The most important
libraries are:
| name | description |
|---|---|
| Hapi | A nicer API that's focused on configurability |
| Nes | A Hapi wrapper for interacting with web sockets |
See Nes' protocol documentation for more information on allowed values in sender/receivers.
- Add payload validation
- Add error logging
- Add query sanitization
- Handle opening and closing connection pool
- Add a load balancer
- Create a file called
env.jsonand populate it with your database credentials, for example:
{
"PGHOST": "127.0.0.1",
"PGPORT": 5432,
"PGUSER": "postgres",
"PGPASSWORD": "",
"PGDATABASE": "tutorial"
}Note: You'll need to have postgres running locally, see the database repo for more instructions.
yarn global add nodemon # install nodemon, optional
yarn [npm install] # install dependencies
yarn dev # runs nodemon (process monitor)
[yarn start] # start server (without nodemon)- API receives an HTTP PUT request from client
- Server does two things after authenticating:
- Publishes an event with that value to all subscribed clients
- Pushes the value TimescaleDB
- The dashboard receives published event and updates the view
- Historical data is displayed by asking API for a view from the database
β β β β β β β β β β β β β ββββββββββββββββββββββββββ
API Server ββββββββββΆβ Client (Dashboard) β
β β ββββββββββββββββββββββββββ
βββββββββββββββββββββββ
ββ WebSocket API βββββββ
βββββββββββββββββββββββ β
β β β ββββββββββββββββββββββββββββββββββββ
β β β β β β ββ²β β β β β βββββββ Client/Server (BeagleBone) β
β β βββββββββ²βββββββββββββββββββ²ββββββββ
β β β β
β β β β
β β β β
β β βββββββββββββ βββββββββββββ
β β β pH Sensor β βTemperatureβ
β β βββββββββββββ βββββββββββββ
β β
βββββββββββΌββ΄ββββββββ
βTimeseries Databaseβ
β β
βββββββββββββββββββββ
- A new sensor can be registered
- JSON records can be received over HTTP
- Messages are pushed to Postgres/Timescale
- Messages can be retrieved from database by sensor/owner
- Historical data can be retrieved for a particular sensor
- Users of the web/native client can view graphs of historical data
- Sensors/Clients/MC's can connect securely over a websocket
- Clients can subscribe to particular sensors and receive live updates
- Users of the web/native client can view graphs of live-updating data
- Create a GraphQL API endpoint
- Add notifications / alerts
Client {
id
name
lat
lon
}
Sensor {
id
owner (id in Client)
type ['temp' | 'humidity' | 'pH' | '']
}
Record {
sensor_id (id in Sensor)
time
value
}