Carbon Dioxide (CO2) is all around us and we are constantly expelling it, but in high concentration CO2 can be harmful or even lethal.CO2 Levels between 2000 and 5000 ppm are associated with headaches, sleepiness poor concentration, loss of attention, increased heart rate and slight nausea may also be present.
- The service should be able to receive measurements from each sensor at the rate of 1 per minute
- If the CO2 level exceeds 2000 ppm the sensor status should be set WARN
- If the service receives 3 or more consecutive measurements higher than 2000 the sensor status should be set to ALERT
- When the sensor reaches to status ALERT an alert should be stored
- If the service receives 3 or more consecutive measurements lower than 2000 the sensor status should be set to OK
- The service should provide the following metrics about each sensor
- Average CO2 level for the last 30 days
- Maximum CO2 Level in the last 30 days • It is possible to list all the alerts for a given sensor
- Collect sensor mesurements
POST /api/v1/sensors/{uuid}/mesurements
{
"co2" : 2000,
"time" : "2019-02-01T18:55:47+00:00"
}
- Sensor status
GET /api/v1/sensors/{uuid}
Response:
{
"status" : "OK" // Possible status OK,WARN,ALERT
}
- Sensor metrics
GET /api/v1/sensors/{uuid}/metrics
Response:
{
"maxLast30Days" : 1200,
"avgLast30Days" : 900
}
- Listing alerts
GET /api/v1/sensors/{uuid}/alerts
Response:
[
{
"startTime" : "2019-02-02T18:55:47+00:00",
"endTime" : "2019-02-02T20:00:47+00:00",
"mesurement1" : 2100,
"mesurement2" : 2200,
"mesurement3" : 2100,
}
]
The CO2-Sensor-API is an API that enables TODO
What things you need to install the software and how to install them?
This project requires you to pre-install the following tools:
- Apache Maven 3.5.2
- Java JDK 1.8
- Docker and Docker Compose
- Postgres
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
mvn install
Since the application uses Maven, running test is as easy as running one line command.
The unit tests in this project will test the consumer, producer and the implementation of the business layer (service). To run these tests you can run the following command
mvn test
The E2E tests in this project will test whole API endpoints to ensure quality criteria are met defined by API design. To run these tests you can run the following command
mvn verify
For running it locally, run following command in directory where docker-compose.yml
file is located in order to provide runtime dependencies required for CO2 Sensor API.
docker-compose up
run docker-compose up -d
This will start you an instance of PostgreSQL Database
After running Docker, run the spring boot application by the following command
mvn spring-boot:run
After running CO2 Sensor API, a swagger file is locally available at {{url}}/swagger-ui.html
and should be fully usable as a rest client.