What is PHrest?

PHrest is a REST API that retrieves Ph data from a PostgreSQL database. It is a data source that PHreader retrieves from the Raspberry Pi circuit and stores.

This post will not delve into technical details, as the API itself is constructed using the Node.js+ExpressJS REST API boilerplate/framework, which I have previously documented here.

What is the stack behind PHrest?

  • Kubernetes (infrastructure)
  • Postgresql (db)
  • Node.js + ExpressJS (application)

What endpoints are available?

GET

/api/v1/stats/ph/avg
/api/v1/stats/ph/latest
/api/v1/stats/ph/max
/api/v1/stats/ph/min
/api/v1/stats/:year/ph
/api/v1/stats/:year/:month/:day/ph
/api/v1/stats/ph/:id
/api/v1/stats/ph

The endpoints are utilized to retrieve the Ph statistics data. They adhere to the REST methodology, which is user-friendly and intuitive. All endpoints return a JSON payload, as specified in the following example:

{
  "status": 1,
  <data>
}

For example:

/api/v1/stats/ph/avg, will return a JSON payload with the Average Ph value.

{
  "status": 1,
  "avg": 8.42286562125667
}

/api/v1/stats/ph/latest will return a JSON payload with the latest recorded Ph value.

{
  "status": 1,
  "latest": 7.699
}

The primary objective of the API is to integrate with the data store (PostgreSQL) to facilitate data access. Consequently, a caller can present the information in a user-friendly manner, such as through graphing and monitoring capabilities.

Next was to build a UI that could display dashboards and make use of information to monitor the hot tubs Ph levels. This is where PHreader-UI comes in.