This app allows the user to request the Thames River flow rates and water levels at a pre-specified location in order to determine if the water is safe to row on.
When the user submits their request, the App performs an API query to pull relevant records from the Environment Agency public data set and will then display a message to the user depending upon whether the values received are within preset safe limits or not.
The app also pulls data on a daily basis and caches it. It applies Machine Learning to this data to predict the daily maxima levels over the forthcoming period, and will alert the user if unsafe levels are expected.
graph TD
A0[User] --> A1{Submit Request};
A1 --> A2[App];
A2 --> A3{Pull API Data};
A3 --> A4{Extract Value};
A4 --> A5{Process Prediction};
C1[Cached Data] --> A5
A4 --Current--> D1[Display Response to User];
A5 --Predicted--> D1;
The app uses Machine Learning tools to make predictions about upcoming river conditions. As this process does not use a previously validated prediction mechanism, functionality is included that allows the predictions made by the app to be compared with corresponding actual values.
This is achieved by storing the predicted data when it is generated and comparing it to the actual daily maxima for the corresponding dates (as and when it becomes available). A chart is displayed to the user showing these actual values (per day) against the values predicted. Since the user might make several requests to the app for data during overlapping predictions periods, the minimum and maximum predictions per day will be included in the output.
The App is hosted within the Azure cloud service and exclusively uses serverless components, particularly Azure Container Apps running Python-based containers. All resource to resource authentication is handled via managed identities.
CosmosDB is used to cache the predictions data, which itself is generated using the Automated ML feature within the Azure Machine Learning service.
Testing will be included to cover the following aspects of the app design and implementation:
- Python's built-in
unittest.mockmodule can be used to test the core functionality against mocked API endpoints.
-
GitHub CodeQL can be used to perform static analysis to find vulnerabilities and errors in the app code.
-
SonarCloud/SonarQube can be also being considered to perform the same role.
- Playwright can be used to simulate user actions and test the end to end functionality of the app.
Use event driven architecture to facilitate data flow.
Environment Agency APIs:
Monitoring Station data (Kingston upon Thames)
Monitoring station data endpoint
Azure Machine Learning Tools:
Set up AutoML to train a time-series forecasting model with SDK and CLI
Testing Tools:
Navigate to the app directory:
cd ./application/rowflowCreate a virtual environment:
python3 -m venv venvActivate it:
source venv/bin/activateInstall dependencies:
pip install -r requirements.txtRun the app:
python app.pyOpen:
http://127.0.0.1:5000/Make sure Docker Desktop is running.
Navigate to app code directory in terminal.
Build the Docker image:
docker build -t rowflow .Run the Docker container:
docker run -p 5000:5000 rowflowOpen:
http://127.0.0.1:5000/