This microservice is designed to validate the ages of machines in a manufacturing company's inventory system. It identifies machines with unreasonably long ages by comparing them against other machines in the submitted list using IQR algorithm.
Make sure Go is installed
-
Clone the repository:
git clone https://github.com/katerina20/machine-age-validator
-
Navigate to the project directory:
cd machine-age-validator
-
Install dependencies:
go mod download
-
Start the service:
go run main.go
The service will be available at http://localhost:8080
.
To use the microservice, send a POST request to /validate
with a JSON body containing a list of machine IDs and their corresponding age strings.
For age can be use: days, weeks, months and years.
Example request:
[{"id": "machine1", "age": "1 year"}, {"id": "machine2", "age": "200 days"}, {"id": "machine3", "age": "90 years"}, {"id": "machine4", "age": "12 month"}, {"id": "machine5", "age": "300 days"}, {"id": "machine6", "age": "3 month"}]
Example response:
{"id": "machine3", "age": "90 years"}
- Improve detection algorithm to use with any data size (even with small dataset).
- Save coefficient in the db for more exact result.
- Add more test cases to be sure the results are expected.
- Create API documentation for endpoints, data formats, and usage examples.
- Implement security to use within the organization.