gustavorodarte / weather-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Genome Code Challenge

Description

Application that display the weather information for any given city made with Python's FastAPI framework inspired in Clean Architecture and DDD principles.

Overview

This project is comprised of the following languages and libraries:

Auxiliary libraries were omitted but can be found in the pyproject file.

Setup

Change in the environment variable OPEN_WEATHER_MAP_API_TOKEN on docker-compose file.

Running

  • Start a container with: docker-compose run --rm --service-ports app ash
  • Inside the container run: poetry install
  • Start the web server with: poetry run web_server
  • The app will be running on http://0.0.0.0:8000

Using the APP

Testing

  • Start a container with: docker-compose run --rm --service-ports tests ash
  • Inside the container run: poetry install
  • Test the API with: pytest

Linting and static check

  • Test the API with: pytest
  • Check code style with: black --check weather
  • Format code with: black weather tests
  • Lint the code with: flake8 weather tests
  • Run static analysis with: mypy weather tests

Knowing Issues

  • The Feature Test isn't passing fully, I had a problem to mock the lib request_async, so when running the feature test the request to Open Weather Map is made.

To Improve

  • The API should be capable to receive a geolocation and return the weather conditions, at the moment only city names are available.
  • Cache the fetched weather data, unfortunately, I don't have time to implement the request cache, my original plan was implementing a Redis to cache the API data.
  • Types: some functions and variables not has types.

About

License:MIT License


Languages

Language:Python 96.6%Language:Dockerfile 3.4%