Skip to content

Simple microservice to collect field data, store and generate a simple report

Notifications You must be signed in to change notification settings

danielpsf/fields-statistics

Repository files navigation

Field statistics

Build Status Codacy Badge codecov

This is a simple microservice to collect and retrieve field statistics using Spring Boot and Maria DB running on Docker.

Development environment tools

Start development

Running locally

  1. Execute chmod +x run-local.sh
  2. Execute ./run-local.sh
    • Execute tests
    • Build the Java project
    • Execute docker-compose up

Try some requests

  • Add some entries
curl -X POST http://localhost:8080/field-statistics -d '{
    "vegetation": 0.98,
    "occurrenceAt": "2019-04-23T19:40Z"
}'
  • Retrieve the statistics

Assuming you have Python installed, if you don't just get rid of everything from the | until the end

$ curl -X GET http://localhost:8080/field-statistics | python -m json.tool
   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                  Dload  Upload   Total   Spent    Left  Speed
 100    70    0    70    0     0   5276      0 --:--:-- --:--:-- --:--:--  5384
 {
     "vegetationResponse": {
         "min": 0.98,
         "max": 0.99,
         "avg": 0.985
     }
 }

Interesting readings and decision points

TODO

  • Implement statistics collect endpoint
    • Create the endpoint
    • Save the entry into database
    • Implement bean validation (check with the PO what are the possible entries that I could expect in here and extrapolate)
  • Implement statistics retrieve endpoint
    • Create the endpoint
    • Retrieve statistics from database
  • Implement default exception handling
  • Implement logging
  • Add unit testing (Not feeling like TDD today. 😅)
  • Add Lombok
  • Upgrade to Java 11

Open questions

  • Check with the PO how big does the decimal report must be
  • Check with the PO what should be returned when no data has been saved if null isn't an acceptable return value

Extra mile:

  • Make the occurrenceAt parameter customizable preserving the default to 30 days
  • Add Travis CI pipeline to build and test
  • Implement integration tests
  • Implement performance tests using artillery.io
  • Add Spring FOX support
  • Optimize docker-compose to limit memory and cpu
  • Try to optimize JPA Query to use interface projection instead of class projection

Improvements to discuss with PO

  • Split report from data collection to make it RESTfull

About

Simple microservice to collect field data, store and generate a simple report

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published