This project consists of microservices that simulate an IoT device sending telemetry data (temperature and humidity) to a message queue (RabbitMQ). The data is then consumed, stored in Redis, and exposed via a REST API.
- Node.js v22
- Docker & Docker Compose
Run the following command to start the services:
docker compose up -dThis will start RabbitMQ, Redis, the producer (IoT simulator), consumer, and API services.
Retrieves telemetry data from Redis with optional filtering parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
startDate |
number (optional) | Start timestamp (milliseconds) | 1742391170007 |
endDate |
number (optional) | End timestamp (milliseconds) | 1742391200010 |
sortDir |
ASC / DESC (optional) |
Sorting order | DESC |
limit |
number (optional) | Maximum results per page | 10 |
page |
number (optional) | Page number | 1 |
curl "http://localhost:5001/telemetry/?startDate=1742391170007&endDate=1742391200010"{
"total": 4,
"documents": [
{
"id": "telemetry:fb0eebf3-22ef-4028-9c53-e26670bfa880:1742391200010",
"value": {
"timestamp": "1742391200010",
"deviceId": "fb0eebf3-22ef-4028-9c53-e26670bfa880",
"temperature": "20.45",
"humidity": "41.68"
}
},
{
"id": "telemetry:5bb8c510-0903-48dc-859a-c03c09f3ecde:1742391190011",
"value": {
"timestamp": "1742391190011",
"deviceId": "5bb8c510-0903-48dc-859a-c03c09f3ecde",
"temperature": "23.57",
"humidity": "51.97"
}
},
{
"id": "telemetry:f210e7f7-0995-4156-a87d-c44ae79e40cd:1742391180004",
"value": {
"timestamp": "1742391180004",
"deviceId": "f210e7f7-0995-4156-a87d-c44ae79e40cd",
"temperature": "21.94",
"humidity": "39.95"
}
},
{
"id": "telemetry:ff1ba59a-4bbd-408c-ada7-2ac32632ea37:1742391170007",
"value": {
"timestamp": "1742391170007",
"deviceId": "ff1ba59a-4bbd-408c-ada7-2ac32632ea37",
"temperature": "23.69",
"humidity": "38.2"
}
}
]
}- Redis is used as a caching layer to store telemetry data.
- Data is retrieved using @redis/search to efficiently filter by timestamp.
- RabbitMQ is used for message passing between microservices.
- Pagination support ensures optimized data retrieval.
To run unit test:
npm run testTo run integration test
- run test docker container
docker-compose -f docker-compose.test.yml up -d- run tests
npm run test:e2e