Skip to content

GuilhermeLessa/weather-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# Running backend containers

       On /api directory, run these commands on CLI:

              docker-compose build
              docker-compose up
              docker exec weather-php composer install
              docker exec weather-php php artisan migrate
              docker exec weather-php php artisan db:seed



# Running frontend container

       On /web directory, run these commands on CLI:

              docker-compose build
              docker-compose up



# Ready to go

       That's all you need to access the application on browser: http://localhost:5173.
       Users to login and test:

              email:        [email protected]
              password:     123456

              email:        [email protected]
              password:     123456



# Reeinstall if its necessary

       If something gets wrong you must clean all to try reinstall:

              docker-compose down
              docker volume rm api_weather-volume



# Running automated tests

       Take a look on test coverage results in /test-coverage-result/index.html.

       After run up the backend containers, run this command on CLI:

              docker exec weather-php php artisan test
              docker exec weather-php php artisan test --coverage-html=test-coverage-result
       
       Know that tests will erase all database, to recover state just run seeds again:

              docker exec weather-php php artisan db:seed



# Testing enpoints with postman

       Theres complete postman collections on folder /postman, you can import. 



# TODO improvements:

       BACK:
       Improve test cases with mock and fakes
       Manage api version endpoints (exe: /api/v1)
       Icons size as parameter
       Metrical units as a parameter (units=metric) https://openweathermap.org/current#data
       Record log of errors on database
       Enable test coverage stats: php artisan test --coverage
       Improve exceptions controll on weather api side (401, invalid key, etc)
       Create isolated tests of weather api and check types (pure gets without adapters)
       Set test cases order (weather response > api > forecast)
       Preserve type temperatures as decimal
       Improve validators on test cases (exe required, etc)
       Ignore case when find for city/country on database (lowercase)
       Add laravel validator on weather response transformer (malformed data)
       Use assertCount instead of count on test cases

       FRONT:
       Build a static website server instead of launch dev instance
       Separate a main view to auth routes and include general components (logout button/container)
       Implement stateless data, only reach backend if clicks on refresh button
       Redirect not found urls typed on browser bar
       Remove seconds of time format on view
       Improve return types, either and error controlling of weather api adapter
       Keep the same height all forecast cards when icon demands less high


































































--------------------------------------------------------

# Useful instructions

       How to install docker on linux:

              https://docs.docker.com/engine/install/ubuntu/

      
       How to attach on container bash:

              docker exec -it weather-php bash

       How run test cases:

              docker exec weather-php php artisan test

              docker exec weather-php php artisan test --coverage-html=coverage


       Steps to install laravel sanctum:

              docker exec weather-php composer create-project laravel/laravel .

              docker exec weather-php php artisan install:api

              docker exec weather-php composer update

              docker exec weather-php php artisan migrate

              docker exec weather-php php artisan db:seed


       How manipulate resources on laravel:

              docker exec weather-php php artisan make:controller WeatherController

              docker exec weather-php php artisan make:migration create_forecast_table

              docker exec weather-php php artisan make:model Forecast

              docker exec weather-php php artisan migrate:rollback --step=1

              docker exec weather-php php artisan migrate:reset