Giter Site home page Giter Site logo

zhrgns / weatherapispringboot Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 186 KB

The Weather API allows users to search for the current weather report of a city by its name. Api consumes an open source api for data resource

Dockerfile 1.59% Java 98.41%
docker docker-compose grafana h2-database intellij-idea java lombok maven open-api prometheus restful-api spring-boot spring-cache springdata-jpa swagger-ui

weatherapispringboot's Introduction

Weather Service Application

General Info:

Architecture

  • The Weather API allows users to search for the current weather report of a city by its name. The request is made to /weather/{city} URL with {city} as the path variable.

  • The city parameter is validated to ensure it is not blank or a decimal value. If it is invalid, a 400 - Http Bad Request response is returned.

  • The API gets the current weather from either the database or consumes the WeatherStack API using an API key.

    • If the latest data is not older than 30 minutes, it is retrieved from the database.
    • If the data is older than 30 minutes or does not exist in the database, a request is made to the WeatherStack API, and the result is cached. If there is a cached value with the city filter as the key, the response is returned from the cache directly.
  • If there is too many request for api in 10 sec, a 429 Too Many Request response is returned.

  • For usages, weather Stack Api_Key should be defined in the application.yml file or an .env file .

  • The API endpoint can be found on the Swagger page at http://localhost:8080/swagger-ui/index.html.

Technology


  • Java 17
  • Spring Boot 3.0
  • H2 In Memory Database
  • Spring Data JPA
  • Spring Cache
  • Lombok
  • Restful API
  • Maven
  • Docker, Docker Compose
  • Prometheus, Grafana
  • Open API Documentation
  • IntelliJ IDEA

Prerequisites


  • Maven or Docker

Docker Run


This application can be built and run using Docker. The Dockerfile has a multistage build, so building and running can be done in one step.

$ cd weatherapp
$ docker-compose up -d

Docker compose creates 3 replicas (instances) of the application on port range 9595-9597

For open-api-ui: http://localhost:{9595-9597}/swagger-ui.html

For Prometheus: http://localhost:9090

For Grafana: http://localhost:3000

USER, PASSWORD=admin

Maven Run


To build and run the app with Maven:

$ cd weatherapp
$ mvn clean install
$ mvn spring-boot:run

weatherapispringboot's People

Contributors

zhrgns 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.