Git Product home page Git Product logo

asteroids-poc's Introduction

This is a tool which provides data on nearby asteroids using NASA Asteroids API

Technology Stack

  • Java 8
  • Spring Boot
  • Maven

Design Considerations

Though this is only a PoC, here are some considerations for an MVP and further development:

  • DB persistence: not necessary at the moment until there is a feature which requires it
  • API Design: For an MVP the API-first mindset should be embraced from the very beginning, which means designing a good API which can scale and then coding the backend. Furthermore, an API Gateway / micro-gateway should be considered as soon as the development gets more ambitious
  • Docker generally solves the "it works / doesn't work on my local environment" issue among other benefits. It also promotes a much more streamlined testing / release / deployment strategy. Developers would definitely benefit from this approach
  • Testing: Automated testing must be implemented towards both front-facing and back-end facing APIs, mocking can be used for early unit testing. Regression and black-box testing should be easy to execute with a streamlined CI / CD strategy. For production use it is also recommended to run performance, volume, stress testing as well as eventually backup/recovery and even canary testing if the system becomes mission critical

Features

  • closestAsteroids: Shows 10 asteroids that passed the closest to Earth between two user-provided dates
  • largestAsteroid: Shows characteristics of the largest asteroid (estimated diameter) passing Earth during a user-provided year

Development

  • The original development was done using IntelliJ IDEA 2022.2.1 (Ultimate Edition), but any Java-compatible IDE will do.
  • This is basically a Spring Boot web application created by using Spring Initializr
  • APIs are published and consumed by leveraging the RestTemplate built-in class
  • No 3rd party dependencies are currently being used
  • Basic response caching has been enabled and added by annotating methods to use the built-in Spring Boot Starter Cache
  • Some further development suggestions:
    • Add error handling
    • Use of developer API key instead of DEMO_KEY
    • Create generic handler for API calls to reduce code
    • Externalize configuration
    • Add more robust caching solution such as Redis, Couchbase, etc.

Usage

Running the application

The application can be started both from an IDE of your choice or from the command line:

./mvnw spring-boot:run

You can also package and run it using a docker container:

./mvnw package
docker build -t springio/gs-spring-boot-docker .
docker run -p 8080:8080 springio/gs-spring-boot-docker

Retrieving Data

The following 2 endpoints are available:

http://<host>:<port>/closestAsteroids.json?startDate=<startDate>&endDate=<endDate>
http://<host>:<port>/largestAsteroid.json?year=<year>

Considerations:

  • Response is a JSON document
  • Date format is always: YYYY-MM-DD
  • The NASA API has a hard limit of 7 days for retrieving data from it
  • This PoC uses the DEMO_KEY to retrieve data, for further use you need to replace this with a NASA developer key

CI / CD

This repo includes GitHub Actions configuration for deploying to Heroku Cloud. This will happen automatically when merging into master.
Sample endpoints:

https://young-wave-56035.herokuapp.com/closestAsteroids.json?startDate=2016-09-07&endDate=2016-09-10
https://young-wave-56035.herokuapp.com/largestAsteroid.json?year=2003.

asteroids-poc's People

Contributors

gugalnikov avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.