WinnipegCast is an application for visualizing the historical forecasts of the weather conditions in Winnipeg, Manitoba.
The application is split into three main parts:
- An Angular client interface that queries a RESTful API backend server by date and displays the data that returns from the server call.
- A Node/Express server which connects to a PostgreSQL database and services the client-side requests.
- A PostgreSQL database that stores the weather forecasts.
-
Node.js comes prepackaged with a Node Package Manager (NPM) client which is used to install required modules and dependencies for the application.
-
Express is a lightweight Node.js web application framework for building web and mobile applications.
-
Sequelize is an ORM for SQL databases.
-
Dotenv is a module that loads environment variables from a .env file into a local or cloud environment.
-
Multer is a middleware for handling forms and multi-part data.
-
Nodemon is a tool that automatically restarts a Node.js application when file changes are detected.
-
Pg is a PostgreSQL client for Node.js and Pg-hstore is a companion module for serializing and deserializing JSON data to hstore format.
-
Angular is the framework used for designing the user interface of the application.
-
Clone the source code for the application at https://github.com/Emmanuel289/WinCast.git.
-
Navigate to the
backend/
folder within the folder tree and executenpm install && npm start
to install the dependencies for the backend and start the backend service. -
Navigate to the
frontend/
folder and executenpm install && ng serve --open
to install the dependencies for the web application and start the frontend service. -
(Optional) Start a postgres client using the
psql
startup shell and connect to the database after entering the required configuration parameters. You can also manage existing connections using the pgAdmin management console.
- The
weekly_forecast.js
located inside thebackend/models/
folder contains the schema for defining and composing a weekly forecast into a table for storage in the database. - The
routes.rest
file contains a list of standard HTTP methods for querying the local server which forwards the requests to the database. For example, the following request adds a new record to the database:
Content-Type: application/json
{
"date_time_local": 2024,
"temperatures": "High 25"
}
- Postman can be used to upload a csv file of datasets to create a new bulk record in the database or to update an existing record. The screenshot below shows the process of uploading a file named "weatherstats_winnipeg_forecast_daily.csv" into the database using Postman:
Postbird is a PostgreSQL client that can be used to connect to the PostgreSQL instance and view the uploaded dataset as shown below:
- PostgreSQL was the choice of the database engine because the weather forecasts are relational and we might want to persist their storage, instead of having in-memory storage. Future iterations will introduce caching on the client side for more recent or frequently accessed data and archival of older records in a cloud datastore like BigQuery or S3.
- The user interface of the application is a skeleton in its present form and does not do much. It will be updated with a service that connects with the backend to display weather data to a user.