This application uses a 3rd party weather API to display tabulated weather forecasts in an interactive React website, and automatically generate weather reports.
- Technologies
- Console Commands
- Requirements
- Setup & Installation
- Job System
- Assumptions
- Design Decisions
- Improvements
- Demonstration
The following commands can be used in the console to perform actions:
COMMAND | USAGE | DESCRIPTION |
---|---|---|
forecast {cities} | php artisan forecast {cities} | Get weather forcast for the specified city or cities |
city:add {city} | php artisan city:add {city} | Add a reported city. Reported cities are included in daily automatic reporting. |
city:remove {city} | php artisan city:remove {city} | Remove a reported city. Reported cities are included in daily automatic reporting. |
city:list | php artisan city:list | List reported cities. Reported cities are included in daily automatic reporting. |
- Node.JS
- PHP
- Composer
- Clone the repository onto your machine.
- Create a MySQL database schema on your machine for the project. Keep the details handy.
- Sign up to WeatherBit and get a free tier API key.
- Complete the following steps within the
/src/
folder of the cloned repository. - Copy the contents of
.env.example
to.env
and configure the database values and add your WeatherBit api key. - Install composer packages with
composer install
- Install NPM packages using
npm install
- Generate the Laravel application key using
php artisan key:generate
. - Run database migrations using
php artisan migrate:fresh
. - Start the development server using
npm run dev
. - In another terminal, serve the web application with
php artisan serve
. - Access and interact with the website using the url.
For daily automated weather forecasts, there is a DailyReportJob
which runs daily. Follow the instructions below to get this running:
- Complete the following steps within the
/src/
folder of the cloned repository. - Start the queue worker with
php artisan queue:work
. - In another terminal, start the scheduler with
php artisan schedule:work
.
- Commands are required to specifiy which cities are included in daily reports.
- A daily report is just a
Report
record in the database that has manyDayForecast
records. - Daily reports do not need to be accessible by end users.
- WeatherBit API was chosen as it offers a generous free tier, and has a suitable endpoint for interpretable weather forecasting.
- DaisyUI was chosen as a TailwindCSS component library for the project to save time developing a simple frontend.
- A spinner displays when loading data so the user has knowledge that their request is being served.
- ReactJS was used for the frontend. A limited amount of components were created so the project didn't become unnecessarily complicated.
- A class
WeatherBitApi
was created to interact with the WeatherBit API. This was done so functionality can be expanded in future should the need arise. - An environment variable
WEATHERBIT_API_KEY
was added to the.env
file, because it's a good idea to keep keys out of version control ;).
- Add improved error handling.
- Remove unused models and migrations provided by Laravel.
- Add response body to unsuccessful API requests.
- Support city names that contain a space in the console commands i.e. "Gold Coast"
- Add check to see if city is actually a city, instead of regex.