Git Product home page Git Product logo

covid-19_alert_microservice_with_spring_boot's Introduction

COVID-19 Alert Microservice with Spring Boot

A Spring Boot microservice to provide alerts based on location.

Current Implementation

The current implementation allows providing a country name, a state name and a specific date. The returned result, will be a measures recommendation based on the current number of new cases in that region.

  • Port: 9090
  • Endpoint: /status/
  • Request: GET
  • Path variables: /{country}/{state}/{YYYY-MM-DD}/

Usage example

http://localhost:9090/status/Germany/Berlin

Data source

The main source API for this implementation will be https://covid19tracking.narrativa.com/index_en.html
Documentation is available at https://documenter.getpostman.com/view/10831675/SzYZ1eNY#9741ae31-6493-4d32-aec3-a272e4bcec67

API use example

https://api.covid19tracking.narrativa.com/api/2020-11-07/country/egypt/region/cairo

Basic Microservice Architecture

img.png

Dependencies

  • Spring boot
  • JSONiJ for parsing json
    • https://bitbucket.org/jmarsden/jsonij/wiki/Home
    • To get the version needed
    • gradle dependencies
      dependencies {
          compile group: 'cc.plural', name: 'jsonij', version: '0.5.2'
          ...
        }
      
    • Basic usage
        import jsonij.Value;
        import jsonij.parser.JSONParser;
        import jsonij.parser.ParserException;
        
        public class json {
            public static void main(String[] arg){
                // Create a new parser object
                JSONParser parser = new JSONParser();
                // Mock a jason response from a REST endpoint
                String JsonResponse = "{\"key\":[{\"imdKey\":55},1,2.3,0.4,-5,-5.92,0.001E1,-0.045E45,987654321], \"key2\":{\"key21\":1,\"key22\":2}}";
                // Parse the response
                Value jsonBody = parser.parse(JsonResponse);
                // Extract a nested value
                Value nestedValue = jsonBody.get("key").get(0).get("imdKey");
                // Type case the response to string
                String stringValue = String.valueOf(jsonBody);
                // Print the values.  Note: you can use/print the value directly.
                System.out.println("The raw response value is " + stringValue + "\nThe nested value extracted is " + nestedValue);
            }
        }

Setup logging

In order to the level correctly, take the path from the root and use . as a separator till you reach the package name.
Levels: TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF .

In the application.yaml file add the following:

logging:
  level:
    com.nexthink.mnt.covidalertservice.service: DEBUG

Aiding materials

This video sires was very helpful while implmenting this. Title: COVID-19 Alert Microservice with Spring Boot https://www.youtube.com/watch?v=g8C0Z-seFEw&feature=youtu.be

Artifact generation

./gradlew clean build

Running the service

java -jar <RepoPath>/build/libs/covidAlertService-0.0.1-SNAPSHOT.jar

covid-19_alert_microservice_with_spring_boot's People

Contributors

abdelrhmanhamouda avatar

Watchers

 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.